Skip to content

Commit 4b7aa80

Browse files
committed
feat: update playwright
1 parent bba9134 commit 4b7aa80

File tree

3 files changed

+29
-56
lines changed

3 files changed

+29
-56
lines changed

apps/docs/playwright.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export default defineConfig({
1111
reporter: 'html',
1212
use: {
1313
baseURL: 'http://localhost:7878',
14-
trace: 'on-first-retry',
14+
trace: 'retain-on-failure',
1515
},
1616
projects: [
1717
{
Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,21 @@
11
import { expect, test } from '@playwright/test';
2-
import { getAllStaticRoutes } from './utils/static-routes';
2+
import { getRoutesByType } from './utils/static-routes';
33

4-
test.describe('All routes should return 200', () => {
5-
const sampleRoutes = getAllStaticRoutes();
4+
test.describe('Static routes', () => {
5+
const routes = getRoutesByType();
66

77
// biome-ignore lint/complexity/noForEach: <explanation>
8-
sampleRoutes.forEach((route) => {
9-
test(`${route.url}`, async ({ page }) => {
10-
console.log(`Testing route: ${route.url}`);
11-
const response = await page.goto(route.url);
12-
expect(response?.status()).toBe(200);
13-
await expect(page.locator('body')).toBeVisible();
8+
Object.entries(routes).forEach(([type, sampleRoutes]) => {
9+
test.describe(type, () => {
10+
// biome-ignore lint/complexity/noForEach: <explanation>
11+
sampleRoutes.forEach((route) => {
12+
test(`${route.url}`, async ({ page }) => {
13+
console.log(`Testing route: ${route.url}`);
14+
const response = await page.goto(route.url);
15+
expect(response?.status()).toBe(200);
16+
await expect(page.locator('body')).toBeVisible();
17+
});
18+
});
1419
});
1520
});
1621
});

apps/docs/tests/e2e/utils/static-routes.ts

Lines changed: 14 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -64,51 +64,19 @@ export function getRoutesByType() {
6464
const allRoutes = getAllStaticRoutes();
6565

6666
return {
67-
docs: allRoutes.filter((route) => route.type === 'docs'),
68-
blog: allRoutes.filter((route) => route.type === 'blog'),
69-
learn: allRoutes.filter((route) => route.type === 'learn'),
70-
all: allRoutes,
67+
'/docs/13': allRoutes.filter(
68+
(route) => route.type === 'docs' && route.url.startsWith('/docs/13'),
69+
),
70+
'/docs/14': allRoutes.filter(
71+
(route) => route.type === 'docs' && route.url.startsWith('/docs/14'),
72+
),
73+
'/docs': allRoutes.filter(
74+
(route) =>
75+
route.type === 'docs' &&
76+
!route.url.startsWith('/docs/13') &&
77+
!route.url.startsWith('/docs/14'),
78+
),
79+
'/blog': allRoutes.filter((route) => route.type === 'blog'),
80+
'/learn': allRoutes.filter((route) => route.type === 'learn'),
7181
};
7282
}
73-
74-
/**
75-
* Get a sample of routes for quick testing
76-
*/
77-
export function getSampleRoutes(limit = 10): StaticRoute[] {
78-
const routes = getAllStaticRoutes();
79-
80-
// Get a balanced sample from each type
81-
const sampleSize = Math.ceil(limit / 3);
82-
const routesByType = getRoutesByType();
83-
84-
return [
85-
...routesByType.docs.slice(0, sampleSize),
86-
...routesByType.blog.slice(0, sampleSize),
87-
...routesByType.learn.slice(0, sampleSize),
88-
].slice(0, limit);
89-
}
90-
91-
/**
92-
* Clean URL by removing fragments that might cause navigation issues
93-
*/
94-
export function cleanUrl(url: string): string {
95-
// Remove URL fragments (#) that can cause timeouts in tests
96-
return url.split('#')[0];
97-
}
98-
99-
/**
100-
* Check if a URL has fragments that might cause navigation issues
101-
*/
102-
export function hasUrlFragments(url: string): boolean {
103-
return url.includes('#');
104-
}
105-
106-
/**
107-
* Get routes suitable for e2e testing (clean URLs without fragments)
108-
*/
109-
export function getTestableRoutes(): StaticRoute[] {
110-
return getAllStaticRoutes().map((route) => ({
111-
...route,
112-
url: cleanUrl(route.url),
113-
}));
114-
}

0 commit comments

Comments
 (0)