#!/usr/bin/env node /* 移动端等待提示验证(修正版):点发送按钮(手机回车=换行,Enter 不发送) */ 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 依次执行 echo m-step-1、sleep 15、echo m-step-2,每步之间报告进度。'); await page.locator('.m-send').click(); console.log('已点击发送按钮'); let sawWait = false; let sawRunning = false; let sawLive = false; for (let i = 0; i < 20; i++) { const probe = await page.evaluate(() => { const turns = [...document.querySelectorAll('app-assistant-turn')]; const last = turns[turns.length - 1]; const txt = (sel) => [...document.querySelectorAll(sel)].map((e) => e.textContent.replace(/\s+/g, ' ').trim()); return { turnCount: turns.length, lastTurn: last ? (last.textContent || '').replace(/\s+/g, ' ').trim().slice(0, 120) : null, wait: txt('.card-wait'), running: txt('.card-running'), liveSteps: document.querySelectorAll('app-live-activity .step, app-live-activity li, app-live-activity .live-step').length, liveVisible: !!document.querySelector('app-live-activity'), }; }); console.log(`[+${i * 2}s]`, JSON.stringify(probe)); if (probe.wait.length) sawWait = true; if (probe.running.length) sawRunning = true; if (probe.liveVisible && probe.liveSteps > 0) sawLive = true; if (i === 3) await page.screenshot({ path: resolve(outDir, 'm-04-wait.png') }); if (i === 8) await page.screenshot({ path: resolve(outDir, 'm-05-live.png') }); await page.waitForTimeout(2000); } console.log('=== 结论 ==='); console.log('④ 等待期文字提示(已送达·正在思考 / 已处理 Ns):', sawWait || sawRunning ? 'OK' : 'FAIL'); console.log('⑤ 过程中实时步骤区:', sawLive ? 'OK' : '(未出现,可能任务太快或进度消息未达)'); await browser.close();