From db63b2d57e868a67659bc6720d9b2301fd86edbc Mon Sep 17 00:00:00 2001 From: lili Date: Sun, 21 Jun 2026 12:55:50 -0700 Subject: [PATCH] =?UTF-8?q?test(account):=20=E8=A1=A5=E4=B8=AA=E4=BA=BA?= =?UTF-8?q?=E4=B8=AD=E5=BF=83=E8=B4=AD=E4=B9=B0/=E6=8E=88=E6=9D=83?= =?UTF-8?q?=E8=AE=B0=E5=BD=95=E7=9C=9F=E5=90=8E=E7=AB=AF=20e2e(=E5=B8=82?= =?UTF-8?q?=E5=9C=BA=E8=AE=B0=E5=BD=95=E4=B8=89=E4=BB=B6=E5=A5=97=E8=A1=A5?= =?UTF-8?q?=E5=AE=8C)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit purchases(GET /account/purchases)/licenses(/account/licenses)与已有「我的发布」同源 (AccountMarketRecordService 读 muse_account_record_projection 投影表),此前有 UI+hook 但缺真后端 e2e 验证(假绿风险)。补两 test:验 200/code:0 + 「我的购买」/「我的授权」区 真后端读通渲染。全量 e2e 38/0(原 36/0)。 Co-Authored-By: Claude Opus 4.8 (1M context) --- .../e2e/account-market-records.spec.ts | 59 +++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 muse-studio/e2e/account-market-records.spec.ts diff --git a/muse-studio/e2e/account-market-records.spec.ts b/muse-studio/e2e/account-market-records.spec.ts new file mode 100644 index 00000000..fe6b5da3 --- /dev/null +++ b/muse-studio/e2e/account-market-records.spec.ts @@ -0,0 +1,59 @@ +import { expect, test, type Page } from '@playwright/test'; + +/** + * 账户中心「我的购买 / 我的授权」记录 e2e(真实后端,MSW off)。 + * + * 前置:vite VITE_API_MOCK=false、真实 muse-server 48080。 + * 目的:补齐个人中心市场记录三件套之一/之二——购买(GET /account/purchases)、授权(GET /account/licenses), + * 与已有「我的发布」(account-publish-records.spec.ts)同源:三者皆经 AccountMarketRecordService 读 + * muse_account_record_projection 投影表。验真后端读通 + 区块渲染(反假绿)。 + * 不依赖记录条数(投影可空),故只断言契约(200/code:0)与区块存在。 + */ +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('账户中心展示我的购买记录(真实后端)', async ({ page }) => { + await seedToken(page); + + // 进个人中心,捕获真实购买记录读响应(打真后端,非 mock)。 + const [resp] = await Promise.all([ + page.waitForResponse( + (r) => /\/account\/purchases/.test(r.url()) && r.request().method() === 'GET', + { timeout: 15_000 } + ), + page.goto('/account'), + ]); + + // Yudao 口径:成功为 HTTP 200 + CommonResult{code:0}。 + expect(resp.status()).toBe(200); + expect((await resp.json()).code).toBe(0); + + // 「我的购买」区(市场记录三件套之一)渲染。 + await expect(page.getByRole('heading', { name: '我的购买' })).toBeVisible({ timeout: 15_000 }); +}); + +test('账户中心展示我的授权记录(真实后端)', async ({ page }) => { + await seedToken(page); + + // 进个人中心,捕获真实授权记录读响应(打真后端,非 mock)。 + const [resp] = await Promise.all([ + page.waitForResponse( + (r) => /\/account\/licenses/.test(r.url()) && r.request().method() === 'GET', + { timeout: 15_000 } + ), + page.goto('/account'), + ]); + + // Yudao 口径:成功为 HTTP 200 + CommonResult{code:0}。 + expect(resp.status()).toBe(200); + expect((await resp.json()).code).toBe(0); + + // 「我的授权」区(市场记录三件套之二)渲染。 + await expect(page.getByRole('heading', { name: '我的授权' })).toBeVisible({ timeout: 15_000 }); +});