Files
Agent-System/web/src/lib/currentProjectRestore.test.ts
T
weichenandCursor 3c26fcb2f8 fix(e2e): assert restored project in the banner and isolate phase artifacts
Page-wide project-name text hits both the top bar and the session rail after restart. Click the complementary exact title, then assert the banner exact name. Split Playwright output and HTML reports by UI_PHASE so post-restart cannot wipe main traces.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-13 23:21:09 +00:00

69 lines
2.2 KiB
TypeScript

import { describe, it } from 'node:test';
import assert from 'node:assert/strict';
import {
currentProjectBannerName,
evaluatePageWideProjectNameHits,
requireProjectName,
visibleProjectEntry,
} from './currentProjectRestore';
describe('currentProjectRestore', () => {
it('rejects empty project names', () => {
assert.throws(() => requireProjectName(' '), /empty_project_name/);
});
it('rejects page-wide project name when banner and sidebar both match', () => {
const verdict = evaluatePageWideProjectNameHits(2);
assert.equal(verdict.ok, false);
assert.match(verdict.reason, /page_wide_project_name_not_unique:2/);
});
it('scopes the visible entry to complementary exact title', () => {
const calls: unknown[] = [];
const page = {
getByRole(role: 'banner' | 'complementary') {
calls.push(['role', role]);
return {
getByText() {
throw new Error('entry must use title, not page text');
},
getByTitle(name: string, options?: { exact?: boolean }) {
calls.push(['title', name, options]);
return 'entry';
},
};
},
};
const loc = visibleProjectEntry(page, ' UI验收-超声微创系统-mu0eq020 ');
assert.equal(loc, 'entry');
assert.deepEqual(calls, [
['role', 'complementary'],
['title', 'UI验收-超声微创系统-mu0eq020', { exact: true }],
]);
});
it('scopes the current project assertion to banner exact text', () => {
const calls: unknown[] = [];
const page = {
getByRole(role: 'banner' | 'complementary') {
calls.push(['role', role]);
return {
getByText(name: string, options?: { exact?: boolean }) {
calls.push(['text', name, options]);
return 'banner';
},
getByTitle() {
throw new Error('banner must use exact text, not title');
},
};
},
};
const loc = currentProjectBannerName(page, 'UI验收-超声微创系统-mu0eq020');
assert.equal(loc, 'banner');
assert.deepEqual(calls, [
['role', 'banner'],
['text', 'UI验收-超声微创系统-mu0eq020', { exact: true }],
]);
});
});