verify-mobile-experience-20261202.mjs 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. #!/usr/bin/env node
  2. /**
  3. * P3 移动端实测(2026-12-02,移动视口 390×844):
  4. * ① 输入区背景透明(.m-composer-area 无底色)
  5. * ② 输入坞与消息流左边距对齐(双层 gutter 已删)
  6. * ③ 无容器命名:.m-target 胶囊不存在、placeholder=发消息…、副标题无容器名
  7. * ④ 发送后出现等待提示(card-wait / card-running,恢复桌面同款)
  8. * ⑤ 会话列表忙碌环(.m-presence--busy)
  9. */
  10. import { chromium, devices } from 'playwright';
  11. import { mkdir } from 'node:fs/promises';
  12. import { dirname, resolve } from 'node:path';
  13. import { fileURLToPath } from 'node:url';
  14. const here = dirname(fileURLToPath(import.meta.url));
  15. const root = resolve(here, '..');
  16. const outDir = resolve(root, 'test-results/ui-experience-20261202');
  17. const BASE = process.env.BASE_URL || 'http://127.0.0.1:4300';
  18. await mkdir(outDir, { recursive: true });
  19. const browser = await chromium.launch({ channel: 'chrome' });
  20. const ctx = await browser.newContext({ ...devices['Pixel 7'], viewport: { width: 390, height: 844 } });
  21. const page = await ctx.newPage();
  22. const errors = [];
  23. page.on('pageerror', (e) => errors.push(String(e)));
  24. await page.goto(`${BASE}/mobile/messages`, { waitUntil: 'domcontentloaded' });
  25. await page.waitForTimeout(9000);
  26. await page.screenshot({ path: resolve(outDir, 'm-00-list.png') });
  27. const target = page.locator('text=技能锁定测试').first();
  28. if (await target.count()) {
  29. await target.click();
  30. await page.waitForTimeout(5000);
  31. console.log('已进入「技能锁定测试」会话');
  32. } else {
  33. console.log('!! 列表里没找到「技能锁定测试」');
  34. }
  35. await page.screenshot({ path: resolve(outDir, 'm-01-chat.png') });
  36. const probe = await page.evaluate(() => {
  37. const area = document.querySelector('.m-composer-area');
  38. const dock = document.querySelector('.m-dock');
  39. const firstMsg = document.querySelector('.m-row-body, .msg-list, main .turn');
  40. const areaStyle = area ? getComputedStyle(area) : null;
  41. const dockRect = dock?.getBoundingClientRect();
  42. const msgRect = firstMsg?.getBoundingClientRect();
  43. const subtitle = document.querySelector('.m-app-bar small, app-m-app-bar small, header small');
  44. const ta = document.querySelector('textarea');
  45. return {
  46. areaBg: areaStyle?.backgroundColor ?? null,
  47. areaPadLeft: areaStyle?.paddingLeft ?? null,
  48. dockLeft: dockRect ? Math.round(dockRect.left) : null,
  49. msgLeft: msgRect ? Math.round(msgRect.left) : null,
  50. targetCapsule: document.querySelectorAll('.m-target').length,
  51. placeholder: ta?.getAttribute('placeholder') ?? null,
  52. subtitle: subtitle?.textContent?.trim() ?? null,
  53. };
  54. });
  55. console.log('输入区探针:', JSON.stringify(probe, null, 1));
  56. // 发一条任务,观察等待提示与列表忙碌环
  57. const box = page.locator('textarea').first();
  58. if (await box.count()) {
  59. await box.click();
  60. await box.fill('请用 terminal 执行 echo mobile-ui-check,然后告诉我输出。');
  61. await page.keyboard.press('Enter');
  62. await page.waitForTimeout(4000);
  63. const wait = await page.evaluate(() => ({
  64. cardWait: [...document.querySelectorAll('.card-wait, .card-running')].map((e) => e.textContent.trim()),
  65. liveActivity: !!document.querySelector('app-live-activity'),
  66. }));
  67. console.log('等待提示探针:', JSON.stringify(wait));
  68. await page.screenshot({ path: resolve(outDir, 'm-02-waiting.png') });
  69. // 回列表看忙碌环
  70. await page.goBack();
  71. await page.waitForTimeout(4000);
  72. const busy = await page.evaluate(() => document.querySelectorAll('.m-presence--busy').length);
  73. console.log('列表忙碌环数量:', busy);
  74. await page.screenshot({ path: resolve(outDir, 'm-03-list-busy.png') });
  75. }
  76. console.log('=== 结论 ===');
  77. console.log('① 输入区背景透明:', probe.areaBg === 'rgba(0, 0, 0, 0)' || probe.areaBg === 'transparent' ? 'OK' : `FAIL(${probe.areaBg})`);
  78. console.log('② 输入坞左边距 = 16px 单层 gutter:', probe.dockLeft === 16 ? 'OK' : `FAIL(left=${probe.dockLeft})`);
  79. console.log('③ 无命名胶囊:', probe.targetCapsule === 0 ? 'OK' : 'FAIL', '| placeholder:', probe.placeholder);
  80. console.log('③ 副标题:', probe.subtitle);
  81. console.log('页面错误:', errors.length ? errors : '无');
  82. await browser.close();