2026-06-03 15:14:44 +08:00
|
|
|
import assert from 'node:assert/strict'
|
2026-06-22 11:58:53 +08:00
|
|
|
import { readdirSync, readFileSync } from 'node:fs'
|
2026-06-03 15:14:44 +08:00
|
|
|
import test from 'node:test'
|
|
|
|
|
import { fileURLToPath } from 'node:url'
|
|
|
|
|
|
|
|
|
|
const appShell = readFileSync(
|
|
|
|
|
fileURLToPath(new URL('../src/views/AppShellRouteView.vue', import.meta.url)),
|
|
|
|
|
'utf8'
|
|
|
|
|
)
|
|
|
|
|
const appShellComposable = readFileSync(
|
|
|
|
|
fileURLToPath(new URL('../src/composables/useAppShell.js', import.meta.url)),
|
|
|
|
|
'utf8'
|
|
|
|
|
)
|
|
|
|
|
const workbench = readFileSync(
|
|
|
|
|
fileURLToPath(new URL('../src/components/business/PersonalWorkbench.vue', import.meta.url)),
|
|
|
|
|
'utf8'
|
|
|
|
|
)
|
2026-06-20 14:42:04 +08:00
|
|
|
const aiMode = readFileSync(
|
|
|
|
|
fileURLToPath(new URL('../src/components/business/PersonalWorkbenchAiMode.vue', import.meta.url)),
|
|
|
|
|
'utf8'
|
|
|
|
|
)
|
2026-06-22 11:58:53 +08:00
|
|
|
const aiModeTemplate = readFileSync(
|
|
|
|
|
fileURLToPath(new URL('../src/components/business/PersonalWorkbenchAiMode.template.html', import.meta.url)),
|
|
|
|
|
'utf8'
|
|
|
|
|
)
|
|
|
|
|
const aiModeRuntimeDir = fileURLToPath(new URL('../src/composables/workbenchAiMode/', import.meta.url))
|
|
|
|
|
const aiModeRuntime = readdirSync(aiModeRuntimeDir)
|
|
|
|
|
.filter((file) => file.endsWith('.js'))
|
|
|
|
|
.sort()
|
|
|
|
|
.map((file) => readFileSync(new URL(`../src/composables/workbenchAiMode/${file}`, import.meta.url), 'utf8'))
|
|
|
|
|
.join('\n')
|
|
|
|
|
const aiModeSurface = `${aiMode}\n${aiModeTemplate}\n${aiModeRuntime}`
|
2026-06-21 22:49:53 +08:00
|
|
|
const aiDetailReference = readFileSync(
|
|
|
|
|
fileURLToPath(new URL('../src/utils/aiDocumentDetailReference.js', import.meta.url)),
|
|
|
|
|
'utf8'
|
|
|
|
|
)
|
2026-06-03 15:14:44 +08:00
|
|
|
|
|
|
|
|
test('workbench document detail keeps workbench as the return target', () => {
|
|
|
|
|
assert.match(workbench, /source:\s*'workbench'/)
|
|
|
|
|
assert.match(workbench, /returnTo:\s*'workbench'/)
|
|
|
|
|
assert.match(appShell, /:back-label="detailBackLabel"/)
|
2026-06-22 11:58:53 +08:00
|
|
|
assert.match(appShell, /const explicitReturnTo = resolveDocumentDetailReturnTarget\(payload\.returnTo\)/)
|
|
|
|
|
assert.match(appShell, /const fallbackToWorkbench = \(/)
|
2026-06-03 15:14:44 +08:00
|
|
|
assert.match(appShell, /String\(payload\.source \|\| ''\)\.trim\(\) === 'workbench'/)
|
2026-06-22 11:58:53 +08:00
|
|
|
assert.match(appShell, /const returnTo = explicitReturnTo \|\| \(fallbackToWorkbench \? 'workbench' : ''\)/)
|
2026-06-20 14:42:04 +08:00
|
|
|
assert.match(appShell, /const detailPayload = request \|\| \{[\s\S]*detailLookupOnly:\s*true[\s\S]*\}/)
|
|
|
|
|
assert.match(appShell, /openRequestDetail\(detailPayload,\s*\{ returnTo \}\)/)
|
2026-06-03 15:14:44 +08:00
|
|
|
assert.match(appShellComposable, /const detailReturnTarget = computed/)
|
|
|
|
|
assert.match(appShellComposable, /detailReturnTarget\.value === 'workbench' \? '返回首页' : '返回单据中心'/)
|
2026-06-22 11:58:53 +08:00
|
|
|
assert.match(appShellComposable, /const returnTo = resolveDocumentDetailReturnTarget\(options\.returnTo\)/)
|
|
|
|
|
assert.match(appShellComposable, /nextQuery\.returnTo = returnTo/)
|
2026-06-03 15:14:44 +08:00
|
|
|
assert.match(appShellComposable, /router\.push\(\{ name: 'app-workbench' \}\)/)
|
|
|
|
|
assert.match(appShellComposable, /router\.push\(\{ name: 'app-documents', query: buildDocumentReturnQuery\(\) \}\)/)
|
|
|
|
|
})
|
2026-06-20 14:42:04 +08:00
|
|
|
|
2026-06-22 11:58:53 +08:00
|
|
|
test('AI conversation document detail returns to the active conversation content', () => {
|
|
|
|
|
assert.match(aiDetailReference, /source:\s*'ai-conversation'/)
|
|
|
|
|
assert.match(aiDetailReference, /returnTo:\s*'conversation'/)
|
|
|
|
|
assert.match(appShell, /@back-to-requests="handleDocumentDetailBack"/)
|
|
|
|
|
assert.match(appShell, /const DOCUMENT_DETAIL_RETURN_TARGETS = new Set\(\['workbench', 'conversation'\]\)/)
|
|
|
|
|
assert.match(
|
|
|
|
|
appShell,
|
|
|
|
|
/function handleDocumentDetailBack\(\) \{[\s\S]*detailReturnTarget\.value === 'conversation'[\s\S]*dispatchAiSidebarCommand\('open-recent', activeConversation\)/
|
|
|
|
|
)
|
|
|
|
|
assert.match(
|
|
|
|
|
appShellComposable,
|
|
|
|
|
/if \(detailReturnTarget\.value === 'conversation'\) \{[\s\S]*return '返回对话'/
|
|
|
|
|
)
|
|
|
|
|
assert.match(
|
|
|
|
|
appShellComposable,
|
|
|
|
|
/if \(detailReturnTarget\.value === 'conversation'\) \{[\s\S]*return router\.push\(\{ name: 'app-workbench' \}\)/
|
|
|
|
|
)
|
|
|
|
|
})
|
|
|
|
|
|
2026-06-21 22:49:53 +08:00
|
|
|
test('AI detail links resolve real claim identity before opening document detail', () => {
|
2026-06-22 11:58:53 +08:00
|
|
|
assert.match(aiModeSurface, /buildAiDocumentDetailRequest/)
|
|
|
|
|
assert.match(aiModeSurface, /parseAiApplicationDetailHref/)
|
|
|
|
|
assert.match(aiModeSurface, /parseAiDocumentDetailHref/)
|
2026-06-21 22:49:53 +08:00
|
|
|
assert.match(aiDetailReference, /detailLookupOnly:\s*true/)
|
|
|
|
|
assert.match(aiDetailReference, /params\.get\('claim_id'\)/)
|
|
|
|
|
assert.match(aiDetailReference, /params\.get\('claim_no'\)/)
|
|
|
|
|
assert.match(aiDetailReference, /isBusinessDocumentReference/)
|
|
|
|
|
assert.match(aiDetailReference, /const claimId = explicitClaimId \|\| \(!referenceIsBusinessNo \? reference : ''\)/)
|
|
|
|
|
assert.match(aiDetailReference, /const claimNo = explicitClaimNo \|\| \(referenceIsBusinessNo \? reference : ''\)/)
|
2026-06-20 14:42:04 +08:00
|
|
|
assert.match(
|
|
|
|
|
appShell,
|
|
|
|
|
/v-else-if="activeView === 'documents' && detailMode && !selectedRequest"[\s\S]*正在加载完整单据详情/
|
|
|
|
|
)
|
|
|
|
|
assert.match(
|
|
|
|
|
appShell,
|
|
|
|
|
/const detailPayload = request \|\| \{[\s\S]*detailLookupOnly:\s*true[\s\S]*\}/
|
|
|
|
|
)
|
2026-06-21 22:49:53 +08:00
|
|
|
assert.match(appShell, /isBusinessDocumentReference/)
|
|
|
|
|
assert.match(appShell, /const requestCandidates = Array\.isArray\(workbenchRequests\.value\)/)
|
|
|
|
|
assert.match(appShell, /claimId:\s*fallbackClaimId/)
|
|
|
|
|
assert.match(appShell, /claimNo:\s*fallbackClaimNo/)
|
2026-06-20 14:42:04 +08:00
|
|
|
assert.match(
|
|
|
|
|
appShellComposable,
|
|
|
|
|
/const isDetailLookupOnlyRequest = isDetailLookupOnlyPayload\(request\)[\s\S]*selectedRequestSnapshot\.value = isDetailLookupOnlyRequest \? null : request \|\| null/
|
|
|
|
|
)
|
2026-06-21 22:49:53 +08:00
|
|
|
assert.match(appShellComposable, /const workbenchRequests = computed/)
|
|
|
|
|
assert.match(appShellComposable, /workbenchRequests\.value\.find\(\(item\) => isSameRequestIdentity\(item, requestId\)\)/)
|
2026-06-20 14:42:04 +08:00
|
|
|
assert.match(
|
|
|
|
|
appShellComposable,
|
|
|
|
|
/void refreshSelectedRequestDetail\(isDetailLookupOnlyRequest \? requestId : request\)/
|
|
|
|
|
)
|
|
|
|
|
})
|