feat: govern knowledge assets and source citations

This commit is contained in:
key
2026-08-02 01:43:43 +08:00
parent cafb836cda
commit 699cc08050
144 changed files with 17205 additions and 453 deletions
@@ -0,0 +1,30 @@
import assert from 'node:assert/strict';
import { readFile } from 'node:fs/promises';
import test from 'node:test';
const source = (path) => readFile(new URL(path, import.meta.url), 'utf8');
test('引用详情使用不透明 ref,并覆盖文本、图片和视频状态', async () => {
const [types, service, page, detail] = await Promise.all([
source('../src/types/api.ts'),
source('../src/services/knowledge.ts'),
source('../src/pages/user/sop/index.vue'),
source('../src/pages/user/sop/citation-detail.vue')
]);
assert.match(types, /detailRef\?: string \| null/);
assert.match(types, /KnowledgeCitationDetail/);
assert.match(service, /\/api\/knowledge\/citations/);
assert.match(page, /openCitationDetail/);
assert.match(page, /snippet\.detailRef/);
assert.doesNotMatch(page, /attachmentId.*navigateTo|navigateTo.*attachmentId/);
assert.match(detail, /state === 'forbidden'|state === 'not-found'/);
assert.match(detail, /authenticatedFileUrl/);
assert.match(detail, /loaded\.locator/);
assert.match(detail, /currentTime/);
});
test('引用详情页释放媒体临时 URL', async () => {
const detail = await source('../src/pages/user/sop/citation-detail.vue');
assert.match(detail, /onUnmounted\(releaseMedia\)/);
assert.match(detail, /releaseAuthenticatedFileUrl/);
});
+6 -2
View File
@@ -142,12 +142,16 @@ test('员工端 tabBar 继续保留四个固定入口', async () => {
assert.match(source, /pages\/user\/profile\/index/);
});
test('登录页按高保真原型保留品牌结构和紧凑验证码行', async () => {
test('登录页保留品牌结构并按开发开关控制验证码行', async () => {
const source = await pageSource('../src/pages/auth/login/index.vue');
assert.match(source, /手机号登录,立刻上手/);
assert.match(source, /<uni-icons[^>]+type="phone"/);
assert.match(source, /<uni-icons[^>]+type="locked"/);
assert.match(source, /v-if="smsVerificationEnabled" label="验证码"/);
assert.match(source, /const smsVerificationEnabled = !import\.meta\.env\.DEV/);
assert.match(source, /VITE_SMS_VERIFICATION_ENABLED === 'true'/);
assert.match(source, /rules: smsVerificationEnabled \? \[/);
assert.doesNotMatch(source, /class="logo-badge"/);
assert.doesNotMatch(source, /grid-template-columns:\s*1fr;[\s\S]*?\.code-button/);
});
@@ -176,7 +180,7 @@ test('登录前协议默认不勾选且协议未配置时禁止发送验证码
test('测试验证码提示必须由开发环境显式开关启用', async () => {
const source = await pageSource('../src/pages/auth/login/index.vue');
assert.match(source, /v-if="showDevSmsHint"/);
assert.match(source, /v-if="smsVerificationEnabled && showDevSmsHint"/);
assert.match(source, /import\.meta\.env\.VITE_DEV_SMS_HINT_VALUE/);
assert.match(source, /import\.meta\.env\.VITE_DEV_SMS_HINT_ENABLED === 'true'/);
assert.match(source, /\/\^\\d\{4,6\}\$\/\.test\(devSmsHintValue\)/);