mirror of
https://github.com/pewdiepie-archdaemon/odysseus.git
synced 2026-10-06 15:02:20 +02:00
Snapshot current maintainer-preview application changes and regression fixtures for integration into lab. Excludes local runtime data, evaluation outputs and source backups. Focused Python regression selection: 140 passed; full suite not certified.
25 lines
1.0 KiB
JavaScript
25 lines
1.0 KiB
JavaScript
import test from 'node:test';
|
|
import assert from 'node:assert/strict';
|
|
import {readEmailReplyResponse} from '../static/js/emailReplyStream.js';
|
|
|
|
const response = frames => new Response(frames.map(f => `data: ${JSON.stringify(f)}\n\n`).join(''),
|
|
{headers: {'content-type': 'text/event-stream'}});
|
|
|
|
test('streams body then requires successful terminal result', async () => {
|
|
const seen = [];
|
|
const result = await readEmailReplyResponse(response([
|
|
{type:'reply', text:'Hi'}, {type:'reply', text:'Hi Jonathan'},
|
|
{type:'result', success:true, reply:'Hi Jonathan'},
|
|
]), text => seen.push(text));
|
|
assert.deepEqual(seen, ['Hi', 'Hi Jonathan']);
|
|
assert.equal(result.success, true);
|
|
});
|
|
|
|
test('editing the draft stops streaming insertion', async () => {
|
|
await assert.rejects(readEmailReplyResponse(response([{type:'reply', text:'Hi'}]), () => false), /edited or closed/);
|
|
});
|
|
|
|
test('disconnect is not a completed draft', async () => {
|
|
await assert.rejects(readEmailReplyResponse(response([{type:'reply', text:'Hi'}]), () => {}), /before completion/);
|
|
});
|