前端:增加测试数据模式切换
This commit is contained in:
@@ -834,6 +834,35 @@ function hasExpectedRequest(expectedRequest) {
|
||||
)
|
||||
}
|
||||
|
||||
const source = (relativePath) => readFile(path.join(frontendRoot, relativePath), 'utf8')
|
||||
|
||||
test('Web 测试模式统一附加请求头并通过路由重建清空页面状态', async () => {
|
||||
const requestSource = await source('src/utils/request.js')
|
||||
const appMainSource = await source('src/layout/components/AppMain.vue')
|
||||
const navbarSource = await source('src/layout/components/Navbar.vue')
|
||||
|
||||
assert.match(requestSource, /X-Test-Batch-Id/)
|
||||
assert.match(requestSource, /TEST_BATCH_UNAVAILABLE/)
|
||||
assert.match(appMainSource, /scopeVersion/)
|
||||
assert.match(navbarSource, /TestBatchModeSwitch/)
|
||||
assert.match(navbarSource, /测试数据/)
|
||||
})
|
||||
|
||||
test('Web 测试批次上下文仅持久化 ID,登出清除 ID 且管理员标记严格来自后端布尔值', async () => {
|
||||
const contextSource = await source('src/utils/testBatchContext.js')
|
||||
const storeSource = await source('src/store/modules/testBatch.js')
|
||||
const userSource = await source('src/store/modules/user.js')
|
||||
|
||||
assert.match(contextSource, /sessionStorage/)
|
||||
assert.doesNotMatch(contextSource, /batchName|status|admin|permission/i)
|
||||
assert.match(storeSource, /getStoredTestBatchId/)
|
||||
assert.match(storeSource, /setStoredTestBatchId/)
|
||||
assert.match(storeSource, /clearStoredTestBatchId/)
|
||||
assert.match(userSource, /admin:\s*false/)
|
||||
assert.match(userSource, /this\.admin\s*=\s*user\.admin\s*===\s*true/)
|
||||
assert.match(userSource, /clearStoredTestBatchId\(\)/)
|
||||
})
|
||||
|
||||
test('17 个页面的真实权限门禁逐项匹配独立硬编码契约', async () => {
|
||||
assert.equal(expectedPagePermissions.length, 17)
|
||||
assert.equal(expectedButtonPermissions.length, 44)
|
||||
|
||||
Reference in New Issue
Block a user