test(account): 补个人中心购买/授权记录真后端 e2e(市场记录三件套补完)
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) <noreply@anthropic.com>
This commit is contained in:
parent
38d4631f06
commit
db63b2d57e
59
muse-studio/e2e/account-market-records.spec.ts
Normal file
59
muse-studio/e2e/account-market-records.spec.ts
Normal file
@ -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<void> {
|
||||
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 });
|
||||
});
|
||||
Loading…
x
Reference in New Issue
Block a user