@sanqianx/project-knowledge 5.0.33 → 5.0.35
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/marketplace.json +1 -1
- package/CHANGELOG.md +14 -0
- package/_site/_test/chat-claudecodeui-match-test.js +22 -3
- package/_site/_test/fresh-product-data-test.js +1 -1
- package/_site/_test/glm-ui-refresh-review-test.js +1 -1
- package/_site/_test/harness-isolation-test.js +1 -1
- package/_site/_test/home-overview-test.js +64 -0
- package/_site/_test/index-error-display-contract-test.js +23 -1
- package/_site/_test/knowledge-engine-client-test.js +1 -1
- package/_site/_test/memory-groups-ui-test.js +149 -0
- package/_site/_test/module-supervisor-backoff-reset-test.js +64 -0
- package/_site/_test/module-terminal-restart-test.js +1 -1
- package/_site/_test/packaged-ui-smoke-test.js +40 -2
- package/_site/_test/parallel-capture-safety-r5-mem005-health-test.js +94 -33
- package/_site/_test/parallel-knowledge-client-error-code-test.js +11 -1
- package/_site/_test/parallel-logging-acceptance-log008-test.js +23 -11
- package/_site/_test/parallel-memory-candidate-test.js +134 -84
- package/_site/_test/parallel-memory-capture-r3-mem005-persistence-test.js +100 -38
- package/_site/_test/parallel-memory-capture-r4-mem005-health-test.js +92 -32
- package/_site/_test/parallel-memory-home-review-test.js +148 -0
- package/_site/_test/parallel-memory-manual-test.js +140 -34
- package/_site/_test/parallel-memory-scope-test.js +91 -23
- package/_site/_test/parallel-memory-source-test.js +54 -25
- package/_site/_test/parallel-memory-sync-test.js +102 -75
- package/_site/_test/parallel-nav-failure-test.js +36 -16
- package/_site/_test/parallel-nav-home-issues-test.js +159 -0
- package/_site/_test/parallel-nav-offline-test.js +37 -9
- package/_site/_test/parallel-nav-operability-test.js +12 -1
- package/_site/_test/parallel-nav-switch-test.js +65 -19
- package/_site/_test/parallel-nav-theme-test.js +52 -7
- package/_site/_test/parallel-nav-viewport-test.js +13 -4
- package/_site/_test/product-diagnostics-ui-test.js +15 -3
- package/_site/_test/product-empty-state-test.js +81 -15
- package/_site/_test/product-import-ui-test.js +35 -9
- package/_site/_test/product-navigation-test.js +78 -17
- package/_site/_test/product-progress-status-test.js +21 -5
- package/_site/_test/project-module-partial-recovery-test.js +22 -7
- package/_site/_test/project-unbind-late-read-ui-test.js +45 -14
- package/_site/_test/workspace-ui-contract-test.js +38 -5
- package/_site/lib/engine-connection.js +1 -1
- package/_site/lib/engine-knowledge-client.js +1 -1
- package/_site/lib/module-bridge.js +16 -6
- package/_site/lib/server-app.js +23 -0
- package/_site/scripts/refresh-runtime-manifest.js +108 -0
- package/module-runtime-manifest.json +17 -15
- package/package.json +2 -2
- package/plugins/project-knowledge/.claude-plugin/plugin.json +1 -1
- package/plugins/project-knowledge/.codex-plugin/plugin.json +1 -1
- package/plugins/project-knowledge/.mcp.json +1 -1
- package/ui/index.html +14 -11
- package/ui/product.css +42 -0
- package/ui/product.js +861 -212
|
@@ -1,6 +1,18 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
// NAV-002 — 主题同步。
|
|
3
3
|
//
|
|
4
|
+
// 迁移说明(五页简化 UI):
|
|
5
|
+
// - nav [data-view] 契约:只有 home/memory/projects/search/activity 五页,
|
|
6
|
+
// work 导航按钮已移除;断言导航恰好五项且不含 work。
|
|
7
|
+
// - '#work' 与未知 hash 经 titles 检查回落 home(history.replaceState 归位
|
|
8
|
+
// '#home',#view-home active、标题「首页」)。
|
|
9
|
+
// - work 不再是导航页:#view-work 仍在 DOM 且永远 hidden,内部 #workFrame
|
|
10
|
+
// 保留为 Workbench 服务挂载点。终端帧的打开路径从「点击 work 导航」改为
|
|
11
|
+
// 「#openSystem 系统抽屉 → #configureProviders」(initializeFrame('terminal'))。
|
|
12
|
+
// - vectorHub/vectorFrame 已删除(检索页改为服务端检索),帧列表只剩
|
|
13
|
+
// terminal(workFrame) 与 eventBridge(bridgeFrame)。
|
|
14
|
+
// - 首页不再罗列项目:导入后的项目出现改为断言顶栏 #projectSelect 选项。
|
|
15
|
+
//
|
|
4
16
|
// The shell owns the product theme: switching it must persist, every embedded
|
|
5
17
|
// module that is already ready must be told about the new theme, and the
|
|
6
18
|
// switch must not rebuild the module task.
|
|
@@ -23,10 +35,12 @@ const { startHarness, makeRepo } = require('./helpers/parallel-nav-shell');
|
|
|
23
35
|
|
|
24
36
|
const EVIDENCE = process.env.PK_TEST_EVIDENCE_DIR ? path.resolve(process.env.PK_TEST_EVIDENCE_DIR) : null;
|
|
25
37
|
|
|
38
|
+
// The workbench frame survives only as a hidden service mount (opened from the
|
|
39
|
+
// system drawer), and the event bridge still lives on the activity page. The
|
|
40
|
+
// vector hub frame was removed with the work navigation page.
|
|
26
41
|
const FRAMES = [
|
|
27
|
-
{ key: 'terminal', id: 'workFrame', view: 'work' },
|
|
28
|
-
{ key: 'vectorHub', id: 'vectorFrame', view: 'search' },
|
|
29
42
|
{ key: 'eventBridge', id: 'bridgeFrame', view: 'activity' },
|
|
43
|
+
{ key: 'terminal', id: 'workFrame' },
|
|
30
44
|
];
|
|
31
45
|
|
|
32
46
|
async function main() {
|
|
@@ -43,11 +57,36 @@ async function main() {
|
|
|
43
57
|
);
|
|
44
58
|
await harness.requestRegistryRefresh();
|
|
45
59
|
await harness.waitFor(
|
|
46
|
-
() => harness.run("document.getElementById('
|
|
60
|
+
() => harness.run("[...document.getElementById('projectSelect').options].some(option => option.textContent === 'NAV002 项目')"),
|
|
47
61
|
'the imported project is listed',
|
|
48
62
|
20000,
|
|
49
63
|
);
|
|
50
64
|
|
|
65
|
+
// NAV-002 navigation contract (five-page UI): exactly the five pages, no
|
|
66
|
+
// work button, and the workbench survives as a hidden service mount.
|
|
67
|
+
assert.deepEqual(
|
|
68
|
+
await harness.run("[...document.querySelectorAll('nav [data-view]')].map(button => button.dataset.view)"),
|
|
69
|
+
['home', 'memory', 'projects', 'search', 'activity'],
|
|
70
|
+
'the navigation offers exactly the five pages',
|
|
71
|
+
);
|
|
72
|
+
assert.equal(await harness.run("document.querySelector('[data-view=\"work\"]') === null"), true, 'the work navigation button is removed');
|
|
73
|
+
assert.equal(await harness.run("document.getElementById('view-work') !== null"), true, 'the work section survives in the DOM');
|
|
74
|
+
assert.equal(await harness.run("document.getElementById('view-work').hidden"), true, 'the work section stays hidden');
|
|
75
|
+
assert.equal(await harness.run("document.getElementById('workFrame') !== null"), true, 'the workbench service mount (workFrame) survives');
|
|
76
|
+
// Unknown hashes fall back to home through the same titles guard the
|
|
77
|
+
// product uses; the workbench page itself is no longer reachable.
|
|
78
|
+
for (const hash of ['#work', '#anything']) {
|
|
79
|
+
await harness.run(`location.hash = ${JSON.stringify(hash)}`);
|
|
80
|
+
await harness.waitFor(
|
|
81
|
+
async () => (await harness.run("document.getElementById('view-home').classList.contains('active')"))
|
|
82
|
+
&& (await harness.run("document.getElementById('pageTitle').textContent")) === '首页'
|
|
83
|
+
&& (await harness.run("location.hash")) === '#home',
|
|
84
|
+
`the ${hash} hash falls back to home`,
|
|
85
|
+
10000,
|
|
86
|
+
);
|
|
87
|
+
assert.equal(await harness.run("document.getElementById('view-work').hidden"), true, `the ${hash} fallback never reveals the work section`);
|
|
88
|
+
}
|
|
89
|
+
|
|
51
90
|
const shellTheme = () => harness.run("document.documentElement.dataset.theme");
|
|
52
91
|
const storedTheme = () => harness.run("localStorage.getItem('kb.theme')");
|
|
53
92
|
|
|
@@ -60,12 +99,18 @@ async function main() {
|
|
|
60
99
|
await harness.browser.screenshot(path.join(harness.evidence, 'nav002-theme-dark.png'));
|
|
61
100
|
|
|
62
101
|
// NAV-002 expected 2: a ready frame receives kb:theme.
|
|
63
|
-
// The
|
|
64
|
-
//
|
|
102
|
+
// The embedded modules are readied one after another; each frame has to
|
|
103
|
+
// be ready (the shell only talks to a frame that announced itself). The
|
|
104
|
+
// event bridge still opens from the activity navigation; the workbench
|
|
105
|
+
// frame now opens from the system drawer's provider management, which is
|
|
106
|
+
// the only remaining reason the hidden mount exists.
|
|
65
107
|
for (const frame of FRAMES) {
|
|
66
|
-
await harness.run(`document.querySelector('[data-view="${frame.view}"]').click()`);
|
|
67
108
|
if (frame.key === 'eventBridge') {
|
|
109
|
+
await harness.run(`document.querySelector('[data-view="${frame.view}"]').click()`);
|
|
68
110
|
await harness.run("document.querySelector('[data-activity-tab=\"sessions\"]').click()");
|
|
111
|
+
} else {
|
|
112
|
+
await harness.nativeClick('#openSystem');
|
|
113
|
+
await harness.nativeClick('#configureProviders');
|
|
69
114
|
}
|
|
70
115
|
await harness.waitFor(
|
|
71
116
|
async () => {
|
|
@@ -121,7 +166,7 @@ async function main() {
|
|
|
121
166
|
|
|
122
167
|
assert.equal(harness.browser.exceptions.length, 0, `no uncaught product JavaScript exceptions: ${JSON.stringify(harness.browser.exceptions)}`);
|
|
123
168
|
|
|
124
|
-
console.log('parallel-nav-theme-test PASS (theme persisted, ready frames receive kb:theme, no module task rebuilt)');
|
|
169
|
+
console.log('parallel-nav-theme-test PASS (five-page nav contract, #work falls back to home, hidden workFrame mount, theme persisted, ready frames receive kb:theme, no module task rebuilt)');
|
|
125
170
|
} finally {
|
|
126
171
|
await harness.cleanup();
|
|
127
172
|
}
|
|
@@ -1,7 +1,15 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
// NAV-007 — 分辨率矩阵。
|
|
3
3
|
//
|
|
4
|
-
//
|
|
4
|
+
// 迁移说明(五页简化 UI):
|
|
5
|
+
// - 页面矩阵从六页改为五页:home/memory/projects/search/activity
|
|
6
|
+
// (work 导航已移除;#view-work 常驻 hidden,不参与矩阵)。
|
|
7
|
+
// - 「项目已登记」等待改查顶栏 #projectSelect 选项含项目名(首页不再
|
|
8
|
+
// 罗列项目,同一 registry projection)。
|
|
9
|
+
// - 几何证据(容器横向溢出、控件可见矩形、elementFromPoint 命中)、
|
|
10
|
+
// 截图像素统计、明暗主题真实重绘的断言保持不变。
|
|
11
|
+
//
|
|
12
|
+
// The five pages of the shell must render without unintended horizontal
|
|
5
13
|
// overflow and without a control being covered, in four desktop viewports
|
|
6
14
|
// and in both themes.
|
|
7
15
|
//
|
|
@@ -43,12 +51,13 @@ const VIEWPORTS = [
|
|
|
43
51
|
|
|
44
52
|
const THEMES = ['light', 'dark'];
|
|
45
53
|
|
|
54
|
+
// The five-page navigation contract: home, memory, projects, search,
|
|
55
|
+
// activity. The workbench section stays hidden and is not a page.
|
|
46
56
|
const PAGES = [
|
|
47
57
|
{ key: 'home', view: 'home' },
|
|
48
|
-
{ key: 'work', view: 'work' },
|
|
49
|
-
{ key: 'search', view: 'search' },
|
|
50
58
|
{ key: 'memory', view: 'memory' },
|
|
51
59
|
{ key: 'projects', view: 'projects' },
|
|
60
|
+
{ key: 'search', view: 'search' },
|
|
52
61
|
{ key: 'activity', view: 'activity' },
|
|
53
62
|
];
|
|
54
63
|
|
|
@@ -198,7 +207,7 @@ async function main() {
|
|
|
198
207
|
await harness.importProject(repo, 'NAV007 甲');
|
|
199
208
|
await harness.requestRegistryRefresh();
|
|
200
209
|
await harness.waitFor(
|
|
201
|
-
() => harness.run("document.getElementById('
|
|
210
|
+
() => harness.run("[...document.getElementById('projectSelect').options].some(option => option.textContent === 'NAV007 甲')"),
|
|
202
211
|
'the imported project is listed',
|
|
203
212
|
20000,
|
|
204
213
|
);
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
|
+
// 迁移说明(五页 UI):#projectDetail 面板已由项目详情视图取代(#projectsContent 内
|
|
3
|
+
// .project-row 列表 + [data-action=project-detail] 进入详情);解绑按钮随详情页渲染
|
|
4
|
+
// ([data-action=unbind],对话框与安全语义不变)。导航循环不含 work(五页契约)。
|
|
2
5
|
const assert = require('node:assert/strict');
|
|
3
6
|
const fs = require('node:fs');
|
|
4
7
|
const os = require('node:os');
|
|
@@ -38,7 +41,10 @@ async function main() {
|
|
|
38
41
|
for (const view of ['home', 'memory', 'projects', 'activity']) {
|
|
39
42
|
await click(`[data-view="${view}"]`); assert.equal(await run('document.documentElement.scrollWidth > innerWidth'), false, view);
|
|
40
43
|
}
|
|
41
|
-
|
|
44
|
+
await click('[data-view="projects"]');
|
|
45
|
+
await waitFor(() => run("document.querySelectorAll('.project-row').length >= 1"), 'project list row');
|
|
46
|
+
await click('[data-action="project-detail"]');
|
|
47
|
+
await waitFor(() => run("document.getElementById('projectsContent').textContent.includes('视觉检测知识库') && document.getElementById('projectsContent').textContent.includes('使用的组合')"), 'project detail renders');
|
|
42
48
|
assert.ok(await run("document.getElementById('activityUpdates').textContent.includes('离线')"), 'offline cannot masquerade as empty/success');
|
|
43
49
|
await click('#openSystem'); await click('#openLogs');
|
|
44
50
|
await waitFor(() => run("document.querySelectorAll('#logsContent .log-entry').length === 100"), 'bounded diagnostic rendering');
|
|
@@ -67,7 +73,13 @@ async function main() {
|
|
|
67
73
|
assert.equal(entries.length, 1); assert.equal(entries[0].projectId, fixture.projectId);
|
|
68
74
|
await click('[data-close="logsDialog"]'); await click('#themeToggle');
|
|
69
75
|
await browser.send('Page.navigate', { url: base + '/#projects' });
|
|
70
|
-
|
|
76
|
+
// Same-document hash navigation keeps an open detail view; return to the
|
|
77
|
+
// list explicitly, then reopen the detail after the theme flip.
|
|
78
|
+
await waitFor(() => run("document.readyState === 'complete'"), 'document settles');
|
|
79
|
+
await run("(() => { const b = document.querySelector('[data-action=project-list]'); if (b) b.click(); return true; })()");
|
|
80
|
+
await waitFor(() => run("document.querySelectorAll('.project-row').length >= 1"), 'list after navigation', 20000);
|
|
81
|
+
await click('[data-action="project-detail"]');
|
|
82
|
+
await waitFor(() => run("document.getElementById('projectsContent').textContent.includes('视觉检测知识库')"), 'detail after navigation', 15000);
|
|
71
83
|
assert.equal(await run('document.documentElement.dataset.theme'), 'dark');
|
|
72
84
|
const codeFiles = fs.readdirSync(fixture.repo.path);
|
|
73
85
|
// The registry does not own knowledge bytes. Use its actual double-directory binding.
|
|
@@ -80,7 +92,7 @@ async function main() {
|
|
|
80
92
|
assert.equal(browser.exceptions.length, 0, JSON.stringify(browser.exceptions));
|
|
81
93
|
console.log('product-diagnostics-ui-test PASS (1920x1080; XSS/filter/expanded failure/export/theme/offline writer protection)');
|
|
82
94
|
} catch (error) {
|
|
83
|
-
if (browser) console.error(await browser.evaluate("JSON.stringify({ toast:document.getElementById('toast').textContent, project:document.getElementById('projectSelect').value, detail:document.getElementById('
|
|
95
|
+
if (browser) console.error(await browser.evaluate("JSON.stringify({ toast:document.getElementById('toast').textContent, project:document.getElementById('projectSelect').value, detail:document.getElementById('projectsContent').textContent })"));
|
|
84
96
|
throw error;
|
|
85
97
|
} finally {
|
|
86
98
|
try { await browser?.close(); }
|
|
@@ -1,6 +1,20 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
// NAV-003 — 空项目。
|
|
3
3
|
//
|
|
4
|
+
// 迁移说明(五页简化 UI):
|
|
5
|
+
// - 首页空项目态保留:成功读取登记且零项目时显示「从第一个项目开始 /
|
|
6
|
+
// 导入第一个项目」。新首页该态依赖 /api/engine/overview 成功,因此本
|
|
7
|
+
// 测试实例接入真实 vendored 知识引擎(无项目、零数据),失败注入仍只
|
|
8
|
+
// 针对 /api/projects/projection 的首次读取(HTTP 503)。
|
|
9
|
+
// - work 空态已删除:改为断言导航恰好五页不含 work、#view-work 永远
|
|
10
|
+
// hidden、#workFrame 服务挂载仍在、'#work' hash 回落 home。
|
|
11
|
+
// - 检索页空态:#searchEmpty 已删除,检索页空态是 #searchContent 的
|
|
12
|
+
// 「输入关键词…」引导文案。
|
|
13
|
+
// - 记忆页空态:记忆库列表为空时显示「没有匹配的记忆。」(引擎可用、
|
|
14
|
+
// 零记忆)。
|
|
15
|
+
// - 项目页空态:#projectTree/#projectDetail 已删除,改为 #projectsContent
|
|
16
|
+
// 的「没有匹配的项目。」且无 .project-row。
|
|
17
|
+
//
|
|
4
18
|
// A brand new data directory must show real empty states, a failed registry
|
|
5
19
|
// read must not be presented as an empty library, and nothing may create a
|
|
6
20
|
// placeholder project on the way.
|
|
@@ -17,6 +31,7 @@
|
|
|
17
31
|
const fs = require('node:fs');
|
|
18
32
|
const os = require('node:os');
|
|
19
33
|
const path = require('node:path');
|
|
34
|
+
const crypto = require('node:crypto');
|
|
20
35
|
const assert = require('node:assert/strict');
|
|
21
36
|
|
|
22
37
|
// One temp root per run, resolved from the caller's environment: the batch
|
|
@@ -29,10 +44,11 @@ const { spawnServer } = require('./helpers/spawn-server');
|
|
|
29
44
|
const { findChrome } = require('./helpers/find-chrome');
|
|
30
45
|
const { launchCdpBrowser, waitFor } = require('./helpers/cdp-browser');
|
|
31
46
|
const { attachNetworkCapture } = require('./helpers/cdp-network-capture');
|
|
32
|
-
const { createProductProxy } = require('./helpers/module-fixture');
|
|
47
|
+
const { createProductProxy, createUpstreamProxy } = require('./helpers/module-fixture');
|
|
33
48
|
const freePort = require('./helpers/free-port');
|
|
34
49
|
|
|
35
50
|
const ROOT = path.resolve(__dirname, '../..');
|
|
51
|
+
const ENGINE_ENTRY = path.join(path.dirname(require.resolve('@sanqianx/ai-coding-knowledge-engine/package.json', { paths: [ROOT] })), 'src', 'server.js');
|
|
36
52
|
|
|
37
53
|
async function main() {
|
|
38
54
|
const fixture = fs.mkdtempSync(path.join(TEMP_ROOT, 'pk-product-empty-state-'));
|
|
@@ -40,12 +56,34 @@ async function main() {
|
|
|
40
56
|
fs.mkdirSync(evidenceDir, { recursive: true });
|
|
41
57
|
const port = await freePort();
|
|
42
58
|
const base = `http://127.0.0.1:${port}`;
|
|
59
|
+
// The new home page renders its empty-project state only after the engine
|
|
60
|
+
// overview answered, so this instance runs the real vendored engine with
|
|
61
|
+
// its own empty data directory (and dead vector/bridge endpoints, so it
|
|
62
|
+
// can never reach a real desktop hub). The engine sits behind the shared
|
|
63
|
+
// upstream proxy so the product's per-instance runtime token is rewritten
|
|
64
|
+
// into the engine's own token, exactly like the parallel-nav harness.
|
|
65
|
+
const { createEngineServer } = require(ENGINE_ENTRY);
|
|
66
|
+
const engineToken = crypto.randomBytes(24).toString('hex');
|
|
67
|
+
const engine = createEngineServer({
|
|
68
|
+
dataDir: path.join(fixture, 'engine'),
|
|
69
|
+
runtimeToken: engineToken,
|
|
70
|
+
consume: false,
|
|
71
|
+
debug: true,
|
|
72
|
+
vectorUrl: 'http://127.0.0.1:0',
|
|
73
|
+
bridgeUrl: 'http://127.0.0.1:0',
|
|
74
|
+
});
|
|
75
|
+
await engine.ready;
|
|
76
|
+
await new Promise(resolve => engine.server.listen(0, '127.0.0.1', resolve));
|
|
77
|
+
const engineUrl = `http://127.0.0.1:${engine.server.address().port}`;
|
|
78
|
+
const engineProxy = createUpstreamProxy({ target: engineUrl, token: engineToken, tag: 'engine' });
|
|
79
|
+
await engineProxy.start();
|
|
43
80
|
const server = spawnServer({
|
|
44
81
|
root: ROOT,
|
|
45
82
|
port,
|
|
46
83
|
dataDir: path.join(fixture, 'data'),
|
|
47
84
|
tag: 'product-empty-state',
|
|
48
85
|
analysisOwner: 'engine',
|
|
86
|
+
extraEnv: { KB_KNOWLEDGE_ENGINE_URL: engineProxy.url },
|
|
49
87
|
});
|
|
50
88
|
const proxy = createProductProxy({ target: base, tag: 'product-empty-state' });
|
|
51
89
|
let browser;
|
|
@@ -90,36 +128,62 @@ async function main() {
|
|
|
90
128
|
// The retry reads the registry for real; now the empty state is a fact.
|
|
91
129
|
await run("document.querySelector('#homeContent [data-action=\"refresh\"]').click()");
|
|
92
130
|
await waitFor(() => run("document.getElementById('homeContent').textContent.includes('从第一个项目开始')"), 'the real empty home', 20000);
|
|
131
|
+
assert.equal(await run("document.getElementById('homeContent').textContent.includes('导入第一个项目')"), true, 'the empty home keeps its real import entry point');
|
|
93
132
|
assert.equal(await run("document.getElementById('homeContent').textContent.includes('项目登记读取失败')"), false, 'the recovered read clears the failure');
|
|
94
133
|
await browser.screenshot(path.join(evidenceDir, 'empty-state-home.png'));
|
|
95
134
|
|
|
96
|
-
// NAV-003 expected 1
|
|
97
|
-
//
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
135
|
+
// NAV-003 expected 1 (work): the workbench page is gone from the
|
|
136
|
+
// navigation, keeps no empty state of its own, and survives only as the
|
|
137
|
+
// hidden service mount.
|
|
138
|
+
assert.deepEqual(
|
|
139
|
+
await run("[...document.querySelectorAll('nav [data-view]')].map(button => button.dataset.view)"),
|
|
140
|
+
['home', 'memory', 'projects', 'search', 'activity'],
|
|
141
|
+
'the navigation offers exactly the five pages',
|
|
142
|
+
);
|
|
143
|
+
assert.equal(await run("document.querySelector('[data-view=\"work\"]') === null"), true, 'the work navigation button is removed');
|
|
144
|
+
assert.equal(await run("document.getElementById('view-work') !== null"), true, 'the work section survives in the DOM');
|
|
145
|
+
assert.equal(await run("document.getElementById('view-work').hidden"), true, 'the work section stays hidden');
|
|
146
|
+
assert.equal(await run("document.getElementById('workFrame') !== null"), true, 'the workbench service mount (workFrame) survives');
|
|
147
|
+
assert.equal(await run("document.getElementById('workEmpty') === null"), true, 'the retired work empty state is really gone');
|
|
148
|
+
await run("location.hash = '#work'");
|
|
149
|
+
await waitFor(
|
|
150
|
+
async () => (await run("document.getElementById('view-home').classList.contains('active')"))
|
|
151
|
+
&& (await run("location.hash")) === '#home',
|
|
152
|
+
'the #work hash falls back to home',
|
|
153
|
+
10000,
|
|
154
|
+
);
|
|
155
|
+
assert.equal(await run("document.getElementById('view-work').hidden"), true, 'the fallback never reveals the work section');
|
|
156
|
+
await browser.screenshot(path.join(evidenceDir, 'empty-state-nav-contract.png'));
|
|
104
157
|
|
|
158
|
+
// NAV-003 expected 1 (search): the search page shows its real empty
|
|
159
|
+
// guidance instead of an embedded module.
|
|
105
160
|
await run("document.querySelector('[data-view=\"search\"]').click()");
|
|
106
161
|
await waitFor(() => run("document.getElementById('view-search').classList.contains('active')"), 'the search view');
|
|
107
|
-
assert.equal(await run("document.getElementById('
|
|
108
|
-
assert.equal(await run("document.getElementById('
|
|
162
|
+
assert.equal(await run("document.getElementById('searchContent').textContent.includes('输入关键词')"), true, 'the search view shows its empty guidance');
|
|
163
|
+
assert.equal(await run("document.getElementById('searchForm') !== null"), true, 'the search view offers the real search form');
|
|
164
|
+
assert.equal(await run("document.getElementById('searchEmpty') === null"), true, 'the retired search empty element is really gone');
|
|
109
165
|
await browser.screenshot(path.join(evidenceDir, 'empty-state-search.png'));
|
|
110
166
|
|
|
167
|
+
// NAV-003 expected 1 (memory): an empty memory library is a fact of the
|
|
168
|
+
// engine, not a placeholder list.
|
|
169
|
+
await run("document.querySelector('[data-view=\"memory\"]').click()");
|
|
170
|
+
await waitFor(() => run("document.getElementById('view-memory').classList.contains('active')"), 'the memory view');
|
|
171
|
+
await waitFor(() => run("document.getElementById('memoryContent').textContent.includes('没有匹配的记忆')"), 'the real empty memory library', 20000);
|
|
172
|
+
assert.equal(await run("document.querySelectorAll('#memoryContent .memory-item').length"), 0, 'the memory library lists no memory');
|
|
173
|
+
await browser.screenshot(path.join(evidenceDir, 'empty-state-memory.png'));
|
|
174
|
+
|
|
175
|
+
// NAV-003 expected 1 (projects): the project page shows its real empty
|
|
176
|
+
// state.
|
|
111
177
|
await run("document.querySelector('[data-view=\"projects\"]').click()");
|
|
112
178
|
await waitFor(() => run("document.getElementById('view-projects').classList.contains('active')"), 'the projects view');
|
|
113
|
-
|
|
114
|
-
assert.equal(await run("document.
|
|
115
|
-
assert.equal(await run("document.getElementById('projectDetail').textContent.includes('尚未导入项目')"), true, 'the project detail shows the empty state');
|
|
179
|
+
await waitFor(() => run("document.getElementById('projectsContent').textContent.includes('没有匹配的项目')"), 'the real empty project list', 20000);
|
|
180
|
+
assert.equal(await run("document.querySelectorAll('#projectsContent .project-row').length"), 0, 'the project page lists no project');
|
|
116
181
|
await browser.screenshot(path.join(evidenceDir, 'empty-state-projects.png'));
|
|
117
182
|
|
|
118
183
|
const brain = await (await fetch(base + '/api/brain')).json();
|
|
119
184
|
assert.equal((brain.brain.domains || []).length, 0, 'a fresh instance owns no domain');
|
|
120
185
|
|
|
121
186
|
// NAV-003 expected 3: nothing created a placeholder project.
|
|
122
|
-
assert.equal(await run("document.querySelectorAll('#projectTree [data-select-project]').length"), 0, 'the project tree offers no project');
|
|
123
187
|
assert.equal(await run("document.getElementById('projectSelect').disabled"), true, 'the project selector stays disabled');
|
|
124
188
|
assert.equal(await run("document.getElementById('projectSelect').value"), '', 'no project is selected');
|
|
125
189
|
assert.equal(await run("localStorage.getItem('kb.project')"), null, 'no project id is remembered');
|
|
@@ -141,6 +205,8 @@ async function main() {
|
|
|
141
205
|
await browser?.close();
|
|
142
206
|
await proxy.close();
|
|
143
207
|
await server.cleanup();
|
|
208
|
+
await engineProxy.close();
|
|
209
|
+
await engine.close().catch(() => {});
|
|
144
210
|
fs.rmSync(fixture, { recursive: true, force: true, maxRetries: 3, retryDelay: 100 });
|
|
145
211
|
}
|
|
146
212
|
}
|
|
@@ -1,4 +1,20 @@
|
|
|
1
1
|
'use strict';
|
|
2
|
+
// 迁移说明(五页简化 UI):
|
|
3
|
+
// - #importDialog 导入流程、预检(preflight/HOOK_CONFLICT/重复导入)、知识
|
|
4
|
+
// 根目录往返(#setupImportRoot → #saveBrainSettings)与领域创建
|
|
5
|
+
// (#createDomain → #domainForm)全部保持原断言。
|
|
6
|
+
// - work 不再是导航页:桌面视图遍历改为五页(memory/search/projects/
|
|
7
|
+
// activity/home)。
|
|
8
|
+
// - 首页不再罗列项目:启动等待改为「首页读取状态落定」(本实例引擎离线,
|
|
9
|
+
// 落定文案是全局状态读取失败——同样是真实的非空库状态)。
|
|
10
|
+
// - 领域落库可见性:#projectTree 已删除,改为项目页领域筛选
|
|
11
|
+
// #projectDomainFilter 的选项包含新领域。
|
|
12
|
+
// - 导入成功跳转项目页:#projectDetail 已删除,改为 #projectsContent 的
|
|
13
|
+
// .project-row 列表(项目名按钮 [data-action="project-detail"])。
|
|
14
|
+
// - PRJ-012 失败读取不被当作刷新结果:旧 #projectTree 从登记快照渲染,
|
|
15
|
+
// 新 UI 中登记快照驱动顶栏 #projectSelect——断言失败读取期间选择器
|
|
16
|
+
// 保持旧状态、恢复读取后出现第二个项目;项目页 .project-row 走独立的
|
|
17
|
+
// /api/projects/page 分页端点,不受该故障影响。
|
|
2
18
|
const assert = require('node:assert/strict');
|
|
3
19
|
const fs = require('node:fs');
|
|
4
20
|
const os = require('node:os');
|
|
@@ -51,8 +67,11 @@ async function main() {
|
|
|
51
67
|
const run = expression => browser.evaluate(expression);
|
|
52
68
|
const click = selector => run(`document.querySelector(${JSON.stringify(selector)}).click()`);
|
|
53
69
|
const fill = (selector, value) => run(`(() => { const field=document.querySelector(${JSON.stringify(selector)}); field.value=${JSON.stringify(value)}; field.dispatchEvent(new Event('input',{bubbles:true})); })()`);
|
|
54
|
-
|
|
55
|
-
|
|
70
|
+
// The shell's boot reads settle: this instance's engine module answers
|
|
71
|
+
// 503, so the settled home state is the reported overview failure (a real
|
|
72
|
+
// non-empty-library state), never a fabricated empty library.
|
|
73
|
+
await waitFor(() => run("(() => { const text = document.getElementById('homeContent').textContent; return text.trim().length > 0 && !text.includes('正在读取'); })()"), 'real settled home state');
|
|
74
|
+
for (const view of ['memory', 'search', 'projects', 'activity', 'home']) {
|
|
56
75
|
await click(`[data-view="${view}"]`);
|
|
57
76
|
assert.equal(await run(`document.getElementById('view-${view}').classList.contains('active')`), true);
|
|
58
77
|
assert.equal(await run('document.documentElement.scrollWidth > innerWidth'), false, `desktop overflow in ${view}`);
|
|
@@ -69,7 +88,7 @@ async function main() {
|
|
|
69
88
|
assert.equal(capture.find(entry => entry.method === 'POST' && entry.url.endsWith('/api/domains')).length, 0, 'an empty domain name must not reach the product');
|
|
70
89
|
assert.equal(((await api('/api/settings')).settings.brain.domains || []).length, 0, 'an empty domain name must not persist a domain');
|
|
71
90
|
await fill('#domainForm input[name="name"]', '回归领域'); await click('#domainForm button[type="submit"]');
|
|
72
|
-
await waitFor(() => run("!document.getElementById('domainDialog').open && document.getElementById('
|
|
91
|
+
await waitFor(() => run("!document.getElementById('domainDialog').open && [...document.getElementById('projectDomainFilter').options].some(option => option.textContent === '回归领域')"), 'domain persisted from UI');
|
|
73
92
|
const domainsOnDisk = JSON.parse(fs.readFileSync(path.join(dataDir, 'settings.json'), 'utf8')).brain.domains || [];
|
|
74
93
|
assert.ok(domainsOnDisk.some(domain => domain.name === '回归领域'), 'the domain is persisted on disk');
|
|
75
94
|
assert.equal(capture.find(entry => entry.method === 'POST' && entry.url.endsWith('/api/domains')).length, 1, 'only the named domain reached the product');
|
|
@@ -106,7 +125,11 @@ async function main() {
|
|
|
106
125
|
assert.ok(await run(`document.getElementById('preflightStatus').textContent.includes(${JSON.stringify(failureLogs[0].operationId)})`), 'UI operation ID resolves to the persisted failure');
|
|
107
126
|
fs.unlinkSync(racedHook);
|
|
108
127
|
await click('#confirmImport');
|
|
109
|
-
await waitFor(() => run("!document.getElementById('importDialog').open && document.getElementById('
|
|
128
|
+
await waitFor(() => run("!document.getElementById('importDialog').open && document.getElementById('view-projects').classList.contains('active') && document.getElementById('projectsContent').textContent.includes('回归项目')"), 'import feedback', 30000);
|
|
129
|
+
// The import now lands on the projects page: the new list renders one
|
|
130
|
+
// .project-row per registered project, with the name as its detail button.
|
|
131
|
+
assert.equal(await run("document.querySelectorAll('#projectsContent .project-row').length"), 1, 'the imported project is listed as one project row');
|
|
132
|
+
assert.equal(await run("document.querySelectorAll('#projectsContent .project-row [data-action=\"project-detail\"]').length"), 1, 'the project row carries the project detail button');
|
|
110
133
|
const selected = await run("document.getElementById('projectSelect').value");
|
|
111
134
|
const project = (await api('/api/projects/aggregated')).projects.find(p => p.projectId === selected);
|
|
112
135
|
assert.ok(project && Object.values(project.modules).every(module => !module.registered));
|
|
@@ -190,9 +213,11 @@ async function main() {
|
|
|
190
213
|
const registered = (await api('/api/projects/aggregated')).projects;
|
|
191
214
|
assert.equal(registered.length, 2, 'the successful import registers exactly one more project');
|
|
192
215
|
assert.ok(registered.some(project => project.name === '第二个项目'), 'the second project is registered');
|
|
193
|
-
// The page does not present the failed read as fresh state
|
|
194
|
-
|
|
195
|
-
|
|
216
|
+
// The page does not present the failed read as fresh state: the registry
|
|
217
|
+
// snapshot drives the top-bar selector, which stays on the previous
|
|
218
|
+
// state until a later read really succeeds.
|
|
219
|
+
assert.equal(await run("[...document.getElementById('projectSelect').options].filter(option => option.value).length"), 1, 'the failed read leaves the registry selector on the previous state');
|
|
220
|
+
assert.equal(await run("document.getElementById('projectSelect').textContent.includes('第二个项目')"), false, 'the failed read is not shown as a refreshed registry');
|
|
196
221
|
// A later read succeeds: the same import is not registered a second time.
|
|
197
222
|
fetchFaults.armed = false;
|
|
198
223
|
const laterRead = () => capture.find(entry => entry.method === 'GET' && entry.url.includes('/api/projects/projection') && entry.status === 200 && requests.indexOf(entry) > importIndex).length > 0;
|
|
@@ -202,8 +227,9 @@ async function main() {
|
|
|
202
227
|
await new Promise(resolve => setTimeout(resolve, 300));
|
|
203
228
|
}
|
|
204
229
|
assert.ok(laterRead(), 'the later registry read succeeds');
|
|
205
|
-
await waitFor(() => run("document.getElementById('
|
|
206
|
-
assert.equal(await run("document.
|
|
230
|
+
await waitFor(() => run("document.getElementById('projectSelect').textContent.includes('第二个项目')"), 'the refreshed registry selector', 20000);
|
|
231
|
+
assert.equal(await run("[...document.getElementById('projectSelect').options].filter(option => option.value).length"), 2, 'the retry reads the same two projects and creates no third');
|
|
232
|
+
await waitFor(() => run("document.querySelectorAll('#projectsContent .project-row').length === 2"), 'the refreshed project rows', 20000);
|
|
207
233
|
assert.equal((await api('/api/projects/aggregated')).projects.length, 2, 'the product registry still holds exactly two projects');
|
|
208
234
|
assert.ok(fs.existsSync(knowledge2), 'the second project keeps its knowledge directory');
|
|
209
235
|
await browser.send('Fetch.disable');
|
|
@@ -1,10 +1,27 @@
|
|
|
1
1
|
'use strict';
|
|
2
|
-
// NAV-001 —
|
|
2
|
+
// NAV-001 — 五页导航。
|
|
3
3
|
//
|
|
4
|
-
// The shell owns the
|
|
4
|
+
// The shell owns the five-page navigation: exactly one active navigation
|
|
5
5
|
// entry, exactly one visible page, and a title/hash pair that matches the
|
|
6
6
|
// active view — both after a click and after the same page is restored from
|
|
7
|
-
// its hash.
|
|
7
|
+
// its hash. The retired `work` page must fall back to home from its hash
|
|
8
|
+
// while its hidden service mount stays in the DOM. Moving around must not
|
|
9
|
+
// write anything into the product.
|
|
10
|
+
//
|
|
11
|
+
// 迁移说明(五页简化 UI,见 patches/ui-test-mapping-spec.md):
|
|
12
|
+
// - 导航从六页改为五页:home/memory/projects/search/activity;`work` 导航
|
|
13
|
+
// 按钮已删除,`nav [data-view]` 数量 6 → 5。
|
|
14
|
+
// - `#view-work` section 仍在 DOM(Workbench 隐藏服务挂载点,`#workFrame`
|
|
15
|
+
// 保留),`.view` 总数仍为 6,但 work 永远 hidden、永无 active。
|
|
16
|
+
// - 页面标题映射:home「智脑首页」→「首页」、projects「领域与项目」→「项目」;
|
|
17
|
+
// 其余不变(memory 长期记忆 / search 知识检索 / activity 活动记录)。
|
|
18
|
+
// - `#work` 回落:hash `#work` 经 setView 未知视图回落 home 并改写为
|
|
19
|
+
// `#home`;载入时(boot)同样回落。原 work 页的点击/重载断言由
|
|
20
|
+
// 「#work hash 回落 + work 挂载点保持 hidden」取代。
|
|
21
|
+
// - 新首页空项目态依赖 /api/engine/overview 成功,因此测试实例接入真实
|
|
22
|
+
// vendored 知识引擎(独立空数据目录、vector/bridge 指向死端口),经
|
|
23
|
+
// createUpstreamProxy 改写 per-instance runtime token(与已迁移的
|
|
24
|
+
// product-empty-state-test 相同模式)。
|
|
8
25
|
//
|
|
9
26
|
// The regression drives the real product UI in a real browser against an
|
|
10
27
|
// isolated instance (own port, own data dir, own knowledge dir, own Bridge
|
|
@@ -15,6 +32,7 @@
|
|
|
15
32
|
const fs = require('node:fs');
|
|
16
33
|
const os = require('node:os');
|
|
17
34
|
const path = require('node:path');
|
|
35
|
+
const crypto = require('node:crypto');
|
|
18
36
|
const assert = require('node:assert/strict');
|
|
19
37
|
|
|
20
38
|
// One temp root per run, resolved from the caller's environment: the batch
|
|
@@ -27,17 +45,18 @@ const { spawnServer } = require('./helpers/spawn-server');
|
|
|
27
45
|
const { findChrome } = require('./helpers/find-chrome');
|
|
28
46
|
const { launchCdpBrowser, waitFor } = require('./helpers/cdp-browser');
|
|
29
47
|
const { attachNetworkCapture } = require('./helpers/cdp-network-capture');
|
|
48
|
+
const { createUpstreamProxy } = require('./helpers/module-fixture');
|
|
30
49
|
const freePort = require('./helpers/free-port');
|
|
31
50
|
|
|
32
51
|
const ROOT = path.resolve(__dirname, '../..');
|
|
52
|
+
const ENGINE_ENTRY = path.join(path.dirname(require.resolve('@sanqianx/ai-coding-knowledge-engine/package.json', { paths: [ROOT] })), 'src', 'server.js');
|
|
33
53
|
|
|
34
|
-
const VIEWS = ['home', '
|
|
54
|
+
const VIEWS = ['home', 'memory', 'projects', 'search', 'activity'];
|
|
35
55
|
const TITLES = {
|
|
36
|
-
home: '
|
|
37
|
-
work: '开始工作',
|
|
38
|
-
search: '知识检索',
|
|
56
|
+
home: '首页',
|
|
39
57
|
memory: '长期记忆',
|
|
40
|
-
projects: '
|
|
58
|
+
projects: '项目',
|
|
59
|
+
search: '知识检索',
|
|
41
60
|
activity: '活动记录',
|
|
42
61
|
};
|
|
43
62
|
|
|
@@ -47,12 +66,34 @@ async function main() {
|
|
|
47
66
|
fs.mkdirSync(evidenceDir, { recursive: true });
|
|
48
67
|
const port = await freePort();
|
|
49
68
|
const base = `http://127.0.0.1:${port}`;
|
|
69
|
+
// The five-page home renders its empty-project state only after the engine
|
|
70
|
+
// overview answered, so this instance runs the real vendored engine with
|
|
71
|
+
// its own empty data directory (and dead vector/bridge endpoints, so it
|
|
72
|
+
// can never reach a real desktop hub). The engine sits behind the shared
|
|
73
|
+
// upstream proxy so the product's per-instance runtime token is rewritten
|
|
74
|
+
// into the engine's own token.
|
|
75
|
+
const { createEngineServer } = require(ENGINE_ENTRY);
|
|
76
|
+
const engineToken = crypto.randomBytes(24).toString('hex');
|
|
77
|
+
const engine = createEngineServer({
|
|
78
|
+
dataDir: path.join(fixture, 'engine'),
|
|
79
|
+
runtimeToken: engineToken,
|
|
80
|
+
consume: false,
|
|
81
|
+
debug: true,
|
|
82
|
+
vectorUrl: 'http://127.0.0.1:0',
|
|
83
|
+
bridgeUrl: 'http://127.0.0.1:0',
|
|
84
|
+
});
|
|
85
|
+
await engine.ready;
|
|
86
|
+
await new Promise(resolve => engine.server.listen(0, '127.0.0.1', resolve));
|
|
87
|
+
const engineUrl = `http://127.0.0.1:${engine.server.address().port}`;
|
|
88
|
+
const engineProxy = createUpstreamProxy({ target: engineUrl, token: engineToken, tag: 'engine' });
|
|
89
|
+
await engineProxy.start();
|
|
50
90
|
const server = spawnServer({
|
|
51
91
|
root: ROOT,
|
|
52
92
|
port,
|
|
53
93
|
dataDir: path.join(fixture, 'data'),
|
|
54
94
|
tag: 'product-navigation',
|
|
55
95
|
analysisOwner: 'engine',
|
|
96
|
+
extraEnv: { KB_KNOWLEDGE_ENGINE_URL: engineProxy.url },
|
|
56
97
|
});
|
|
57
98
|
let browser;
|
|
58
99
|
try {
|
|
@@ -73,8 +114,9 @@ async function main() {
|
|
|
73
114
|
const run = expression => browser.evaluate(expression);
|
|
74
115
|
|
|
75
116
|
await waitFor(() => run("document.getElementById('homeContent').textContent.includes('第一个项目')"), 'the real empty home', 20000);
|
|
76
|
-
assert.equal(await run("document.querySelectorAll('nav [data-view]').length"),
|
|
77
|
-
assert.equal(await run("document.
|
|
117
|
+
assert.equal(await run("document.querySelectorAll('nav [data-view]').length"), 5, 'the shell exposes five navigation entries');
|
|
118
|
+
assert.equal(await run("document.querySelector('[data-view=\"work\"]')"), null, 'the retired work page no longer has a navigation entry');
|
|
119
|
+
assert.equal(await run("document.querySelectorAll('.view').length"), 6, 'five pages plus the hidden work service mount');
|
|
78
120
|
|
|
79
121
|
const readShell = () => run(`(() => ({
|
|
80
122
|
marker: window.__navMarker === undefined ? null : String(window.__navMarker),
|
|
@@ -85,15 +127,20 @@ async function main() {
|
|
|
85
127
|
href: location.href,
|
|
86
128
|
navCount: document.querySelectorAll('[data-view]').length,
|
|
87
129
|
documentTitle: document.title,
|
|
88
|
-
|
|
130
|
+
workHidden: document.getElementById('view-work').hidden,
|
|
131
|
+
workActive: document.getElementById('view-work').classList.contains('active'),
|
|
132
|
+
workFrameKept: Boolean(document.getElementById('workFrame')),
|
|
89
133
|
}))()`);
|
|
90
134
|
|
|
91
135
|
const assertShell = (shell, view, phase) => {
|
|
92
|
-
const where = `${phase} (href=${shell.href}, nav=${shell.navCount}, title=${shell.documentTitle},
|
|
136
|
+
const where = `${phase} (href=${shell.href}, nav=${shell.navCount}, title=${shell.documentTitle}, exceptions=${JSON.stringify(browser.exceptions)})`;
|
|
93
137
|
assert.deepEqual(shell.activeNav, [view], `${where}: only ${view} is the active navigation entry`);
|
|
94
138
|
assert.deepEqual(shell.activeView, [`view-${view}`], `${where}: only view-${view} is the visible page`);
|
|
95
139
|
assert.equal(shell.title, TITLES[view], `${where}: the page title matches ${view}`);
|
|
96
140
|
assert.equal(shell.hash, `#${view}`, `${where}: the hash matches ${view}`);
|
|
141
|
+
assert.equal(shell.workHidden, true, `${where}: the hidden work service mount never becomes a page`);
|
|
142
|
+
assert.equal(shell.workActive, false, `${where}: view-work is never the active page`);
|
|
143
|
+
assert.equal(shell.workFrameKept, true, `${where}: the workbench service mount iframe survives without a work page`);
|
|
97
144
|
};
|
|
98
145
|
|
|
99
146
|
// NAV-001 expected 1 + 2: one active entry, and title/hash/selection in
|
|
@@ -106,6 +153,10 @@ async function main() {
|
|
|
106
153
|
}
|
|
107
154
|
|
|
108
155
|
// The same four properties after the hash alone restores the page.
|
|
156
|
+
const bootedInto = view => shell => shell && shell.marker === null
|
|
157
|
+
&& shell.activeNav.length === 1 && shell.activeNav[0] === view
|
|
158
|
+
&& shell.activeView.length === 1 && shell.activeView[0] === `view-${view}`
|
|
159
|
+
&& shell.title === TITLES[view] && shell.hash === `#${view}`;
|
|
109
160
|
for (const view of VIEWS) {
|
|
110
161
|
await run(`location.hash = '#${view}'`);
|
|
111
162
|
await waitFor(() => run(`location.hash === '#${view}'`), `the ${view} hash`);
|
|
@@ -116,15 +167,23 @@ async function main() {
|
|
|
116
167
|
// shell properties prove the product booted into that view - a complete
|
|
117
168
|
// readyState alone cannot show that. One atomic evaluation per attempt;
|
|
118
169
|
// two round-trips can straddle the document swap.
|
|
119
|
-
const bootedInto = view => shell => shell && shell.marker === null
|
|
120
|
-
&& shell.activeNav.length === 1 && shell.activeNav[0] === view
|
|
121
|
-
&& shell.activeView.length === 1 && shell.activeView[0] === `view-${view}`
|
|
122
|
-
&& shell.title === TITLES[view] && shell.hash === `#${view}`;
|
|
123
170
|
await waitFor(async () => bootedInto(view)(await readShell()), `the reloaded ${view} page reaches its booted state`, 20000);
|
|
124
171
|
assertShell(await readShell(), view, `reload ${view}`);
|
|
125
172
|
await browser.screenshot(path.join(evidenceDir, `nav-reload-${view}.png`));
|
|
126
173
|
}
|
|
127
174
|
|
|
175
|
+
// The retired work page must fall back to home, both from a live hash
|
|
176
|
+
// change and when the document boots with the stale #work hash, while its
|
|
177
|
+
// service mount stays hidden in the DOM.
|
|
178
|
+
await run("location.hash = '#work'");
|
|
179
|
+
await waitFor(() => run("location.hash === '#home' && document.querySelector('[data-view].active')?.dataset.view === 'home'"), 'the #work hash to fall back to home');
|
|
180
|
+
assertShell(await readShell(), 'home', 'work hash falls back');
|
|
181
|
+
await run("history.replaceState(null, '', '#work'); window.__navMarker = 'nav-work-boot'");
|
|
182
|
+
await browser.send('Page.reload');
|
|
183
|
+
await waitFor(async () => bootedInto('home')(await readShell()), 'a reloaded #work page to boot into home', 20000);
|
|
184
|
+
assertShell(await readShell(), 'home', 'work hash reload falls back');
|
|
185
|
+
await browser.screenshot(path.join(evidenceDir, 'nav-work-fallback.png'));
|
|
186
|
+
|
|
128
187
|
// NAV-001 expected 3: moving around writes nothing.
|
|
129
188
|
const writes = capture.find(entry => entry.url.includes('/api/') && !['GET', 'HEAD', 'OPTIONS'].includes(entry.method));
|
|
130
189
|
assert.deepEqual(writes.map(entry => `${entry.method} ${entry.url}`), [], 'navigation performs no business write');
|
|
@@ -141,10 +200,12 @@ async function main() {
|
|
|
141
200
|
if (fs.existsSync(projectDirs)) assert.deepEqual(fs.readdirSync(projectDirs), [], 'no project metadata directory is created');
|
|
142
201
|
assert.equal(browser.exceptions.length, 0, `no uncaught product JavaScript exceptions: ${JSON.stringify(browser.exceptions)}`);
|
|
143
202
|
|
|
144
|
-
console.log(`product-navigation-test PASS (${VIEWS.length} pages, click + hash reload, one active entry, no business write)`);
|
|
203
|
+
console.log(`product-navigation-test PASS (${VIEWS.length} pages, click + hash reload, #work falls back to home, one active entry, no business write)`);
|
|
145
204
|
} finally {
|
|
146
205
|
await browser?.close();
|
|
147
206
|
await server.cleanup();
|
|
207
|
+
await engineProxy.close();
|
|
208
|
+
await engine.close().catch(() => {});
|
|
148
209
|
fs.rmSync(fixture, { recursive: true, force: true, maxRetries: 3, retryDelay: 100 });
|
|
149
210
|
}
|
|
150
211
|
}
|