This commit is contained in:
2026-07-30 21:23:06 +08:00
parent 4e24d381c2
commit 4cef53e842
23 changed files with 493 additions and 54 deletions
+14
View File
@@ -8,6 +8,7 @@ const authStoreSource = readFileSync(new URL('../stores/auth.ts', import.meta.ur
const httpSource = readFileSync(new URL('../api/http.ts', import.meta.url), 'utf8')
const sessionSource = readFileSync(new URL('../api/session.ts', import.meta.url), 'utf8')
const authApiSource = readFileSync(new URL('../api/auth.ts', import.meta.url), 'utf8')
const mainSource = readFileSync(new URL('../main.ts', import.meta.url), 'utf8')
test('matches the backend username login contract', () => {
assert.match(loginSource, /label="用户名"/)
@@ -52,3 +53,16 @@ test('uses real auth endpoints and single-flight refresh handling', () => {
assert.match(authStoreSource, /decodeMerchantToken/)
assert.doesNotMatch(authStoreSource, /mock-client:/)
})
test('keeps a valid local session during temporary context and refresh outages', () => {
assert.match(authStoreSource, /function isExpiredSessionError/)
assert.match(authStoreSource, /if \(isExpiredSessionError\(error\)\)/)
assert.match(authStoreSource, /sessionRestored\.value = true\s+return/)
assert.match(httpSource, /if \(mappedError\.status === 401 \|\| mappedError\.code === 'A0401'\)/)
assert.doesNotMatch(httpSource, /catch \(refreshError\) \{\s+clearSessionTokens\(\)/)
})
test('loads styles for programmatic Element Plus messages and dialogs', () => {
assert.match(mainSource, /element-plus\/es\/components\/message\/style\/css/)
assert.match(mainSource, /element-plus\/es\/components\/message-box\/style\/css/)
})