Debian Codegraph @

www/tests/e2e/smoke.ts

raw symbols SCIP
1 import { test, expect, TOP_LEVEL_PAGES, STANDALONE_PAGES } from './_fixtures';
2
3 // Known hyperscript issue — filter these out until fixed
4 const KNOWN_JS_ERRORS = ['init is not defined'];
5
6 function filterKnownErrors(errors: string[]): string[] {
7 return errors.filter(e => !KNOWN_JS_ERRORS.some(known => e.includes(known)));
8 }
9
10 test.describe('Smoke tests', () => {
11 for (const path of TOP_LEVEL_PAGES) {
12 test(`${path} renders without errors`, async ({ page }) => {
13 const errors: string[] = [];
14 page.on('pageerror', (err) => errors.push(err.message));
15
16 await page.goto(path);
17 await expect(page.locator('main#content-main-content')).toBeVisible();
18 expect(filterKnownErrors(errors)).toEqual([]);
19 });
20 }
21
22 for (const path of STANDALONE_PAGES) {
23 test(`${path} renders without errors`, async ({ page }) => {
24 const errors: string[] = [];
25 page.on('pageerror', (err) => errors.push(err.message));
26
27 await page.goto(path, { waitUntil: 'domcontentloaded' });
28 // Standalone pages don't use ContentLayout — just check page loaded
29 await expect(page.locator('body')).toBeVisible();
30 expect(filterKnownErrors(errors)).toEqual([]);
31 });
32 }
33
34 const SAMPLE_CONTENT_PAGES = [
35 '/docs/get-started/installation',
36 '/docs/core-concepts/mental-model',
37 '/reference/attributes/hx-get',
38 '/reference/headers/HX-Request',
39 '/reference/events',
40 '/patterns/loading/click-to-load',
41 '/patterns/forms/active-search',
42 '/essays/locality-of-behaviour',
43 ];
44
45 for (const path of SAMPLE_CONTENT_PAGES) {
46 test(`${path} renders content`, async ({ page }) => {
47 const errors: string[] = [];
48 page.on('pageerror', (err) => errors.push(err.message));
49
50 await page.goto(path);
51 await expect(page.locator('main#content-main-content')).toBeVisible();
52 await expect(page.locator('.prose')).toBeVisible();
53 expect(filterKnownErrors(errors)).toEqual([]);
54 });
55 }
56
57 test('search-index.json is valid', async ({ request }) => {
58 const response = await request.get('/search-index.json');
59 expect(response.status()).toBe(200);
60 const data = await response.json();
61 expect(data.results).toBeDefined();
62 expect(data.results.length).toBeGreaterThan(50);
63 });
64 });