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
+6 -6
View File
@@ -89,20 +89,20 @@ describe('automatic host preparation', () => {
});
expect(operations(host.id)).toEqual([]);
const firstPoll = await pollOperations({ request: request('operations') }).json();
const firstPoll = await (await pollOperations({ request: request('operations') })).json();
expect(firstPoll.operations).toHaveLength(1);
const runtimeOperation = firstPoll.operations[0];
expect(runtimeOperation).toMatchObject({ kind: 'runtime.pull', payload: { image: runtime } });
expect((await pollOperations({ request: request('operations') }).json()).operations).toEqual([runtimeOperation]);
expect((await (await pollOperations({ request: request('operations') })).json()).operations).toEqual([runtimeOperation]);
const version = await publish();
expect((await pollOperations({ request: request('operations') }).json()).operations).toEqual([runtimeOperation]);
expect((await (await pollOperations({ request: request('operations') })).json()).operations).toEqual([runtimeOperation]);
vi.setSystemTime(Date.now() + 1);
const completedRuntime = await reportOperation({
request: request(`operations/${runtimeOperation.id}`, { state: 'completed' }), params: { id: runtimeOperation.id }
});
expect(completedRuntime.status).toBe(200);
expect((await pollOperations({ request: request('operations') }).json()).operations).toEqual([]);
expect((await (await pollOperations({ request: request('operations') })).json()).operations).toEqual([]);
expect(operations(host.id)).toHaveLength(1);
vi.setSystemTime(Date.now() + 1);
@@ -113,7 +113,7 @@ describe('automatic host preparation', () => {
const download = operations(host.id)[0];
expect(download).toMatchObject({ kind: 'library.download', payload: { libraryVersionId: version.id } });
expect((await reportHeartbeat({ request: request('heartbeat', { inventory: preparedInventory }) })).status).toBe(200);
expect((await pollOperations({ request: request('operations') }).json()).operations).toEqual([download]);
expect((await (await pollOperations({ request: request('operations') })).json()).operations).toEqual([download]);
expect(operations(host.id)).toHaveLength(2);
vi.setSystemTime(Date.now() + 1);
@@ -129,7 +129,7 @@ describe('automatic host preparation', () => {
expect(finalHeartbeat.status).toBe(200);
expect(libraries.requireReadyLibrary(host.id, version.id).id).toBe(version.id);
expect(preparation.hostPreparationStatus(hosts.getHost(host.id)!).state).toBe('ready');
expect((await pollOperations({ request: request('operations') }).json()).operations).toEqual([]);
expect((await (await pollOperations({ request: request('operations') })).json()).operations).toEqual([]);
expect(operations(host.id)).toHaveLength(2);
});