From 0ced171305525ed9265e339e43e600572ec0dbac Mon Sep 17 00:00:00 2001 From: Codex Bot Date: Wed, 11 Nov 2026 15:55:23 +0800 Subject: [PATCH] test(canvas): drain cancellation events before next AI admission --- tests/headless/foundry-ai.integration.mjs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/headless/foundry-ai.integration.mjs b/tests/headless/foundry-ai.integration.mjs index db02fc3..8a34c8d 100644 --- a/tests/headless/foundry-ai.integration.mjs +++ b/tests/headless/foundry-ai.integration.mjs @@ -14,7 +14,7 @@ export async function verifyFoundryAI({open,transport,rootId,imageId,assets,call const target={id:randomUUID(),incarnation:1}; assert.equal(engine.editor.dispatch({type:'element.create',element:{id:target.id,incarnation:1,ownerCanvasId:rootId,componentId:'text',dataVersion:1,structure:'node',data:{title:'Real AI adapter',text:'before generation',extension:{keep:true}},geometry:{x:0,y:0,width:100,height:80,rotation:0}}}).status,'applied');await engine.settle(); const input={target,boardId:rootId,modelId:'fixture-text',prompt:'Fixture generation',parameters:{},propagate:false}; - const begin=async value=>{const result=engine.startRun(value);assert.equal(result.status,'applied');await engine.settle();return result;}; + const begin=async value=>{const result=engine.startRun(value);assert.equal(result.status,'applied',JSON.stringify(result));await engine.settle();return result;}; const byOperation=id=>[...engine.getSnapshot().runtime.runs.values()].find(run=>run.operationId===id); const initialStarts=posts('/ai/runs').length,initialUploads=posts('/assets').length; @@ -38,6 +38,7 @@ export async function verifyFoundryAI({open,transport,rootId,imageId,assets,call loseAction();assert.equal(engine.cancelRun(secondRun.id).status,'applied');await engine.settle(); const cancellation=[...engine.getSnapshot().runtime.ledger.requests.values()].find(request=>request.kind==='run.cancel'&&request.runId===secondRun.id);assert.equal(cancellation.phase,'waiting');const cancellationCount=posts('/cancel').length; await reopen();assert.equal(posts('/cancel').length,cancellationCount);assert.equal(engine.getSnapshot().runtime.ledger.requests.get(cancellation.id).body,cancellation.body);assert.equal(engine.getSnapshot().runtime.runs.get(secondRun.id).status,'cancelled'); + await poll();assert.equal(engine.getSnapshot().runtime.runs.get(secondRun.id).hasMore,false,'drain the cancelled run event cursor before another admission'); assert.equal((await control('stats')).executions,beforeCancel); // Edit while the provider is held, then retain and explicitly apply its output.