import { expect, test, type Page } from '@playwright/test'; /** * 活体只读旅程 e2e(真实后端,MSW off)。 * * 前置:vite 以 VITE_API_MOCK=false 运行(关 MSW)、真实 muse-server 在 48080、muse_slice_live 已种子。 * 目的:验证 rendered studio 经「client.ts 注入 tenant-id 修复」后的 HTTP 客户端,能直连活体单体并把 * content(作品列表)/account(个人资料)/ai(智能体列表)的真实后端数据在 UI 正确渲染。 */ const TOKEN = 'test1'; async function seedToken(page: Page): Promise { await page.addInitScript((t) => { window.localStorage.setItem('accessToken', t); window.localStorage.setItem('tenantId', '1'); }, TOKEN); } test.describe('活体只读旅程(真实后端,MSW off)', () => { test('作品列表渲染真实作品(content)', async ({ page }) => { await seedToken(page); await page.goto('/'); // .first():种子库存在多个同名作品(多次播种),strict 模式需唯一匹配;能渲染即证真实后端作品列表已加载。 await expect(page.getByText('活体验证样书').first()).toBeVisible({ timeout: 15_000 }); }); test.skip('市场浏览渲染真实资产(market)', async ({ page }) => { await seedToken(page); await page.goto('/market'); // .first():推荐位与资产列表可能同时渲染同一资产(推荐区新增),strict 模式需唯一匹配;渲染即证真实市场数据已加载。 await expect(page.getByText('活体市场资产·测试').first()).toBeVisible({ timeout: 15_000 }); }); test('个人中心渲染真实账户(account)', async ({ page }) => { await seedToken(page); await page.goto('/account'); await expect(page.getByText('活体用户')).toBeVisible({ timeout: 15_000 }); }); test('智能体列表渲染真实 Agent(ai)', async ({ page }) => { await seedToken(page); await page.goto('/agents'); await expect(page.getByText('活体测试智能体').first()).toBeVisible({ timeout: 15_000 }); }); test.skip('个人中心渲染真实购买/授权记录(account 深页)', async ({ page }) => { await seedToken(page); await page.goto('/account'); // 个人中心「我的购买 / 我的授权」渲染 market→account 投影的真实资产(后端经 market 跨模块 Facade 提供,curl 已证)。 await expect(page.getByText('活体市场资产·测试').first()).toBeVisible({ timeout: 15_000 }); }); test.skip('个人中心渲染真实安全事件(account 深页)', async ({ page }) => { await seedToken(page); await page.goto('/account'); // 个人中心「安全事件」区渲染 GET /account/security-events 的真实摘要(按登录用户隔离;种子见 /tmp/SeedSec.java,curl 已证)。 await expect(page.getByText('活体安全事件·异地登录提醒').first()).toBeVisible({ timeout: 15_000 }); }); });