完成 2.0.0 S4 的外部 AI、admin、account 与 solo SQL 收口,并推进 S5 studio 市场/handoff/旧编辑器入口裁剪。S5 的前端单测、构建与 route-only e2e 已留证;MSW-off 创作主线 e2e 仍因本地后端活体启动口径待修正,已在总账标为未完成验收。
51 lines
2.1 KiB
TypeScript
51 lines
2.1 KiB
TypeScript
import { expect, test, type Page } from '@playwright/test';
|
|
|
|
test.skip(true, '2.0.0 S5 单人版已移除市场、handoff 或多用户前端入口,本 spec 隔离保留待恢复');
|
|
|
|
/**
|
|
* 个人中心 New-API 绑定摘要 e2e(真实后端,MSW off)——A 类:后端 getAppNewApiBinding 就绪、studio 此前 0 消费。
|
|
*
|
|
* 反假绿:盘点 02G ❌ "New-API 绑定摘要"缺口——后端就绪(curl code:0、未绑定时 fail-closed 返 bindingStatus=unbound),
|
|
* 但前端无任何展示。本测进个人中心 → 等真实 GET /account/new-api-binding → 验 code:0 + 「New-API 绑定」区
|
|
* 按真实 bindingStatus 渲染状态徽标。
|
|
* 设计:不硬编码绑定态(随账户状态变),依真实响应数据断言——区块标题恒在,徽标按返回 bindingStatus 映射。
|
|
*/
|
|
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);
|
|
}
|
|
|
|
const STATUS_LABELS: Record<string, string> = {
|
|
bound: '已绑定',
|
|
unbound: '未绑定',
|
|
sync_failed: '同步失败',
|
|
pending: '同步中',
|
|
};
|
|
|
|
test('个人中心渲染 New-API 绑定摘要(真实后端)', async ({ page }) => {
|
|
await seedToken(page);
|
|
|
|
const bindingResp = page.waitForResponse(
|
|
(r) =>
|
|
/\/account\/new-api-binding$/.test(new URL(r.url()).pathname) &&
|
|
r.request().method() === 'GET',
|
|
{ timeout: 15_000 }
|
|
);
|
|
await page.goto('/account');
|
|
const resp = await bindingResp;
|
|
expect(resp.status()).toBe(200);
|
|
const body = await resp.json();
|
|
expect(body.code).toBe(0); // 后端就绪(未绑定时 fail-closed unbound,非报错)。
|
|
|
|
// 「New-API 绑定」区渲染(标题恒在) + 状态徽标按真实 bindingStatus 映射(证真后端态被 UI 消费)。
|
|
await expect(page.getByRole('heading', { name: 'New-API 绑定' })).toBeVisible({ timeout: 10_000 });
|
|
const expectedLabel = STATUS_LABELS[body.data?.bindingStatus] ?? body.data?.bindingStatus;
|
|
if (expectedLabel) {
|
|
await expect(page.getByText(expectedLabel).first()).toBeVisible({ timeout: 10_000 });
|
|
}
|
|
});
|