mirror of
https://github.com/CompassConnections/Compass.git
synced 2026-05-19 14:29:21 -04:00
Add tests
This commit is contained in:
10
.github/workflows/ci.yaml
vendored
10
.github/workflows/ci.yaml
vendored
@@ -42,6 +42,14 @@ jobs:
|
||||
# Optional: Playwright E2E tests
|
||||
- name: Install Playwright deps
|
||||
run: npx playwright install --with-deps
|
||||
# npm install @playwright/test
|
||||
# npx playwright install
|
||||
|
||||
- name: Run E2E tests
|
||||
run: npx playwright test
|
||||
run: |
|
||||
npm start &
|
||||
npx wait-on http://localhost:3000
|
||||
npx playwright test tests/playwright
|
||||
SERVER_PID=$(fuser -k 3000/tcp)
|
||||
echo $SERVER_PID
|
||||
kill $SERVER_PID
|
||||
|
||||
@@ -1,17 +1,13 @@
|
||||
import { render, screen } from '@testing-library/react';
|
||||
import {render, screen} from '@testing-library/react';
|
||||
import LoadingSpinner from '../lib/client/LoadingSpinner';
|
||||
import '@testing-library/jest-dom';
|
||||
|
||||
describe('LoadingSpinner', () => {
|
||||
it('renders a loading spinner', () => {
|
||||
render(<LoadingSpinner />);
|
||||
|
||||
// Check if the spinner container is rendered with the correct classes
|
||||
const spinnerContainer = screen.getByTestId('spinner-container');
|
||||
expect(spinnerContainer).toBeInTheDocument();
|
||||
expect(spinnerContainer).toHaveClass('flex', 'items-center', 'justify-center', 'min-h-screen');
|
||||
|
||||
render(<LoadingSpinner/>);
|
||||
|
||||
// Check if the spinner has the correct classes
|
||||
const spinner = screen.getByTestId('spinner');
|
||||
expect(spinner).toHaveClass('w-12', 'h-12', 'border-4', 'border-gray-300', 'border-t-gray-800', 'rounded-full', 'animate-spin');
|
||||
expect(spinner).toHaveClass('animate-spin');
|
||||
});
|
||||
});
|
||||
|
||||
8
tests/playwright/LoadingSpinner.test.ts
Normal file
8
tests/playwright/LoadingSpinner.test.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
import {expect, test} from '@playwright/test';
|
||||
|
||||
test('shows loading spinner on load', async ({page}) => {
|
||||
await page.goto('http://localhost:3000/profiles'); // Adjust this to your route
|
||||
|
||||
const spinner = page.locator('[data-testid="spinner"]');
|
||||
await expect(spinner).toBeVisible();
|
||||
});
|
||||
Reference in New Issue
Block a user