Download test/wrapper/batch-continuation-ui.test.cjs from VanyaJ/bada-terminal: direct link, hf CLI and curl.
- Browser
- Download file 14.3 kB
-
https://huggingface.co/VanyaJ/bada-terminal/resolve/main/test/wrapper/batch-continuation-ui.test.cjs
- Command line
-
hf download hf://VanyaJ/bada-terminal/test/wrapper/batch-continuation-ui.test.cjs
-
curl -L -o batch-continuation-ui.test.cjs https://huggingface.co/VanyaJ/bada-terminal/resolve/main/test/wrapper/batch-continuation-ui.test.cjs
14.3 kB
| // ์ค์ renderer ๋ชจ๋์ ๊ฒํ ยท์น์ธยท์ฌ๊ฐ ์ ๋ฌ ๋ฐ ๋ฆ์ ์๋ต ๊ฒฉ๋ฆฌ๋ฅผ ๊ฒ์ฆํ๋ค. | |
| // ์ค๋ช ๋ฌธ์: docs/specs/batch-step-continuation.md (v0.7.0, R67 ์งํ ์ค) | |
| const {test}=require('node:test'),assert=require('node:assert/strict'),fs=require('fs'),vm=require('vm'); | |
| function dom(){const{window,document}=require('linkedom').parseHTML('<html><body></body></html>');vm.runInNewContext(fs.readFileSync('batch-continuation.js','utf8'),{window,document});return{window,document};} | |
| const review={runId:'original',status:'reviewable',fingerprint:'a'.repeat(64),completedStepIds:['web'],remainingStepIds:['after'],costUsd:.02,loopRunId:'looprun-original',iteration:2,loopPublications:{uncertain:1,pending:0}}; | |
| for(const status of['reviewable','paused'])test('renderer identifies the retained worktree and branch before separate '+status+' action',async()=>{const{window,document}=dom(),calls=[];await window.openBatchContinuation('original',async(_c,_id,input)=>{calls.push(input.action);return{success:true,review:{...review,status,workspace:{path:'/fixture/original-worktree',branch:'bada-wt-original-batch',preserved:true}}};});assert.match(document.body.textContent,/๊ฒฉ๋ฆฌ ์์ ํด๋: \/fixture\/original-worktree/);assert.match(document.body.textContent,/๋ธ๋์น: bada-wt-original-batch/);assert.match(document.body.textContent,/์๋ ํด๋์ ๊ฒฐ๊ณผ๋ฅผ ๋ณด์กดํด ์ด์ด๊ฐ๋๋ค/);assert.match(document.body.textContent,/์ ๊ฒฉ๋ฆฌ ํด๋๋ฅผ ๋ง๋ค์ง ์์ต๋๋ค/);assert.deepEqual(calls,['review']);assert.equal(document.querySelectorAll('button')[1].hidden,status==='paused');assert.equal(document.querySelectorAll('button')[2].hidden,status!=='paused');}); | |
| for(const status of['reviewable','paused'])test('renderer explains the original scheduled occurrence without enabling automatic scheduling in '+status,async()=>{const{window,document}=dom(),calls=[];await window.openBatchContinuation('original',async(_c,_id,input)=>{calls.push(input.action);return{success:true,review:{...review,status,scheduledOccurrence:{due:0,timezone:'UTC',currentActive:0}}};});assert.match(document.body.textContent,/์์ฝ ๋ฐ์: 1970-01-01T00:00:00.000Z \(UTC\)/);assert.match(document.body.textContent,/์๋ ์์ฝ ์ํ๋ ๋ณ๊ฒฝํ์ง ์์ต๋๋ค/);assert.match(document.body.textContent,/์ต์ด ์์ฝ ์คํ์ ์คํจ ๊ธฐ๋ก์ ๋ณด์กด/);assert.deepEqual(calls,['review']);assert.equal(document.querySelectorAll('button')[1].hidden,status==='paused');assert.equal(document.querySelectorAll('button')[2].hidden,status!=='paused');}); | |
| for(const status of['reviewable','paused'])test('renderer discloses the preserved memory continue output before explicit '+status+' action',async()=>{const{window,document}=dom(),calls=[];await window.openBatchContinuation('original',async(_channel,_id,input)=>{calls.push(input.action);return{success:true,review:{...review,status,memoryContinueStepIds:['optional']}};});assert.match(document.body.textContent,/๊ณผ๊ฑฐ ๊ณ์ ์งํ ์ถ๋ ฅ: optional/);assert.match(document.body.textContent,/๋น์ ์๋น๋ ์๋ ๊ฐ์ผ๋ก ๋ณด์กด/);assert.match(document.body.textContent,/์๋ ์คํจ ์ํ๋ ์ ์ง/);assert.deepEqual(calls,['review']);assert.equal(document.querySelectorAll('button')[1].hidden,status==='paused');assert.equal(document.querySelectorAll('button')[2].hidden,status!=='paused');}); | |
| test('blocked memory output inspection stays read-only and never enables approval from its fingerprint',async()=>{const{window,document}=dom(),calls=[];await window.openBatchContinuation('original',async(_channel,_id,input)=>{calls.push(input);return input.action==='verify-continue'?{success:true,verification:{kind:'memory_continue',verifiedOutputs:2,fingerprint:'c'.repeat(64),canResume:false}}:{success:false,error:'blocked'};});const b=[...document.querySelectorAll('button')];await b.find(v=>v.textContent==='๊ณ์ ์งํ ์ถ๋ ฅ ํ์ธ').onclick();assert.match(document.body.textContent,/๊ณ์ ์งํ ์ถ๋ ฅ 2๊ฐ/);assert.match(document.body.textContent,/๋น์ ์๋น๋ ์๋ ์ถ๋ ฅ ๊ทธ๋๋ก/);assert.match(document.body.textContent,/์ด์ด๊ฐ ์ค๋น๋ ์์ง ์๋ฃ๋์ง ์์์ต๋๋ค/);assert.equal(b[1].hidden,true);assert.equal(b[2].hidden,true);assert.deepEqual(calls.map(v=>v.action),['review','verify-continue']);assert.equal(calls[1].fingerprint,undefined);}); | |
| test('memory output inspection ignores a response after closing its renderer',async()=>{const{window,document}=dom();let resolve;await window.openBatchContinuation('original',async(_channel,_id,input)=>input.action==='review'?{success:false,error:'blocked'}:new Promise(r=>resolve=r));const work=[...document.querySelectorAll('button')].find(v=>v.textContent==='๊ณ์ ์งํ ์ถ๋ ฅ ํ์ธ').onclick();document.querySelectorAll('button')[4].onclick();resolve({success:true,verification:{kind:'memory_continue',verifiedOutputs:1,fingerprint:'c'.repeat(64)}});await work;assert.equal(document.querySelector('[role=dialog]'),null);}); | |
| test('renderer distinguishes ghost archival from partial closure and requires separate explicit preparation',async()=>{const{window,document}=dom(),actions=[];await window.openBatchContinuation('original',async(_channel,_id,input)=>{actions.push(input.action);return{success:true,review:{...review,reconciledGhostIteration:true,ghostIteration:3}};});assert.match(document.body.textContent,/์์ ๊ทผ๊ฑฐ๊ฐ ์๋ 3ํ์ฐจ ํ/);assert.match(document.body.textContent,/์น์ธ ์ด๋ ฅ์ ๋ณด์กดํ๊ณ ์คํ ์์ฅ์์ ์ ์ธ/);assert.match(document.body.textContent,/๋ค์ ํ์ฐจ๋ ์๋ก ์์/);assert.doesNotMatch(document.body.textContent,/๋ถ๋ถ ๋ง๊ฐ ํ/);assert.deepEqual(actions,['review']);assert.equal(document.querySelectorAll('button')[2].hidden,true);}); | |
| test('renderer discloses independent partial-row reconciliation and preserved originals before any acceptance',async()=>{const{window,document}=dom(),actions=[];await window.openBatchContinuation('original',async(_channel,_id,input)=>{actions.push(input.action);return{success:true,review:{...review,reconciledLoopRows:true}};});assert.match(document.body.textContent,/๋ ๋ฆฝ ๊ด์ธก๊ณผ ๋์ฌํ ๋ถ๋ถ ๋ง๊ฐ ํ/);assert.match(document.body.textContent,/์๋ ํ์ ์น์ธ ๊ธฐ๋ก์ ๋ณด์กด/);assert.deepEqual(actions,['review']);assert.equal(document.querySelectorAll('button')[2].hidden,true);}); | |
| test('renderer names the reconstructed record and discloses intentional loop work, while settlement verification stays read-only',async()=>{const{window,document}=dom();await window.openBatchContinuation('original',async()=>({success:true,review:{...review,reconstructedPhase:true,reconstructedPhaseName:'๋ชฉํ ํ๊ฐ'}}));assert.match(document.body.textContent,/์๋ ๊ด์ธก์ผ๋ก ๋ณต์ํ ๊ธฐ๋ก: ๋ชฉํ ํ๊ฐ/);assert.match(document.body.textContent,/ํ์ ๋ถ์ยท๋ค์ ํ์ฐจ/);document.querySelector('[role=dialog]').parentElement.remove();const calls=[];await window.openBatchContinuation('original',async(_channel,_id,input)=>{calls.push(input.action);return input.action==='verify'?{success:true,verification:{kind:'settlement',fingerprint:'b'.repeat(64),canResume:false}}:{success:false,error:'blocked'};});await [...document.querySelectorAll('button')].find(b=>b.textContent==='์๋ ๊ด์ธก ํ์ธ').onclick();assert.match(document.body.textContent,/ํ์ฐจ ์ ์ฐ ๊ด์ธก/);assert.doesNotMatch(document.body.textContent,/undefined/);assert.equal(document.querySelectorAll('button')[1].hidden,true);assert.equal(document.querySelectorAll('button')[2].hidden,true);assert.deepEqual(calls,['review','verify']);}); | |
| test('blocked renderer exposes read-only evidence verification and never turns its fingerprint into a resume approval',async()=>{const{window,document}=dom(),calls=[];await window.openBatchContinuation('original',async(...args)=>{calls.push(args);return args[2].action==='verify'?{success:true,verification:{kind:'evaluation',goalMet:true,verifiedGoals:6,fingerprint:'b'.repeat(64),canResume:false}}:{success:false,error:'์ ์ฅ ๊ฒฐ๊ณผ๊ฐ ์์ต๋๋ค.'};});const buttons=[...document.querySelectorAll('button')],verify=buttons.find(b=>b.textContent==='์๋ ๊ด์ธก ํ์ธ');assert.ok(verify);assert.equal(verify.hidden,false);await verify.onclick();assert.match(document.body.textContent,/๋ชฉํ ๊ด์ธก 6๊ฐ/);assert.match(document.body.textContent,/์ด์ด๊ฐ ์ค๋น๋ ์์ง ์๋ฃ๋์ง ์์์ต๋๋ค/);assert.equal(buttons[1].hidden,true);assert.equal(buttons[2].hidden,true);assert.deepEqual(calls.map(c=>c[2].action),['review','verify']);assert.equal(calls[1][2].fingerprint,undefined);}); | |
| test('a closed renderer ignores a late read verification response',async()=>{const{window,document}=dom();let resolve;await window.openBatchContinuation('original',async(_channel,_id,input)=>input.action==='review'?{success:false,error:'blocked'}:new Promise(r=>resolve=r));const verify=[...document.querySelectorAll('button')].find(b=>b.textContent==='์๋ ๊ด์ธก ํ์ธ');assert.ok(verify);const pending=verify.onclick();document.querySelector('[role="dialog"]').parentElement.remove();resolve({success:true,verification:{kind:'analysis',verifiedRequests:1,fingerprint:'b'.repeat(64),canResume:false}});await pending;assert.equal(document.querySelector('[role="dialog"]'),null);}); | |
| test('the renderer prepares then separately resumes with the reviewed fingerprint, without result HTML',async()=>{ | |
| const{window,document}=dom(),calls=[];let status='reviewable',refreshes=0;await window.openBatchContinuation('original',async(...args)=>{calls.push(args);const action=args[2].action;if(action==='review')return{success:true,review:{...review,status,completedStepIds:['<img src=x onerror=alert(1)>']}};if(action==='accept')status='paused';return{success:true};},()=>{refreshes++;}); | |
| const buttons=[...document.querySelectorAll('button')];assert.match(document.body.textContent,/<img src=x/);assert.equal(document.querySelector('img'),null);assert.match(document.body.textContent,/์ด์ด๊ฐ ํ์ฐจ: 2/);assert.match(document.body.textContent,/์๋ฆผ ์ ์ถ ๋ฏธํ์ธ: 1๊ฑด/);assert.match(document.body.textContent,/ํ์ธ ๋น์ฉ: \$0.02/);assert.equal(buttons[1].hidden,false);assert.equal(buttons[2].hidden,true); | |
| await buttons[1].onclick();assert.equal(calls.length,2);assert.equal(calls[1][2].action,'accept');assert.equal(calls[1][2].fingerprint,review.fingerprint);assert.equal(refreshes,1); | |
| await buttons[0].onclick();assert.equal(buttons[2].hidden,false);await buttons[2].onclick();assert.equal(calls[3][2].action,'resume');assert.equal(refreshes,2);assert.match(document.body.textContent,/์๋ ๋ฐฐ์น๊ฐ ์๋ฃ/);buttons[4].onclick();assert.equal(document.querySelector('[role=dialog]'),null); | |
| }); | |
| test('closing a pending review prevents a late response from attaching evidence',async()=>{ | |
| const{window,document}=dom();let release;const pending=window.openBatchContinuation('original',()=>new Promise(r=>{release=r;}));document.querySelectorAll('button')[4].onclick();release({success:false,error:'LATE_PRIVATE_DETAIL'});await pending;assert.equal(document.querySelector('[role=dialog]'),null);assert.doesNotMatch(document.body.textContent,/LATE_PRIVATE_DETAIL/); | |
| }); | |
| test('an older overlapping review cannot replace a newer fingerprint or enabled action',async()=>{ | |
| const{window,document}=dom();let release;const pending=window.openBatchContinuation('original',()=>new Promise(r=>{release=r;})),first=release;const second=document.querySelector('button').onclick();release({success:true,review:{...review,status:'paused',fingerprint:'b'.repeat(64)}});await second;first({success:true,review});await pending;assert.match(document.body.textContent,/b{64}/);assert.doesNotMatch(document.body.textContent,/a{64}/);assert.equal(document.querySelectorAll('button')[2].hidden,false); | |
| }); | |
| test('a blocked prepared review offers explicit revoke with its own fingerprint and no resume action',async()=>{ | |
| const{window,document}=dom(),calls=[];await window.openBatchContinuation('original',async(...args)=>{calls.push(args);return args[2].action==='review'?{success:true,review:{...review,status:'paused',canResume:false,canRevoke:true,revokeFingerprint:'c'.repeat(64)}}:{success:true};}); | |
| const buttons=[...document.querySelectorAll('button')];assert.equal(buttons[2].hidden,true);assert.equal(buttons[3].hidden,false);await buttons[3].onclick();assert.equal(calls[1][2].action,'revoke');assert.equal(calls[1][2].fingerprint,'c'.repeat(64));assert.match(document.body.textContent,/๊ธฐ์กด ์ธ๋ถ ํจ๊ณผ์ ์คํ ๊ธฐ๋ก์ ๋ณด์กด/);assert.equal(calls.some(c=>c[2].action==='resume'),false); | |
| }); | |
| for(const archivedFirstRow of [true,false])test('renderer discloses the first real start '+(archivedFirstRow?'with preserved original row':'without inventing an original row'),async()=>{const{window,document}=dom(),actions=[];await window.openBatchContinuation('original',async(_channel,_id,input)=>{actions.push(input.action);return{success:true,review:{...review,iteration:1,completedStepIds:[],remainingStepIds:['child'],reconciledFirstIteration:true,archivedFirstRow}};});assert.match(document.body.textContent,/์ฒซ ํ์ฐจ ์คํ ์ ๊ธฐ๋ก๊ณผ ์๋ ์์ฐ/);assert.match(document.body.textContent,/1ํ์ฐจ๋ฅผ ์๋ก ์์/);if(archivedFirstRow)assert.match(document.body.textContent,/์๋ 1ํ์ฐจ ํ์ ์น์ธ ์ด๋ ฅ์ ๋ณด์กด/);else assert.doesNotMatch(document.body.textContent,/์๋ 1ํ์ฐจ ํ/);assert.doesNotMatch(document.body.textContent,/์ง์ ์๋ฃ ํ์ฐจ|๋ถ๋ถ ๋ง๊ฐ ํ/);assert.deepEqual(actions,['review']);assert.equal(document.querySelectorAll('button')[2].hidden,true);}); | |
| for(const phase of ['evaluated','analyzed','settled'])test('renderer names partial '+phase+' evidence without preparing or resuming automatically',async()=>{const{window,document}=dom(),actions=[];await window.openBatchContinuation('original',async(_channel,_id,input)=>{actions.push(input.action);return{success:true,review:{...review,reconciledLoopRows:true,reconciledLoopPhase:phase}};});assert.match(document.body.textContent,new RegExp('๋ถ๋ถ ๋ง๊ฐ ๊ธฐ์ค: '+({evaluated:'๋ชฉํ ํ๊ฐ',analyzed:'๋ฉํ ๋ถ์',settled:'ํ์ฐจ ์ ์ฐ'})[phase]));assert.match(document.body.textContent,/์๋ ํ์ ์น์ธ ๊ธฐ๋ก์ ๋ณด์กด/);assert.deepEqual(actions,['review']);assert.equal(document.querySelectorAll('button')[2].hidden,true);}); | |