docs(tests): explain renderer timing and migration probes

This commit is contained in:
2026-11-12 18:25:52 +08:00
parent 357c92d749
commit f0c7c83b24
3 changed files with 7 additions and 1 deletions
+2 -1
View File
@@ -19,7 +19,7 @@ export function createRendererMigrationFixture({id,account,workspace,boards,docu
return{states,async handle(request,path,reply,bytes){
const state=states.find(value=>path.includes('/materials/'+value.root+'/canvas'));if(!state)return false;
const base=`/materials/${state.root}/canvas`,raw=bytes.length?JSON.parse(bytes.toString()):undefined;
// 未迁移时 canonical model 返回带 source_versions 的明确 migration_required;此 header 才能开启升级入口。
// 未迁移时 canonical model 返回 409,响应正文含 migration_required 和 source_versions;不是靠响应 header 开启升级入口。
if(path.endsWith(base+'/model')&&!state.ready){reply(409,{error:'canonical_migration_required',root_id:state.root,document_format_version:1,source_versions:{[state.root]:state.version}});return true;}
// 旧快照 GET 返回当前 document;PATCH 校验账户和 If-Match,并禁止 ready 后旧 writer 再写入。
if(path.endsWith(base)){
@@ -75,6 +75,7 @@ export async function verifyRendererMigration({fixture,call,evaluate,until,port,
// 旧编辑器可用条件同时检查升级入口和画布非 inert,避免只凭按钮出现就认为旧写入已放开。
const editable=()=>`!!${button('升级画布')}&&!document.querySelector('.react-flow').parentElement.inert`;
// 账户/workspace 级持久化迁移键,稍后比较保存的冻结 body 与服务实际收到字节。
// 原请求尚未知时保留同一 key/body;只有 terminal not-applied 证明零写入后,显式重新准备才可以取新版本生成新请求。
const storageKey=`endoleap_canvas_migration_v1:${account}:${workspace}`;
// 五份状态按下方场景依次使用,互不污染版本、回执和旧 PATCH 数量。
const[a,b,c,d,e]=fixture.states;