PG 宿主 100.64.0.8 恢复在线→查出旧 jar(Jun-19 00:59)缺 GET bindings 端点(commit 3a7a72f Jun-19 13:30)致 405→rebuild Jun-20 新 jar(反假绿:不用过时 jar)→起栈 48080(local,infra,清 socks)→playwright MSW-off 真打:22 passed/0 failed/0 skipped/0 flaky(9.1s)。 覆盖:accept-suggestion 正负×2 + account-security-ack + agent-create + knowledge-bindings(06-19 PG 离线阻塞项 unblock) + knowledge-confirm + knowledge-graph + live-read×6 + market-publish×8 + workspace。 种子:核验 4/5 基础数据在,knowledge-bindings 投影固化进 e2e/global-setup.ts #6(可入库、下次自动补,补此前未覆盖项);0 红故无就地修。回写进度总账 §五C + 总览待办(受阻→完成) + spec 注释。附本会话 ce-brainstorm/ce-plan 产出文档。 诚实边界:本地全栈活体(rebuild jar + 真 PG muse_slice_live),非 CI(maven.yml 不跑 e2e/需活体后端+浏览器)。 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
53 lines
2.7 KiB
TypeScript
53 lines
2.7 KiB
TypeScript
import { expect, test, type Page } from '@playwright/test';
|
|
|
|
/**
|
|
* 作品已绑定知识来源读回视图 e2e(来源绑定读模型,真实后端,MSW off)。
|
|
*
|
|
* 前置(同 knowledge-graph.spec.ts 的活体全栈口径):
|
|
* - vite 以 VITE_API_MOCK=false 运行、真实 muse-server 在 48080;
|
|
* - muse_slice_live 作品 1 下已种子一条<生效>的来源绑定读模型投影
|
|
* (muse_knowledge_source_binding_projection:work_id=1、deleted=false、status=active、
|
|
* source_type=market_kb、kb_id=4001;可由真实 bind(precheck→bind)产生,或等价 seed)。
|
|
* 目的:rendered studio 的「作品已绑定的知识来源」面板经 GET /works/1/knowledge-bindings
|
|
* 读真实投影,把当前生效的来源绑定在 UI 渲染——证"绑定确认 → 读模型回填 → 读回展示"链路活体可见(打真后端,非 mock)。
|
|
*
|
|
* ✅ 状态(2026-06-20):本 spec 已活体跑绿——PG 宿主 100.64.0.8:5433 恢复在线、rebuild jar(含 GET bindings 端点)起栈 48080、
|
|
* playwright MSW-off 真打 1 passed(207ms,全量套件 22/22 内);绑定投影种子由 e2e/global-setup.ts #6 固化补齐。
|
|
* (历史:2026-06-19 曾因 PG 宿主离线 env 受阻未跑;后端读端点 + FE hook/面板早已在 vitest/单测/tsc/build 层验证。)
|
|
*/
|
|
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) => /\/works\/1\/knowledge-bindings(\?|$)/.test(r.url()) && r.request().method() === 'GET',
|
|
{ timeout: 15_000 }
|
|
),
|
|
page.goto('/knowledge/1'),
|
|
]);
|
|
|
|
// Yudao 口径:成功为 HTTP 200 + CommonResult{code:0}。
|
|
expect(resp.status()).toBe(200);
|
|
const body = await resp.json();
|
|
expect(body.code).toBe(0);
|
|
// 真实后端返回该作品当前生效(未删)的来源绑定。
|
|
const bindings = body.data?.bindings ?? [];
|
|
expect(bindings.length).toBeGreaterThan(0);
|
|
expect(bindings.some((b: { status: string }) => b.status === 'active')).toBe(true);
|
|
|
|
// UI 渲染:面板标题 + 来源类型徽标(market_kb→市场知识库)+ 生效状态徽标。
|
|
await expect(page.getByText('作品已绑定的知识来源').first()).toBeVisible({ timeout: 15_000 });
|
|
await expect(page.getByText('市场知识库').first()).toBeVisible({ timeout: 15_000 });
|
|
await expect(page.getByText('生效中').first()).toBeVisible({ timeout: 15_000 });
|
|
});
|