Improve application responsiveness and background processing

This commit is contained in:
2026-10-04 19:56:06 -04:00
parent 1392a082da
commit ed004ddbcf
70 changed files with 1324 additions and 345 deletions
+18
View File
@@ -15,6 +15,24 @@ async function enrolled() {
}
describe('native host enrollment and scoped authentication', () => {
it('separates observation and mutation delivery and wakes long polls on newly queued work', async () => {
const api = await enrolled();
const inspect = api.queueHostOperation(api.host.id, 'host.inspect', {});
const restart = api.queueHostOperation(api.host.id, 'instance.restart', {});
const status = api.queueHostOperation(api.host.id, 'rcon.execute', { command: 'status' });
const command = api.queueHostOperation(api.host.id, 'rcon.execute', { command: 'map_restart' });
expect(api.pendingHostOperations(api.host.id, 'read').map(op => op.id).sort()).toEqual([inspect.id, status.id].sort());
expect(api.pendingHostOperations(api.host.id, 'write').map(op => op.id).sort()).toEqual([restart.id, command.id].sort());
// Let earlier enqueue notifications finish before subscribing.
await Promise.resolve();
const controller = new AbortController();
const waiting = api.waitForHostWork(api.host.id, controller.signal, 20_000);
api.queueHostOperation(api.host.id, 'host.inspect', {});
await waiting;
const aborted = api.waitForHostWork(api.host.id, controller.signal, 20_000);
controller.abort();
await aborted;
});
it('consumes an enrollment exactly once and stores only credential hashes', async () => {
const api = await enrolled();
expect(api.authenticateCredential(api.credentials.credential)?.id).toBe(api.host.id);