test(studio-e2e): global-setup 补 asset1/work1 fixture 复位(环境污染致 7 spec 偶发红)

studio e2e 全量核查 run1 7 红,根因测试间环境污染、global-setup 复位不全:①asset1「活体市场资产·测试」被历史操作 delisted(应 listed/active)→bind-precheck 返 1044000003 资产不存在→连带 handoff-agent/content/knowledge+live-read 市场浏览+market-governance-impact+market-handoff-precheck 6 红;②work1 残留多余 writing.expansion active 槽位(spec 假设仅 continuation)→agent-slot-bind strict 命中 2 元素红。修:§17 复位 asset1→listed/active、§18 删 work1 非 continuation 槽位。验证:重新污染→自愈后 7 spec 全绿、全量回归持续绿。

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
lili 2026-06-25 13:47:28 -07:00
parent 443a1f3414
commit de5f4d0bf9

View File

@ -369,7 +369,33 @@ async function globalSetup(): Promise<void> {
String(installE2eAssetId),
]);
console.log(`[e2e globalSetup] 已复位每轮 fixture(graph/confirm-draft/accept/security-ack/appeal/binding/meta-schema/block/kb-status/installed-kb/handoff-bind/handoff-agent/handoff-content/agent-slot-bind/market-install assetId=${installE2eAssetId});清理 e2e 累积 agent ${agentCleanup.rowCount}`);
// 17) 复位种子资产 asset1「活体市场资产·测试」为上架态(listing_status='listed'、status='active')。
// WHY:asset1 是 handoff-agent/handoff-content/handoff-knowledge 正路(bind-precheck/createHandoff 的来源资产)、
// market-handoff-precheck、market-governance-impact(详情页 /market/assets/1)、live-read「市场浏览」的共同依赖。
// 这些 spec 默认 asset1 可被消费(在售/可绑/可见)。若 asset1 被历史操作下架(实测 listing_status/status='delisted'),
// 则:① bind-precheck 直接返「Market 资产不存在(1044000003)」→ handoff 三条正路 + market-handoff-precheck 红;
// ② 市场列表不含该资产 → live-read「市场浏览」断言渲染该资产 timeout 红;
// ③ 详情页对下架资产不渲染绑定/治理控件 → governance-impact、handoff-knowledge 填「目标作品 ID」timeout 红。
// 无任何 spec 主动下架 asset1(grep 全 spec 确认),故其下架属环境污染,此处每轮复位为上架态修正。
// 注:asset1 上的治理结果记录(resultType=delist 演练)保留不动——governance-impact spec 依真实响应断言其展示,
// 上架态 + 留存治理记录两者并存正是该 spec 的预期数据形态(curl 已证 governanceResult 仍随上架资产返回)。
const asset1Reset = await client.query(
"UPDATE muse_market_asset SET listing_status='listed', status='active' WHERE tenant_id=1 AND id=1 AND deleted=false"
);
if (asset1Reset.rowCount === 0) {
console.warn('[e2e globalSetup] ⚠️ 未找到 asset id=1「活体市场资产·测试」(handoff/market 系列正路用例需该种子资产)');
}
// 18) 清理 work1 除 writing.continuation 外的多余 active 槽位(去污)。
// WHY:agent-slot-bind.spec 假设 work1 仅一个开放槽位(writing.continuation,§15 每轮复位),据此用
// getByText('revision 1') 唯一定位该槽位卡片。若 work1 残留了别的 active 槽位(实测有 writing.expansion、
// 同为 revision 1),则页面出现 2 个「revision 1」节点 → strict 模式命中歧义、该断言红。§15 只管 continuation 槽位,
// 未清其它,故此处补一刀删净 work1 非 continuation 槽位(物理 DELETE 释放唯一约束名额),保证 UI 槽位唯一可定位。
const work1SlotCleanup = await client.query(
"DELETE FROM muse_agent_slot_binding WHERE tenant_id=1 AND work_id=1 AND slot_key<>'writing.continuation'"
);
console.log(`[e2e globalSetup] 已复位每轮 fixture(graph/confirm-draft/accept/security-ack/appeal/binding/meta-schema/block/kb-status/installed-kb/handoff-bind/handoff-agent/handoff-content/agent-slot-bind/market-install assetId=${installE2eAssetId}/asset1-listed/work1-slot-dedup);清理 e2e 累积 agent ${agentCleanup.rowCount} 条、work1 多余槽位 ${work1SlotCleanup.rowCount}`);
} finally {
await client.end();
}