fix(audit): match export ownership and inventory receipts in browser
This commit is contained in:
@@ -9,9 +9,9 @@ test("shell updates retain unrelated caches and the current app cache", async ()
|
||||
let activation;
|
||||
vm.runInNewContext(await readFile(new URL("../sw.js", import.meta.url), "utf8"), {
|
||||
self: { addEventListener: (type, handler) => handlers.set(type, handler), clients: { claim: async () => {} } },
|
||||
caches: { keys: async () => ["pipelines-shell-v7", "pipelines-shell-v8", "unrelated-user-cache"], delete: async (key) => deleted.push(key) },
|
||||
caches: { keys: async () => ["pipelines-shell-v8", "pipelines-shell-v9", "unrelated-user-cache"], delete: async (key) => deleted.push(key) },
|
||||
});
|
||||
handlers.get("activate")({ waitUntil: (promise) => { activation = promise; } });
|
||||
await activation;
|
||||
assert.deepEqual(deleted, ["pipelines-shell-v7"]);
|
||||
assert.deepEqual(deleted, ["pipelines-shell-v8"]);
|
||||
});
|
||||
|
||||
@@ -23,6 +23,7 @@ const rt={state,modal:createModalController(),views:{},repo:{repairSessionExport
|
||||
rt.views.chat=createChatView(rt);rt.views.dialogs=createDialogsView(rt);rt.views.runDetail=createRunDetailView(rt);
|
||||
document.querySelector('main').append(rt.views.runDetail.renderStagePane(run));rt.modal.reconcile();
|
||||
window.recordRepair=()=>{const updated={...step,session_export_repairs:[{session_id:'ses_exact',status:'complete',messages:14,html:'session-repair-1-fixed.html',html_bytes:100}],artifacts:[{name:'session-repair-1-fixed.html',url:'/artifacts/19/1/session-repair-1-fixed.html',content_type:'text/html',size_bytes:100}]};state.runDetail={...run,steps:[updated]};rt.views.dialogs.refreshStageAudit();};
|
||||
window.parkForExport=()=>{state.runDetail={...run,status:'waiting',export_pending_sequence:1,steps:[{...step,session_export_recovery:{status:'pending'}}]};rt.views.dialogs.refreshStageAudit();};
|
||||
</script>`;
|
||||
const server=createServer(async(req,res)=>{try{
|
||||
const pathname=new URL(req.url,"http://fixture").pathname;
|
||||
@@ -40,6 +41,11 @@ try{
|
||||
assert.match(await page.evaluate("document.querySelector('.audit-body').textContent"),/ses_exact is recorded/);
|
||||
assert.doesNotMatch(await page.evaluate("document.querySelector('.audit-body').textContent"),/Session not recorded|exported by model stages/);
|
||||
await page.screenshot(resolve(out,'01-recorded-identity-export-failed.png'));
|
||||
await page.evaluate('parkForExport()');
|
||||
assert.match(await page.evaluate("document.querySelector('.audit-body').textContent"),/pending recovery/);
|
||||
assert.equal(await page.evaluate("document.querySelector('.session-export-retry').disabled"),false);
|
||||
assert.equal(await page.evaluate("document.querySelectorAll('.decision-card').length"),0);
|
||||
await page.screenshot(resolve(out,'03-export-wait-is-not-a-human-decision.png'));
|
||||
await page.click('.session-export-retry');await page.waitForSelector('.audit-session-frame');
|
||||
assert.deepEqual(await page.evaluate('repairRequests'),[{id:19,sequence:1}]);
|
||||
assert.match(await page.evaluate("document.querySelector('.audit-session-frame').src"),/session-repair-1-fixed.html$/);
|
||||
|
||||
@@ -49,6 +49,24 @@ test("an original export naming another session is not selected", () => {
|
||||
assert.equal(sessionExportArtifact({session_id:"ses_stage",session_export:original,artifacts:[file("session.html")]}),null);
|
||||
});
|
||||
|
||||
test("repairs must match the original backend and directory, not just its session ID", () => {
|
||||
const original={session_id:"ses_stage",backend:"v2",directory:"/owned",status:"failed"};
|
||||
for (const override of [{backend:"pi",directory:"/owned"},{backend:"v2",directory:"/other"}]) {
|
||||
const repair={...complete("session-repair-other.html"),...override};
|
||||
const step={session_id:"ses_stage",session_export:original,session_export_repairs:[repair],artifacts:[file(repair.html)]};
|
||||
assert.equal(effectiveSessionExport(step),original);
|
||||
assert.equal(sessionExportArtifact(step),null);
|
||||
}
|
||||
});
|
||||
|
||||
test("a repair's file bytes must match its export receipt", () => {
|
||||
const original=complete("session.html");
|
||||
const repair=complete("session-repair-mismatch.html");
|
||||
const step={session_id:"ses_stage",session_export:original,session_export_repairs:[repair],artifacts:[file(original.html),{...file(repair.html),size_bytes:1}]};
|
||||
assert.equal(effectiveSessionExport(step),original);
|
||||
assert.equal(sessionExportArtifact({...step,session_export:null}),null);
|
||||
});
|
||||
|
||||
test("pre-admission failure, starting session and export recovery have distinct states", () => {
|
||||
assert.match(sessionCaptureState({model:"fixture",status:"running"}).message,/being created/);
|
||||
assert.match(sessionCaptureState({model:"fixture",status:"failed",diagnostic:"provider unreachable"}).message,/did not create.*provider unreachable/);
|
||||
|
||||
Reference in New Issue
Block a user