| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- #!/usr/bin/env node
- /**
- * P3 移动端实测(2026-12-02,移动视口 390×844):
- * ① 输入区背景透明(.m-composer-area 无底色)
- * ② 输入坞与消息流左边距对齐(双层 gutter 已删)
- * ③ 无容器命名:.m-target 胶囊不存在、placeholder=发消息…、副标题无容器名
- * ④ 发送后出现等待提示(card-wait / card-running,恢复桌面同款)
- * ⑤ 会话列表忙碌环(.m-presence--busy)
- */
- import { chromium, devices } from 'playwright';
- import { mkdir } from 'node:fs/promises';
- import { dirname, resolve } from 'node:path';
- import { fileURLToPath } from 'node:url';
- const here = dirname(fileURLToPath(import.meta.url));
- const root = resolve(here, '..');
- const outDir = resolve(root, 'test-results/ui-experience-20261202');
- const BASE = process.env.BASE_URL || 'http://127.0.0.1:4300';
- await mkdir(outDir, { recursive: true });
- const browser = await chromium.launch({ channel: 'chrome' });
- const ctx = await browser.newContext({ ...devices['Pixel 7'], viewport: { width: 390, height: 844 } });
- const page = await ctx.newPage();
- const errors = [];
- page.on('pageerror', (e) => errors.push(String(e)));
- await page.goto(`${BASE}/mobile/messages`, { waitUntil: 'domcontentloaded' });
- await page.waitForTimeout(9000);
- await page.screenshot({ path: resolve(outDir, 'm-00-list.png') });
- const target = page.locator('text=技能锁定测试').first();
- if (await target.count()) {
- await target.click();
- await page.waitForTimeout(5000);
- console.log('已进入「技能锁定测试」会话');
- } else {
- console.log('!! 列表里没找到「技能锁定测试」');
- }
- await page.screenshot({ path: resolve(outDir, 'm-01-chat.png') });
- const probe = await page.evaluate(() => {
- const area = document.querySelector('.m-composer-area');
- const dock = document.querySelector('.m-dock');
- const firstMsg = document.querySelector('.m-row-body, .msg-list, main .turn');
- const areaStyle = area ? getComputedStyle(area) : null;
- const dockRect = dock?.getBoundingClientRect();
- const msgRect = firstMsg?.getBoundingClientRect();
- const subtitle = document.querySelector('.m-app-bar small, app-m-app-bar small, header small');
- const ta = document.querySelector('textarea');
- return {
- areaBg: areaStyle?.backgroundColor ?? null,
- areaPadLeft: areaStyle?.paddingLeft ?? null,
- dockLeft: dockRect ? Math.round(dockRect.left) : null,
- msgLeft: msgRect ? Math.round(msgRect.left) : null,
- targetCapsule: document.querySelectorAll('.m-target').length,
- placeholder: ta?.getAttribute('placeholder') ?? null,
- subtitle: subtitle?.textContent?.trim() ?? null,
- };
- });
- console.log('输入区探针:', JSON.stringify(probe, null, 1));
- // 发一条任务,观察等待提示与列表忙碌环
- const box = page.locator('textarea').first();
- if (await box.count()) {
- await box.click();
- await box.fill('请用 terminal 执行 echo mobile-ui-check,然后告诉我输出。');
- await page.keyboard.press('Enter');
- await page.waitForTimeout(4000);
- const wait = await page.evaluate(() => ({
- cardWait: [...document.querySelectorAll('.card-wait, .card-running')].map((e) => e.textContent.trim()),
- liveActivity: !!document.querySelector('app-live-activity'),
- }));
- console.log('等待提示探针:', JSON.stringify(wait));
- await page.screenshot({ path: resolve(outDir, 'm-02-waiting.png') });
- // 回列表看忙碌环
- await page.goBack();
- await page.waitForTimeout(4000);
- const busy = await page.evaluate(() => document.querySelectorAll('.m-presence--busy').length);
- console.log('列表忙碌环数量:', busy);
- await page.screenshot({ path: resolve(outDir, 'm-03-list-busy.png') });
- }
- console.log('=== 结论 ===');
- console.log('① 输入区背景透明:', probe.areaBg === 'rgba(0, 0, 0, 0)' || probe.areaBg === 'transparent' ? 'OK' : `FAIL(${probe.areaBg})`);
- console.log('② 输入坞左边距 = 16px 单层 gutter:', probe.dockLeft === 16 ? 'OK' : `FAIL(left=${probe.dockLeft})`);
- console.log('③ 无命名胶囊:', probe.targetCapsule === 0 ? 'OK' : 'FAIL', '| placeholder:', probe.placeholder);
- console.log('③ 副标题:', probe.subtitle);
- console.log('页面错误:', errors.length ? errors : '无');
- await browser.close();
|