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