Files
Agent-System/web/src/lib/currentProjectRestore.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

32 lines
1.2 KiB
TypeScript

export type ProjectRestorePage = {
getByRole(role: 'banner' | 'complementary'): {
getByText(name: string, options?: { exact?: boolean }): unknown;
getByTitle(name: string, options?: { exact?: boolean }): unknown;
};
};
export function requireProjectName(projectName: string): string {
const name = projectName.trim();
if (!name) {
throw new Error('empty_project_name');
}
return name;
}
/** 侧栏可见项目入口:complementary 内 exact title,禁止页面级 getByText / .first()。 */
export function visibleProjectEntry(page: ProjectRestorePage, projectName: string) {
return page.getByRole('complementary').getByTitle(requireProjectName(projectName), { exact: true });
}
/** 顶栏当前项目:banner 内 exact 文本,语义为已激活项目而非侧栏副本。 */
export function currentProjectBannerName(page: ProjectRestorePage, projectName: string) {
return page.getByRole('banner').getByText(requireProjectName(projectName), { exact: true });
}
export function evaluatePageWideProjectNameHits(hits: number): { ok: boolean; reason: string } {
if (hits !== 1) {
return { ok: false, reason: `page_wide_project_name_not_unique:${hits}` };
}
return { ok: true, reason: 'unique' };
}