wishforge-ide/apps/ide/policy/test/lifecycle-safety.test.cjs
eust-w b47a07e8d2 chore: baseline snapshot of the Codex-delivered code before review
Imports the previously untracked working tree as-is so that the review
changes that follow (requirements -> design -> implementation) can be
reviewed as diffs and reverted if needed. No content changes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-19 13:18:04 +08:00

5 lines
1.5 KiB
JavaScript

'use strict';const test=require('node:test');const assert=require('node:assert/strict');const {sleepReceipt}=require('../lifecycle-safety.cjs');
const hash='a'.repeat(64);function fixture(){return{coordinator:{inputState:()=>({activeClients:0,dirty:false,currentDiskDigest:hash,latestSnapshot:{digest:hash,revision:1}}),state:()=>({debugController:null})},processManager:{processes:new Map()},debugManager:{getAll:()=>[].values()},snapshotPending:false,hostedDebugTouched:false};}
test('quiescent saved workspace reports complete snapshots and no active processes',()=>{assert.deepEqual(sleepReceipt(fixture()),{known:true,activeClients:0,terminals:0,debugSessions:0,dirty:false,snapshotComplete:true,snapshotRevision:1,diskDigest:hash});});
test('unknown/debug/plugin activity, active terminals and incomplete snapshots never look quiescent',()=>{const f=fixture();f.processManager.processes.set(1,{});assert.equal(sleepReceipt(f).terminals,1);f.hostedDebugTouched=true;assert.equal(sleepReceipt(f).known,false);f.hostedDebugTouched=false;f.debugManager.getAll=()=>[{}].values();assert.equal(sleepReceipt(f).debugSessions,1);f.coordinator.inputState=()=>({activeClients:1,dirty:true,currentDiskDigest:hash,latestSnapshot:{digest:'b'.repeat(64),revision:1}});assert.equal(sleepReceipt(f).snapshotComplete,false);assert.equal(sleepReceipt(f).activeClients,1);assert.equal(sleepReceipt({...f,processManager:{}}).known,false);assert.equal(sleepReceipt({...f,snapshotPending:true}).known,false);});