docs(tests): clarify legacy canvas DOM scenario coverage

This commit is contained in:
2026-11-12 18:23:15 +08:00
parent 7ac78e1191
commit 357c92d749
4 changed files with 14 additions and 7 deletions
+3 -1
View File
@@ -25,6 +25,7 @@ export async function canvasMemberScenario({root,act,h,useCanvasTree,makeCanvasN
// 内存 API 按路径分流:完整快照保存、版本命令、分区创建与成员迁移,各自记录参与者版本。
mock(async(url,options={})=>{
const parts=new URL(url,'http://localhost').pathname.split('/'),id=parts[6],suffix=parts.slice(8).join('/'),method=options.method||'GET';
// 此分支未区分 method,POST 也直接得到空列表;下方同路径 POST 分支不会到达,不模拟 canvas_version 推进。
if(suffix==='ai/runs')return json({runs:[]});
// 慢响应延迟超过两秒;一次网络失败只影响首个请求,允许检查重新探测而非永久判为不支持。
if(suffix==='capabilities'){
@@ -126,7 +127,8 @@ export async function canvasMemberScenario({root,act,h,useCanvasTree,makeCanvasN
await act(async()=>{await tree.undo();await tick();});assert.ok(tree.rootDocument.nodes.some(n=>n.id===pendingImage.id));assert.ok(!tree.current.current.get(child).nodes.some(n=>n.id===pendingImage.id));
await act(async()=>{await tree.redo();await tick();});assert.ok(tree.current.current.get(child).nodes.some(n=>n.id===pendingImage.id));assert.equal(posts.length,2,'Undo/redo after persistence use real ownership transactions');
console.log('PASS pending image ownership: editable local moves, atomic local undo, current-owner upload resolution and transactional undo after persistence');
// 版本刷新和分区创建响应都不能覆盖本地 pending/已完成图片;重复父快照也只能采用一次。
// 空 AI 响应与分区创建响应不能覆盖本地 pending/已完成图片;重复父快照也只能采用一次。
// 当前 mock 的 ai/runs POST 被前面的通用分支截获,因此该调用不能单独证明版本推进后的 refresh 合并行为。
await reset('create-delayed');
const asyncImage=makeCanvasNode('image',{x:800,y:500},'blob:async-upload');asyncImage.id='async-image';asyncImage.pendingUpload=asyncImage.id;
await act(async()=>{tree.dispatch({type:'nodes',changes:[{type:'add',item:asyncImage}]});await tick();});