import fs from 'node:fs' import path from 'node:path' import test from 'node:test' import assert from 'node:assert/strict' import { fileURLToPath } from 'node:url' const __dirname = path.dirname(fileURLToPath(import.meta.url)) const repoRoot = path.resolve(__dirname, '..', '..') const frontendRoot = path.join(repoRoot, 'frontend') const standaloneRoot = path.join(frontendRoot, 'standalone-web', 'src') const app = fs.readFileSync(path.join(standaloneRoot, 'App.vue'), 'utf8') const navigation = fs.readFileSync(path.join(standaloneRoot, 'features', 'navigation', 'navigation-config.ts'), 'utf8') const workbenchStyles = fs.readFileSync(path.join(standaloneRoot, 'styles', 'workbench.css'), 'utf8') const bridge = fs.readFileSync(path.join(frontendRoot, 'shared', 'api', 'astrbot-page-bridge.ts'), 'utf8') const views = ['overview', 'generate', 'queue', 'performance', 'gallery', 'profiles', 'materials', 'settings', 'logs'] test('UI shell keeps all supported views and landmarks', () => { for (const view of views) assert.match(navigation, new RegExp('key: \"' + view + '\"'), 'missing nav view: ' + view) assert.match(app, //) assert.match(app, /role=\"status\"[\s\S]*aria-live=\"polite\"/) }) test('UI shell preserves plugin bridge and primary page loading', () => { assert.match(app, /import GalleryPage from/) assert.match(app, /import SettingsPage from/) assert.match(app, /defineAsyncComponent\(\(\) => import\(\"\.\/features\/workflow\/WorkflowComposer\.vue\"\)\)/) assert.match(bridge, /kind: \"ready\"/) assert.match(bridge, /message.kind === \"context\"/) assert.match(bridge, /apiGet/) assert.match(bridge, /apiPost/) }) test('UI CSS avoids layout-property animation and supports reduced motion', () => { assert.doesNotMatch(workbenchStyles, /transition\s*:\s*[^;]*(?:width|height|max-height|grid-template-columns|padding|margin)/i) assert.match(workbenchStyles, /@media \(max-width: 1180px\)/) assert.match(workbenchStyles, /@media \(max-width: 900px\)/) assert.match(workbenchStyles, /@media \(prefers-reduced-motion: reduce\)/) assert.match(workbenchStyles, /--ui-focus-ring/) }) test('standalone image markup provides alt text', () => { const files = [] const visit = (dir) => { for (const entry of fs.readdirSync(dir, { withFileTypes: true })) { const fullPath = path.join(dir, entry.name) if (entry.isDirectory()) visit(fullPath) else if (entry.name.endsWith('.vue')) files.push(fullPath) } } visit(standaloneRoot) for (const file of files) { const source = fs.readFileSync(file, 'utf8') for (const tag of source.match(//gi) ?? []) { assert.match(tag, /\balt\s*=/i, 'image without alt: ' + path.relative(repoRoot, file)) } } })