Files
pipelines/web/test/chatInteractions.test.mjs
T

29 lines
1.5 KiB
JavaScript

import test from 'node:test';
import assert from 'node:assert/strict';
import { applyChatForm, applyChatPermission, chatApprovalCards, chatPendingForms, approvalCard } from '../src/chat.js';
test('parallel approvals stay independently actionable and resolve by identity',()=>{
let thread={};
for(const id of ['a','b']) thread=applyChatPermission(thread,{session_id:'s',request_id:id,action:'shell'});
assert.deepEqual(chatApprovalCards(thread).map(c=>c.requestId),['a','b']);
thread=applyChatPermission(thread,{session_id:'s',request_id:'a',resolved:true});
assert.deepEqual(chatApprovalCards(thread).map(c=>c.requestId),['b']);
thread=applyChatPermission(thread,{session_id:'s',request_id:'b',resolved:true});
assert.deepEqual(chatApprovalCards(thread),[]);
});
test('Codex session-scoped approval is never described as a permanent grant',()=>{
const card=approvalCard({request_id:'a',always_label:'Allow for session',resolved:true,decision:'always'},'');
assert.equal(card.headline,'Allowed for session');
});
test('parallel questions survive replies and cancellation of a different question',()=>{
let thread={};
for(const id of ['a','b']) thread=applyChatForm(thread,{id,session_id:'s',fields:[]});
assert.deepEqual(chatPendingForms(thread).map(f=>f.id),['a','b']);
thread=applyChatForm(thread,{id:'a',resolved:true});
assert.deepEqual(chatPendingForms(thread).map(f=>f.id),['b']);
thread=applyChatForm(thread,{id:'b',cancelled:true});
assert.deepEqual(chatPendingForms(thread),[]);
});