Files
reader/web/test/select-usage.test.ts
hectorqinandClaude 5eb38a974b feat(web): one themed drop-down everywhere instead of native selects
- MediaSelect moves to ui/select.tsx as Select (old name kept as an alias);
  its colours fall back to the theme tokens outside 影音
- sources, reader panels and admin pages use it; business settings default
  to it
- a test rejects a native <select> anywhere but the two select components
- review scripts target the hidden native element

Co-Authored-By: Claude <noreply@anthropic.com>
2026-11-11 06:01:07 +00:00

21 lines
1.0 KiB
TypeScript

import { readdirSync, readFileSync } from 'node:fs';
import { join } from 'node:path';
import { describe, expect, it } from 'vitest';
const src = join(import.meta.dirname, '../src');
const files = (dir: string): string[] => readdirSync(dir, { withFileTypes: true })
.flatMap(entry => entry.isDirectory() ? files(join(dir, entry.name)) : entry.name.endsWith('.tsx') ? [join(dir, entry.name)] : []);
describe('下拉框', () => {
// ui.md §10: one drop-down. The two controls below own the (hidden) native element;
// a screen writing its own `<select>` gets the platform's look instead of the theme's.
it('only ui/select.tsx and ui/searchable-select.tsx render a native <select>', () => {
const owners = new Set(['ui/select.tsx', 'ui/searchable-select.tsx']);
const offenders = files(src)
.filter(file => /<select[\s>]/.test(readFileSync(file, 'utf8')))
.map(file => file.slice(src.length + 1).replaceAll('\\', '/'))
.filter(file => !owners.has(file));
expect(offenders).toEqual([]);
});
});