Improve application responsiveness and background processing
This commit is contained in:
@@ -67,6 +67,34 @@ async function setup() {
|
||||
}
|
||||
|
||||
describe('Fleet report clock', () => {
|
||||
it('accepts newer navigation snapshots while keeping stream evidence newer than the snapshot', async () => {
|
||||
const { fleetServers, hydrateFleet } = await setup();
|
||||
await vi.advanceTimersByTimeAsync(2000);
|
||||
emit(epoch + 2000, [status(epoch + 2000, { players: 3 })]);
|
||||
const integrations = { rcon: true, komodo: false, rconTimeoutMs: 3000, defaultRconHost: '' };
|
||||
hydrateFleet({ serverNow: epoch + 1000, servers: [server(epoch + 1000), server(epoch, { name: 'two' })], operations: [], integrations });
|
||||
expect(get(fleetServers)).toHaveLength(2);
|
||||
expect(get(fleetServers)[0].last_players).toBe(3);
|
||||
hydrateFleet({ serverNow: epoch, servers: [], operations: [], integrations });
|
||||
expect(get(fleetServers)).toHaveLength(2);
|
||||
});
|
||||
it('merges partial events without dropping other servers or repainting unchanged elapsed ticks', async () => {
|
||||
snapshot.servers = [server(), server(epoch, { name: 'two' })];
|
||||
const { fleetServers, statusByServer } = await setup();
|
||||
emit(epoch, [status(epoch), status(epoch, { server: 'two' })]);
|
||||
await vi.advanceTimersByTimeAsync(1000);
|
||||
source.dispatchEvent(new MessageEvent('server-status', { data: JSON.stringify({
|
||||
delta: true, serverNow: epoch + 1000, entries: [status(epoch + 1000, { players: 2 })]
|
||||
}) }));
|
||||
expect(get(statusByServer).size).toBe(2);
|
||||
expect(get(fleetServers).find(server => server.name === 't5_zombie_theater_1')?.last_players).toBe(2);
|
||||
const changes = vi.fn();
|
||||
const unsubscribe = fleetServers.subscribe(changes);
|
||||
changes.mockClear();
|
||||
await vi.advanceTimersByTimeAsync(5000);
|
||||
expect(changes).not.toHaveBeenCalled();
|
||||
unsubscribe();
|
||||
});
|
||||
it('keeps persisted occupancy and match anchors through live reports before the next status poll', async () => {
|
||||
const at = (seconds: number) => new Date(epoch + seconds * 1000).toISOString();
|
||||
snapshot.servers = [server(epoch, { container_state: 'running', container_checked_at: at(0) })];
|
||||
|
||||
Reference in New Issue
Block a user