oh-my-muse/muse-studio/e2e/account-publish-records.spec.ts
lili 3dff0e1735 feat(account): studio 个人中心补齐市场记录三件套之三「我的发布」+ e2e
P3 真缺口补全(6/7):PersonalCenter 此前只有购买记录+授权记录,缺发布记录(账户台账视角)——补齐三件套对称。useAccountPublishRecords→GET /account/publish-records(AppPublishRecordRespVO:reviewStatus/marketStatus/blockingReason);PersonalCenter 加「我的发布」区。

查重结论:不与 market 模块 useMyPublishRecords 重复——后者是发布工作流操作台(草稿/提交/申诉,my-publish-records),本接口是账户中心历史台账(account/publish-records,member 模块,与购买/授权并列)。

验证:vitest account 3/3(加 publish-records URL+reviewStatus 契约)、tsc 0 错;新增 e2e account-publish-records.spec.ts 真后端绿(GET 200+「我的发布」渲染),全量 29/29 无回归。

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-20 20:36:20 -07:00

38 lines
1.5 KiB
TypeScript

import { expect, test, type Page } from '@playwright/test';
/**
* 账户中心「我的发布」记录 e2e(真实后端,MSW off)。
*
* 前置:vite VITE_API_MOCK=false、真实 muse-server 48080、muse_slice_live(market-publish 旅程已落发布记录)。
* 目的:个人中心补齐市场记录三件套之三——发布记录(账户台账视角,GET /account/publish-records),
* 验真后端读通 + 「我的发布」区渲染(反假绿)。不依赖记录条数,故只断言契约与区块存在。
*/
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\/publish-records/.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 });
});