28 lines
1.7 KiB
JavaScript
28 lines
1.7 KiB
JavaScript
|
|
import test from 'node:test'
|
||
|
|
import assert from 'node:assert/strict'
|
||
|
|
import { readFileSync } from 'node:fs'
|
||
|
|
import { assistantSessionLoadingCopy } from '../../src/utils/assistant-loading.js'
|
||
|
|
|
||
|
|
test('loading explains permissions and recent conversations without invented progress', () => {
|
||
|
|
assert.match(assistantSessionLoadingCopy(0), /操作权限和最近对话/)
|
||
|
|
assert.equal(assistantSessionLoadingCopy(7999), assistantSessionLoadingCopy(0))
|
||
|
|
assert.match(assistantSessionLoadingCopy(8000), /响应比平时慢/)
|
||
|
|
assert.match(assistantSessionLoadingCopy(20000), /等待服务器响应/)
|
||
|
|
assert.match(assistantSessionLoadingCopy(90000), /先收起助手/)
|
||
|
|
for (const ms of [0, 8000, 20000, 90000]) assert.doesNotMatch(assistantSessionLoadingCopy(ms), /完成|成功|%|即将/)
|
||
|
|
})
|
||
|
|
|
||
|
|
test('preparing screen replaces stale recovery and action controls without artificial delays', () => {
|
||
|
|
const main = readFileSync(new URL('../../src/components/BusinessAssistant/index.vue', import.meta.url), 'utf8')
|
||
|
|
assert.match(main, /<assistant-session-loading v-if="sessionLoading"/)
|
||
|
|
assert.match(main, /canOperateDraft && !sessionLoading && !resumePrompt/)
|
||
|
|
assert.match(main, /assistant.needsRefresh && !sessionLoading && !resumePrompt/)
|
||
|
|
assert.match(main, /v-if="allowed && !sessionLoading && !resumePrompt" class="business-assistant-composer"/)
|
||
|
|
assert.doesNotMatch(main, /正在核对权限并恢复会话/)
|
||
|
|
const loading = readFileSync(new URL('../../src/components/BusinessAssistant/AssistantSessionLoading.vue', import.meta.url), 'utf8')
|
||
|
|
assert.match(loading, /role="status" aria-live="polite"/)
|
||
|
|
assert.match(loading, /prefers-reduced-motion/)
|
||
|
|
assert.match(loading, /clearInterval\(timer\)/)
|
||
|
|
assert.doesNotMatch(loading, /setTimeout|Math\.random/)
|
||
|
|
})
|