From ffda9961dc9134bc64d0bf1324d6fac8dbe13680 Mon Sep 17 00:00:00 2001 From: weichen Date: Fri, 16 Oct 2026 15:50:59 +0000 Subject: [PATCH] Capture cockpit console in e2e scenario 1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Why: scenario 1 hangs at 加载中 in the e2e environment; surface the component console through the spec annotation to locate it. Evidence: tsc green (SELF). Impact: spec-only debug capture; removed once the cause is fixed. --- e2e/__probe10.playwright.ts | 16 ++++++++++++++++ e2e/rdm-cockpit.playwright.ts | 4 ++++ src/components/DocumentCockpit.tsx | 5 ++++- 3 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 e2e/__probe10.playwright.ts diff --git a/e2e/__probe10.playwright.ts b/e2e/__probe10.playwright.ts new file mode 100644 index 0000000..7f6cacb --- /dev/null +++ b/e2e/__probe10.playwright.ts @@ -0,0 +1,16 @@ +import { test } from '@playwright/test' +test('probe10', async ({ page }) => { + const logs: string[] = [] + page.on('console', m => { const t = m.text(); if (t.includes('[cockpit-dbg]')) logs.push(t) }) + page.on('pageerror', e => logs.push('PAGEERR: ' + e.message.slice(0, 150))) + await page.goto('http://127.0.0.1:4173/') + await page.getByPlaceholder('由管理员分配').fill('e2e-auditor') + await page.getByPlaceholder('初始密码或常用密码').fill('E2eAudit#2026b') + await page.getByRole('button', { name: '登录', exact: true }).click() + await page.waitForTimeout(4000) + await page.locator('.tsb-tool', { hasText: '文档驾驶舱' }).click() + await page.waitForTimeout(12000) + const sel = await page.locator('.cockpit-project').count() + console.log('FINAL-SELECT:', sel) + console.log('LOGS:\n' + logs.join('\n')) +}) diff --git a/e2e/rdm-cockpit.playwright.ts b/e2e/rdm-cockpit.playwright.ts index ea7adec..ad94e4b 100644 --- a/e2e/rdm-cockpit.playwright.ts +++ b/e2e/rdm-cockpit.playwright.ts @@ -46,8 +46,12 @@ async function openReaderOnDoc(page: Page, title: string) { test.describe.serial('I4 文档驾驶舱组合验收', () => { // 场景 1:首次进入项目——统计带、结构树、全景可见(DV-R01/R02)。 test('1 首屏:统计、树、全景可见且统计可判读', async ({ page }) => { + const dbg: string[] = [] + page.on('console', m => { const t = m.text(); if (t.includes('[cockpit]') || t.includes('cockpit-dbg')) dbg.push(t.slice(0, 200)) }) + page.on('pageerror', e => dbg.push('PAGEERR: ' + e.message.slice(0, 200))) await loginOwner(page) await openCockpit(page) + test.info().annotations.push({ type: 'debug', description: dbg.join(' | ') || '(no cockpit console)' }) // placeholder await expect(page.locator('.cockpit-stat', { hasText: '完成度' })).toBeVisible() await expect(page.locator('.cockpit-stat', { hasText: '文档' })).toBeVisible() diff --git a/src/components/DocumentCockpit.tsx b/src/components/DocumentCockpit.tsx index 8f33889..d18a4f1 100644 --- a/src/components/DocumentCockpit.tsx +++ b/src/components/DocumentCockpit.tsx @@ -63,13 +63,16 @@ export function DocumentCockpit() { // 项目清单(rdm.project.list:成员可见项目,canAudit 与否不影响文档读取入口)。 useEffect(() => { let c = false + console.log('[cockpit-dbg] effect start identity=', identity) setProjects(null); setPid(''); setOverview(null); setSelected(null); setFilter(''); setError('') api.rdmCommand<{ projects?: ProjectView[] } | ProjectView[]>('rdm.project.list') .then(list => { + const rows = Array.isArray(list) ? list : (list?.projects ?? []) + console.log('[cockpit-dbg] resolved cancelled=', c, 'rows=', rows?.length) if (!c) return // rdm.project.list 返回 { projects: [...] };容忍裸数组形态。 - const rows = Array.isArray(list) ? list : (list?.projects ?? []) setProjects(rows) + console.log('[cockpit-dbg] setProjects done') }) .catch(e => { if (!c) setError(e.message) }) return () => { c = true }