verify-mobile-busy-ring.mjs 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #!/usr/bin/env node
  2. /* 移动端会话列表忙碌环验证:任务运行中返回列表,看「技能锁定测试」行是否出旋转环 */
  3. import { chromium, devices } from 'playwright';
  4. import { resolve, dirname } from 'node:path';
  5. import { fileURLToPath } from 'node:url';
  6. const outDir = resolve(dirname(fileURLToPath(import.meta.url)), '../test-results/ui-experience-20261202');
  7. const BASE = process.env.BASE_URL || 'http://127.0.0.1:4300';
  8. const browser = await chromium.launch({ channel: 'chrome' });
  9. const ctx = await browser.newContext({ ...devices['Pixel 7'], viewport: { width: 390, height: 844 } });
  10. const page = await ctx.newPage();
  11. page.on('pageerror', (e) => console.log('PAGEERR', String(e)));
  12. await page.goto(`${BASE}/mobile/messages`, { waitUntil: 'domcontentloaded' });
  13. await page.waitForTimeout(9000);
  14. await page.locator('text=技能锁定测试').first().click();
  15. await page.waitForTimeout(5000);
  16. /* 发一个长任务 */
  17. const box = page.locator('textarea').first();
  18. await box.click();
  19. await box.fill('请用 terminal 执行 sleep 40 && echo busy-ring-probe,然后报告。');
  20. await page.locator('.m-send').click();
  21. await page.waitForTimeout(3000);
  22. /* 返回会话列表 */
  23. await page.goto(`${BASE}/mobile/messages`, { waitUntil: 'domcontentloaded' });
  24. await page.waitForTimeout(4000);
  25. const probe = await page.evaluate(() => {
  26. const busy = [...document.querySelectorAll('.m-presence--busy')];
  27. const rows = [...document.querySelectorAll('a, li, [class*="row"]')].filter((e) =>
  28. (e.textContent || '').includes('技能锁定测试'),
  29. );
  30. const row = rows[0];
  31. return {
  32. busyCount: busy.length,
  33. busyInTargetRow: row ? !!row.querySelector('.m-presence--busy') || !!row.parentElement?.querySelector('.m-presence--busy') : null,
  34. rowHtml: row ? row.outerHTML.replace(/\s+/g, ' ').slice(0, 500) : null,
  35. };
  36. });
  37. console.log(JSON.stringify(probe, null, 2));
  38. await page.screenshot({ path: resolve(outDir, 'm-06-busy-ring.png') });
  39. console.log(probe.busyCount > 0 ? '⑥ 列表忙碌环: OK' : '⑥ 列表忙碌环: FAIL');
  40. await browser.close();