Fix fleet stale-status flicker during polling

This commit is contained in:
2026-09-18 15:11:49 -04:00
parent f54cac8c50
commit 6d903adb31
6 changed files with 59 additions and 12 deletions
+3 -3
View File
@@ -30,14 +30,14 @@ describe('Fleet discovery and match freshness', () => {
expect(fleetIdentity({ ...server, game_mode: 'mp' }).launch).toBeNull();
});
it('does not classify stale, missing, or starting occupancy as an empty lobby', () => {
for (const change of [{ last_seen_at: iso(-31_000) }, { last_players: null }, { health: 'starting' as const }, { health: 'offline' as const }]) {
for (const change of [{ last_seen_at: iso(-46_000) }, { last_players: null }, { health: 'starting' as const }, { health: 'offline' as const }]) {
expect(matchesFleet({ ...server, last_players: 0, ...change }, '', 'empty', '', [], [], now)).toBe(false);
}
expect(matchesFleet({ ...server, last_players: 0 }, '', 'empty', '', [], [], now)).toBe(true);
expect(matchesFleet(server, '', 'occupied', 't5', [], [], now)).toBe(false);
});
it('includes stale health and failed operations in attention without flagging normal startup', () => {
expect(matchesFleet({ ...server, last_seen_at: iso(-31_000) }, '', 'attention', '', [], [], now)).toBe(true);
expect(matchesFleet({ ...server, last_seen_at: iso(-46_000) }, '', 'attention', '', [], [], now)).toBe(true);
expect(matchesFleet(server, '', 'attention', '', [], [{ ...operation, state: 'attention' }], now)).toBe(true);
expect(matchesFleet({ ...server, health: 'starting' }, '', 'attention', '', [], [], now)).toBe(false);
});
@@ -59,7 +59,7 @@ describe('one-shot lobby watches', () => {
expect(watchSatisfied(watch, { ...server, last_players: 0 }, [], now)).toBe(true);
expect(watchSatisfied(watch, undefined, [], now)).toBe(false);
expect(watchSatisfied(watch, { ...server, last_players: null }, [], now)).toBe(false);
expect(watchSatisfied(watch, { ...server, last_players: 0, last_seen_at: iso(-31_000) }, [], now)).toBe(false);
expect(watchSatisfied(watch, { ...server, last_players: 0, last_seen_at: iso(-46_000) }, [], now)).toBe(false);
});
it('only completes the watched operation on explicit success', () => {
const watch = { id: 'op', server: server.name, kind: 'operation' as const, operationKey: operation.key, href: '/' };