Debian Codegraph @

www/tests/e2e/content-pages.ts

raw symbols SCIP
1 import { test, expect } from './_fixtures';
2
3 test.describe('Content page structure', () => {
4 test('docs page has sidebar with section groups', async ({ page }) => {
5 await page.goto('/docs');
6 const sidebar = page.locator('#sidebar-nav');
7 await expect(sidebar).toBeVisible();
8
9 const groups = sidebar.locator('h3');
10 expect(await groups.count()).toBeGreaterThanOrEqual(6);
11 });
12
13 test('docs sidebar scrollspy highlights a link on scroll', async ({ page }) => {
14 await page.goto('/docs', { waitUntil: 'networkidle' });
15 await page.waitForTimeout(300);
16
17 // Scroll through the page until the observer activates a link
18 for (let y = 0; y <= 2000; y += 300) {
19 await page.evaluate((scrollY: number) => window.scrollTo(0, scrollY), y);
20 await page.waitForTimeout(150);
21 if (await page.locator('#sidebar-nav a.sidebar-link[aria-current]').count() > 0) break;
22 }
23 const activeLink = page.locator('#sidebar-nav a.sidebar-link[aria-current]');
24 await expect(activeLink).toHaveCount(1);
25 const href = await activeLink.getAttribute('href');
26 expect(href).toMatch(/^#/);
27 });
28
29 test('reference sidebar highlights current page', async ({ page }) => {
30 await page.goto('/reference/attributes/hx-get');
31 const activeLink = page.locator('#sidebar-nav a[aria-current]');
32 await expect(activeLink).toHaveCount(1);
33 await expect(activeLink).toContainText('hx-get');
34 });
35
36 test('reference sidebar section contains current page links', async ({ page }) => {
37 await page.goto('/reference/attributes/hx-get');
38 const group = page.locator('#sidebar-nav h3', { hasText: 'Attributes' });
39 await expect(group).toBeVisible();
40 });
41
42 test('docs sidebar anchor navigates to in-page heading', async ({ page }) => {
43 await page.goto('/docs');
44 const sidebarToggle = page.locator('label[for="sidebar-toggle-mobile"]');
45 if (await sidebarToggle.isVisible()) {
46 await sidebarToggle.click();
47 }
48 const link = page.locator('#sidebar-nav a.sidebar-link', { hasText: 'Installation' }).first();
49 const href = await link.getAttribute('href');
50 expect(href).toBe('#installation');
51 await link.click();
52 await expect(page).toHaveURL(/\/docs#installation/);
53 });
54
55 test('table of contents visible on wide viewport', async ({ page }) => {
56 await page.setViewportSize({ width: 1400, height: 900 });
57 await page.goto('/docs');
58 await expect(page.locator('#page-outline')).toBeVisible();
59 });
60
61 test('table of contents hidden on narrow viewport', async ({ page }) => {
62 await page.setViewportSize({ width: 1024, height: 768 });
63 await page.goto('/docs');
64 await expect(page.locator('#page-outline')).not.toBeVisible();
65 });
66
67 test('category URLs redirect to reference index', async ({ page }) => {
68 await page.goto('/reference/attributes');
69 await expect(page).toHaveURL(/\/reference/);
70 });
71
72 test('patterns page has pattern links', async ({ page }) => {
73 await page.goto('/patterns');
74 const patternLinks = page.locator('a[href*="/patterns/"]');
75 expect(await patternLinks.count()).toBeGreaterThan(5);
76 });
77 });