| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- 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);
- // ① 会话切换验证(核心 bug)
- await p.goto('http://localhost:4200/desktop/chat/zhixia', { waitUntil:'networkidle' });
- await clear(); await p.waitForTimeout(1800);
- const before = await p.locator('.chat-title strong').textContent().catch(()=>'?');
- await p.locator('.conv-row').nth(1).click();
- await p.waitForTimeout(2000);
- const after = await p.locator('.chat-title strong').textContent().catch(()=>'?');
- console.log(`① 会话切换: ${before} → ${after} ${before!==after ? '✅ 可切换' : '❌ 仍不能切换'}`);
- await p.screenshot({ path: '../../.shots/f2-chat.png' });
- // ② 通讯录白框
- await p.goto('http://localhost:4200/desktop/contacts', { waitUntil:'networkidle' });
- await clear(); await p.waitForTimeout(1800);
- const boxW = await p.locator('.search-box').first().evaluate(el => Math.round(el.getBoundingClientRect().width)).catch(()=>0);
- console.log(`② 通讯录搜索框宽度: ${boxW}px ${boxW < 400 ? '✅ 已限宽' : '❌ 仍撑满'}`);
- await p.screenshot({ path: '../../.shots/f2-contacts.png' });
- // ③ 导航选中态(无竖条) + 折叠
- await p.goto('http://localhost:4200/desktop/workbench', { waitUntil:'networkidle' });
- await clear(); await p.waitForTimeout(1500);
- const shadow = await p.locator('.nav-link.active').first().evaluate(el => getComputedStyle(el).boxShadow).catch(()=>'none');
- console.log(`③ 导航选中态 box-shadow: ${shadow} ${shadow==='none' ? '✅ 无竖条' : '❌ 仍有'}`);
- await p.locator('.collapse-btn').click();
- await p.waitForTimeout(1200);
- const navW = await p.locator('.sidebar').evaluate(el => Math.round(el.getBoundingClientRect().width));
- console.log(`④ 折叠后侧栏宽: ${navW}px ${navW < 100 ? '✅ 已折叠' : '❌ 未折叠'}`);
- await p.screenshot({ path: '../../.shots/f2-nav-collapsed.png' });
- // ⑤ 我的页 PC 布局
- await p.goto('http://localhost:4200/desktop/mine', { waitUntil:'networkidle' });
- await clear(); await p.waitForTimeout(1800);
- await p.screenshot({ path: '../../.shots/f2-mine.png', fullPage: true });
- console.log(errs.length ? '⚠ 错误: '+errs.slice(0,2).join(' | ') : '✅ 无控制台错误');
- await b.close();
|