Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions frontend/src/app/App.test.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Suspense } from 'react';
import { describe, expect, it } from 'vitest';
import { beforeAll, describe, expect, it } from 'vitest';
import { render, screen } from '@testing-library/react';
import { MockedProvider } from '@apollo/client/testing/react';
import { MemoryRouter } from 'react-router';
Expand All @@ -26,11 +26,23 @@ function renderRoute(route: string) {
);
}

/** The pages are lazy, and the import takes longer when the whole test suite runs at once. */
const findHeading = (name: string) =>
screen.findByRole('heading', { level: 1, name }, { timeout: 5000 });

describe('AppRoutes', () => {
// Build the lazy pages once, with plenty of time. The tests then check the routes,
// not how fast the machine is when the whole suite runs at once.
beforeAll(async () => {
await Promise.all([
import('../features/search/SearchPage'),
import('../features/wine/WinePage'),
import('../features/my/MyPage'),
import('../features/my/MyListPage'),
import('../features/my/MyReviewsPage'),
import('../features/auth/AccountPage'),
]);
}, 30_000);

it.each([
['/finnes-ikke', 'Fant ikke siden'],
['/vin/abc', 'Fant ikke vinen'],
Expand All @@ -55,4 +67,4 @@ describe('AppRoutes', () => {
renderRoute('/sok');
expect(await findHeading('Utforsk viner')).toBeInTheDocument();
});
});
});