| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- import { chromium } from 'playwright';
- const b = await chromium.launch({ executablePath: 'C:/Program Files/Google/Chrome/Application/chrome.exe' });
- const ctx = await b.newContext({ viewport: { width: 1440, height: 900 } });
- const p = await ctx.newPage();
- const errs = [];
- p.on('pageerror', e => errs.push(e.message.slice(0,150)));
- p.on('console', m => { if (m.type()==='error') errs.push(m.text().slice(0,150)); });
- 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(600);
- await p.fill('input[type="tel"]', '13800138000');
- await p.fill('input[type="text"][maxlength="6"]', '123456');
- await p.click('button[type="submit"]');
- await p.waitForTimeout(3000);
- await p.goto('http://localhost:4200/desktop/chat', { waitUntil: 'networkidle' });
- await clear();
- await p.waitForTimeout(2500);
- const r = await p.evaluate(() => {
- const lay = document.querySelector('.conversation-layout');
- return {
- url: location.pathname,
- cols: lay ? getComputedStyle(lay).gridTemplateColumns : null,
- colsCount: lay ? getComputedStyle(lay).gridTemplateColumns.split(' ').length : 0,
- uiInput: document.querySelectorAll('ui-input').length,
- msgBubbles: document.querySelectorAll('app-message-bubble').length,
- composer: !!document.querySelector('app-composer'),
- overflowX: document.documentElement.scrollWidth > document.documentElement.clientWidth,
- };
- });
- console.log('=== 1440 ==='); console.log(JSON.stringify(r, null, 2));
- await p.screenshot({ path: '../../.shots/final-chat-1440.png' });
- // 窄窗 1100 验证右栏让位
- await p.setViewportSize({ width: 1100, height: 900 });
- await p.waitForTimeout(1500);
- const n = await p.evaluate(() => {
- const lay = document.querySelector('.conversation-layout');
- return { cols: getComputedStyle(lay).gridTemplateColumns, railVisible: !!document.querySelector('.rail-col') && getComputedStyle(document.querySelector('.rail-col')).display !== 'none' };
- });
- console.log('=== 1100(右栏应让位)==='); console.log(JSON.stringify(n));
- await p.screenshot({ path: '../../.shots/final-chat-1100.png' });
- console.log(errs.length ? '⚠ 错误: '+errs.slice(0,2).join(' | ') : '✅ 无控制台错误');
- await b.close();
|