From 4e3df81786fe8ac6ee226e61cebb045fa75036a9 Mon Sep 17 00:00:00 2001 From: Josh Wright Date: Mon, 12 Oct 2026 23:14:00 -0400 Subject: [PATCH] Fix lifecycle simulation in script scope tests --- tests/unit/script-flow.test.ts | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/tests/unit/script-flow.test.ts b/tests/unit/script-flow.test.ts index a1c5b2d..96b96a3 100644 --- a/tests/unit/script-flow.test.ts +++ b/tests/unit/script-flow.test.ts @@ -37,6 +37,20 @@ describe('scope options', () => { }); describe('editing promoted script scopes', () => { + async function activateAndCompleteFiles(kind: 'beta' | 'campaign', id: number | string) { + await activateFiles(kind, id); + const { db } = await import('../../src/lib/server/db/index.js'); + const { finishDeployment } = await import('../../src/lib/server/provisioning/history.js'); + // These scope-edit flows simulate a completed deployment before opening + // another beta; applying files alone leaves its rebuild pending. + const operations = db() + .prepare( + 'SELECT operation_id FROM provisioning_sources WHERE kind = ? AND source_id = ?' + ) + .all(kind, String(id)) as { operation_id: string }[]; + for (const operation of operations) finishDeployment(operation.operation_id, { ok: true }); + } + async function saveScope( scriptId: number, scopeType: 'game' | 'map' | null, @@ -77,13 +91,13 @@ describe('editing promoted script scopes', () => { waitForHealth: false, waitForMatch: false }); - await activateFiles('beta', betaId); + await activateAndCompleteFiles('beta', betaId); db() .prepare("UPDATE beta_servers SET stage = 'ready' WHERE beta_id = ?") .run(betaId); db().prepare("UPDATE betas SET state = 'ready-promote' WHERE id = ?").run(betaId); const result = await promoteBeta(betaId); - await activateFiles('campaign', result.deploymentId); + await activateAndCompleteFiles('campaign', result.deploymentId); return result; } await promote();