_v6.mjs 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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. await p.goto('http://localhost:4200/desktop/chat/zhixia', { waitUntil:'networkidle' });
  15. await clear(); await p.waitForTimeout(2000);
  16. // ① 右栏显示时 vs 隐藏时的列数
  17. const withRail = await p.evaluate(() => getComputedStyle(document.querySelector('.conversation-layout')).gridTemplateColumns);
  18. await p.locator('.rail-col .col-head ui-button button').click(); // 关右栏
  19. await p.waitForTimeout(1000);
  20. const withoutRail = await p.evaluate(() => ({
  21. cols: getComputedStyle(document.querySelector('.conversation-layout')).gridTemplateColumns,
  22. railExists: !!document.querySelector('.rail-col'),
  23. chatW: Math.round(document.querySelector('.main-col').getBoundingClientRect().width),
  24. }));
  25. console.log('① 右栏显示时列数:', withRail);
  26. console.log(' 隐藏后:', JSON.stringify(withoutRail));
  27. console.log(` ${withoutRail.cols.split(' ').length === 2 ? '✅ 聊天区已填满' : '❌ 仍留空'}`);
  28. await p.screenshot({ path: '../../.shots/v6-chat-norail.png' });
  29. // ② 会话列表滚动
  30. await p.goto('http://localhost:4200/desktop/chat/zhixia', { waitUntil:'networkidle' });
  31. await clear(); await p.waitForTimeout(1800);
  32. const scr = await p.evaluate(() => {
  33. const el = document.querySelector('.list-scroll');
  34. return { overflow: getComputedStyle(el).overflowY, h: Math.round(el.getBoundingClientRect().height) };
  35. });
  36. console.log('② 会话列表:', JSON.stringify(scr), scr.overflow === 'auto' ? '✅ 可内滚' : '❌');
  37. // ③ 列表页滚动区
  38. await p.goto('http://localhost:4200/desktop/events', { waitUntil:'networkidle' });
  39. await clear(); await p.waitForTimeout(1800);
  40. const zone = await p.evaluate(() => {
  41. const z = document.querySelector('.scroll-zone');
  42. const f = document.querySelector('.fixed-zone');
  43. return { zoneAnim: getComputedStyle(z).animationName, fixedH: Math.round(f.getBoundingClientRect().height) };
  44. });
  45. console.log('③ 列表页滚动区动画:', JSON.stringify(zone));
  46. console.log(errs.length ? '⚠ '+errs.slice(0,2).join(' | ') : '✅ 无控制台错误');
  47. await b.close();