#!/usr/bin/env node /* 移动端会话列表忙碌环验证:任务运行中返回列表,看「技能锁定测试」行是否出旋转环 */ import { chromium, devices } from 'playwright'; import { resolve, dirname } from 'node:path'; import { fileURLToPath } from 'node:url'; const outDir = resolve(dirname(fileURLToPath(import.meta.url)), '../test-results/ui-experience-20261202'); const BASE = process.env.BASE_URL || 'http://127.0.0.1:4300'; 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(); page.on('pageerror', (e) => console.log('PAGEERR', String(e))); await page.goto(`${BASE}/mobile/messages`, { waitUntil: 'domcontentloaded' }); await page.waitForTimeout(9000); await page.locator('text=技能锁定测试').first().click(); await page.waitForTimeout(5000); /* 发一个长任务 */ const box = page.locator('textarea').first(); await box.click(); await box.fill('请用 terminal 执行 sleep 40 && echo busy-ring-probe,然后报告。'); await page.locator('.m-send').click(); await page.waitForTimeout(3000); /* 返回会话列表 */ await page.goto(`${BASE}/mobile/messages`, { waitUntil: 'domcontentloaded' }); await page.waitForTimeout(4000); const probe = await page.evaluate(() => { const busy = [...document.querySelectorAll('.m-presence--busy')]; const rows = [...document.querySelectorAll('a, li, [class*="row"]')].filter((e) => (e.textContent || '').includes('技能锁定测试'), ); const row = rows[0]; return { busyCount: busy.length, busyInTargetRow: row ? !!row.querySelector('.m-presence--busy') || !!row.parentElement?.querySelector('.m-presence--busy') : null, rowHtml: row ? row.outerHTML.replace(/\s+/g, ' ').slice(0, 500) : null, }; }); console.log(JSON.stringify(probe, null, 2)); await page.screenshot({ path: resolve(outDir, 'm-06-busy-ring.png') }); console.log(probe.busyCount > 0 ? '⑥ 列表忙碌环: OK' : '⑥ 列表忙碌环: FAIL'); await browser.close();