feat: integrate pinned original Purge with host execution gates
This commit is contained in:
@@ -4,6 +4,26 @@ import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
import http from 'node:http';
|
||||
import { fixture, launchWorkbench, compatibleFixture, until, assertToolPairs } from './helpers.mjs';
|
||||
import { createSessionPublisher } from '../src/server/app.mjs';
|
||||
|
||||
test('large source receipts use cursor-preserving invalidation without filling the event stream or changing the session', () => {
|
||||
const session = { id: 'owned-session', projectId: 'owned-project', revision: 10, eventSeq: 42, source: '汉'.repeat(24000) };
|
||||
let queued = 0, destroyed = false; const chunks = [];
|
||||
const response = { get writableLength() { return queued; }, write(value) { queued += Buffer.byteLength(value); chunks.push(value); }, destroy() { destroyed = true; } };
|
||||
const publish = createSessionPublisher(new Set([response]));
|
||||
for (let i = 0; i < 100; i++) publish(session);
|
||||
assert.equal(destroyed, false); assert.ok(queued < 64 * 1024);
|
||||
assert.ok(chunks.every(value => value.startsWith('id: 42\ndata: ')));
|
||||
assert.deepEqual(JSON.parse(chunks[0].split('\ndata: ')[1]), { kind: 'session_changed', seq: 42, sessionId: session.id, projectId: session.projectId, revision: 10 });
|
||||
assert.equal(session.source, '汉'.repeat(24000)); assert.equal(session.eventSeq, 42);
|
||||
});
|
||||
|
||||
test('small event updates retain the current session and actual cursor', () => {
|
||||
const session = { id: 'owned-small', projectId: 'owned-project', revision: 3, eventSeq: 7, status: 'awaiting_approval' }, chunks = [];
|
||||
createSessionPublisher(new Set([{ write(value) { chunks.push(value); } }]))(session);
|
||||
assert.deepEqual(JSON.parse(chunks[0].split('\ndata: ')[1]), { kind: 'session', seq: 7, session });
|
||||
assert.ok(chunks[0].startsWith('id: 7\n'));
|
||||
});
|
||||
|
||||
test('the bundled local service enforces host, origin, token and JSON object contracts', async t => {
|
||||
const f = fixture(t), server = await launchWorkbench(t, f.data); f.onCleanup(server.close);
|
||||
|
||||
Reference in New Issue
Block a user