import assert from 'node:assert/strict' import { readFileSync } from 'node:fs' import test from 'node:test' import { fileURLToPath } from 'node:url' function readSource(path) { return readFileSync(fileURLToPath(new URL(path, import.meta.url)), 'utf8') } const aiModeComponent = readSource('../src/components/business/PersonalWorkbenchAiMode.vue') const aiModeTemplate = readSource('../src/components/business/PersonalWorkbenchAiMode.template.html') const composerComponent = readSource('../src/components/business/workbench-ai/WorkbenchAiComposer.vue') const fileStripComponent = readSource('../src/components/business/workbench-ai/WorkbenchAiFileStrip.vue') const aiModeRuntime = readSource('../src/composables/workbenchAiMode/usePersonalWorkbenchAiMode.js') function countOccurrences(source, pattern) { return source.match(pattern)?.length || 0 } test('personal workbench AI mode reuses shared composer and file strip components', () => { assert.match(aiModeComponent, /import \{ proxyRefs \} from 'vue'/) assert.match(aiModeComponent, /import WorkbenchAiComposer from '\.\/workbench-ai\/WorkbenchAiComposer\.vue'/) assert.match(aiModeComponent, /import WorkbenchAiFileStrip from '\.\/workbench-ai\/WorkbenchAiFileStrip\.vue'/) assert.match(aiModeComponent, /const aiModeRuntime = usePersonalWorkbenchAiMode\(props, emit\)/) assert.match(aiModeComponent, /const workbenchAiRuntime = proxyRefs\(aiModeRuntime\)/) assert.equal(countOccurrences(aiModeTemplate, / { assert.match(composerComponent, /:ref="runtime\.setAssistantInputRef"/) assert.match(aiModeRuntime, /function setAssistantInputRef\(element\)/) assert.match(aiModeRuntime, /assistantInputRef\.value = element/) assert.match(aiModeRuntime, /setAssistantInputRef,/) }) test('shared workbench file strip preserves OCR status badges', () => { assert.match(fileStripComponent, /file\.ocrState\?\.label/) assert.match(fileStripComponent, /class="workbench-ai-file-card__ocr"/) assert.match(fileStripComponent, /file\.ocrState\.status === 'recognizing'/) assert.match(fileStripComponent, /mdi mdi-text-recognition/) assert.match(fileStripComponent, /:title="file\.ocrState\.title \|\| file\.ocrState\.label"/) })