_v4.mjs 3.2 KB

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