Skip to content

Commit 69bcd8c

Browse files
committed
site: update type handling in /types route and improve test visibility checks
1 parent 32dc7f6 commit 69bcd8c

2 files changed

Lines changed: 11 additions & 9 deletions

File tree

meta/site/src/routes/types/+page.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,13 @@ import type {TypeDef} from '@datakit/scripts/site';
33
import type {PageLoad} from './$types';
44
import typesData from '$lib/data/generated/types.json';
55

6-
const FILE_ORDER = ['array', 'function', 'object', 'shared'] as const;
7-
type TypesFile = typeof FILE_ORDER[number];
8-
96
export type TypeGroup = {
10-
id: TypesFile;
7+
id: string;
118
types: TypeDef[];
129
};
1310

1411
export const load: PageLoad = () => ({
15-
groups: FILE_ORDER
12+
groups: Object.keys(typesData as Record<string, TypeDef[]>)
1613
.filter(f => (typesData as Record<string, TypeDef[]>)[f]?.length)
1714
.map(f => ({
1815
id: f,

meta/site/tests/08_route_types.test.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
1+
import {createRequire} from 'module';
2+
13
import {expect, test} from '@playwright/test';
24

5+
const require = createRequire(import.meta.url);
6+
const typesData = require('../src/lib/data/generated/types.json') as Record<string, unknown[]>;
7+
const typeGroups = Object.keys(typesData).sort();
8+
39
/*
410
* Viewport strategy (mirrors what we should apply to 06_route_tx tests too):
511
* - Sidebar is `hidden md:flex` → visible only at md+ (768px+)
@@ -17,10 +23,9 @@ test.describe('/types sidebar', () => {
1723
test('renders group headers', async ({page}) => {
1824
await page.goto('/datakit/types/');
1925
const navHeaders = page.locator('[data-testid="group-nav"] code');
20-
await expect(navHeaders.filter({hasText: /^array$/})).toBeVisible();
21-
await expect(navHeaders.filter({hasText: /^function$/})).toBeVisible();
22-
await expect(navHeaders.filter({hasText: /^object$/})).toBeVisible();
23-
await expect(navHeaders.filter({hasText: /^shared$/})).toBeVisible();
26+
for (const group of typeGroups) {
27+
await expect(navHeaders.filter({hasText: new RegExp(`^${group}$`)})).toBeVisible();
28+
}
2429
});
2530

2631
test('shows known type names in nav', async ({page}) => {

0 commit comments

Comments
 (0)