refactor: consolidate finance workflow modules
This commit is contained in:
46
web/tests/workbench-ai-composer-components.test.mjs
Normal file
46
web/tests/workbench-ai-composer-components.test.mjs
Normal file
@@ -0,0 +1,46 @@
|
||||
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, /<WorkbenchAiComposer\b/g), 2)
|
||||
assert.equal(countOccurrences(aiModeTemplate, /<WorkbenchAiFileStrip\b/g), 2)
|
||||
assert.doesNotMatch(aiModeTemplate, /<form class="workbench-ai-composer"/)
|
||||
assert.doesNotMatch(aiModeTemplate, /<article v-for="file in selectedFileCards"/)
|
||||
})
|
||||
|
||||
test('shared workbench composer keeps the parent input focus ref writable', () => {
|
||||
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"/)
|
||||
})
|
||||
Reference in New Issue
Block a user