import { chromium } from 'playwright'; const b = await chromium.launch({ executablePath: 'C:/Program Files/Google/Chrome/Application/chrome.exe' }); const p = await (await b.newContext({ viewport: { width: 1440, height: 900 } })).newPage(); const errs = []; p.on('pageerror', e => errs.push(e.message.slice(0,120))); p.on('console', m => { if (m.type()==='error') errs.push(m.text().slice(0,120)); }); const clear = () => p.evaluate(() => document.querySelectorAll('vite-error-overlay').forEach(e=>e.remove())); await p.goto('http://localhost:4200/login', { waitUntil:'networkidle' }); await clear(); await p.waitForTimeout(800); const ins = await p.locator('ui-input input').all(); await ins[0].fill('13800138000'); await ins[1].fill('123456'); await p.getByText('登 录', { exact:false }).first().click(); await p.waitForTimeout(3000); // ① 通讯录白框 await p.goto('http://localhost:4200/desktop/contacts', { waitUntil:'networkidle' }); await clear(); await p.waitForTimeout(1800); const c = await p.evaluate(() => { const tabs = document.querySelector('ui-tabs'); return { hasUiTabs: !!tabs, hasSegmented: !!document.querySelector('ui-segmented'), toolbarH: Math.round(document.querySelector('.toolbar')?.getBoundingClientRect().height ?? 0) }; }); console.log('① 通讯录:', JSON.stringify(c)); await p.screenshot({ path: '../../.shots/v4-contacts.png' }); // ② 导航「需要关注」是否删除 const nav = await p.evaluate(() => document.body.innerText.includes('需要关注')); console.log(`② 导航「需要关注」区块: ${nav ? '❌ 仍在' : '✅ 已删除'}`); // ③ 消息顺序 + 右栏切换 await p.goto('http://localhost:4200/desktop/chat/zhixia', { waitUntil:'networkidle' }); await clear(); await p.waitForTimeout(2000); const m = await p.evaluate(() => { const msgs = document.querySelector('.messages'); return { align: getComputedStyle(msgs).alignContent, railOpen: !!document.querySelector('.rail-col') }; }); console.log(`③ 消息排列: align-content=${m.align} ${m.align==='start'?'✅ 自上而下':'❌ 仍贴底'}`); await p.screenshot({ path: '../../.shots/v4-chat-results.png' }); // 点「任务」按钮 → 右栏切到任务 await p.locator('.chat-actions ui-button').first().locator('button').click(); await p.waitForTimeout(1200); const t = await p.evaluate(() => ({ railHeader: document.querySelector('.rail-col h2')?.textContent?.trim(), taskItems: document.querySelectorAll('.rail-item.task').length, })); console.log(`④ 点任务按钮后: 右栏标题="${t.railHeader}" 任务项=${t.taskItems} ${t.railHeader==='任务'?'✅ 已切换':'❌'}`); await p.screenshot({ path: '../../.shots/v4-chat-tasks.png' }); // ⑤ 列表页固定头部 await p.goto('http://localhost:4200/desktop/tasks', { waitUntil:'networkidle' }); await clear(); await p.waitForTimeout(1800); const f = await p.evaluate(() => { const page = document.querySelector('.page'); return { splitMode: page?.classList.contains('split-mode'), fixed: !!document.querySelector('.fixed-zone'), scroll: !!document.querySelector('.scroll-zone') }; }); console.log(`⑤ 任务看板固定头部: ${JSON.stringify(f)}`); console.log(errs.length ? '⚠ '+errs.slice(0,2).join(' | ') : '✅ 无控制台错误'); await b.close();