Compact autoscaling lobby rows and observation times

This commit is contained in:
2026-10-07 16:47:35 -04:00
parent 40df99c115
commit 45e9bcd4ce
4 changed files with 84 additions and 18 deletions
+20 -1
View File
@@ -1,7 +1,8 @@
import { describe, expect, it } from 'vitest';
import { render } from 'svelte/server';
import PolicyCard from '../../src/lib/ui/components/autoscaling/PolicyCard.svelte';
import { lobbyGroups, lobbyLabel, policyStatus, scalingActivity } from '../../src/lib/ui/autoscaling.js';
import { lobbyGroups, lobbyLabel, policyStatus, scalingActivity, observationAge } from '../../src/lib/ui/autoscaling.js';
import { zombieMaps } from '../../src/lib/map-aliases.js';
import type { ScalingHistory, ScalingView } from '../../src/lib/autoscaling.js';
const now = Date.parse('2026-10-07T20:00:00Z');
@@ -79,6 +80,24 @@ describe('autoscaling presentation', () => {
expect(activity[0]).toMatchObject({ operationId: 'job-1', action: 'create', at: now, lastSeenAt: now + 30, evaluations: 3, operationState: 'done' });
expect(activity[1].reason).toBe('No available game keys.');
});
it('consolidates a fully covered game into one healthy summary', () => {
const data = view();
data.unsettled = [];
data.snapshot.members = zombieMaps('t5').map(map => ({ ...data.snapshot.members[0], name: `t5_zombie_${map.slug}_1`, mapSlug: map.slug }));
data.decision = { ...data.decision, reason: 'Empty spare target is satisfied.', deficit: 0, empty: 10, pending: 0 };
const html = body(data);
expect(html).toContain('All 10 maps meet their spare target.');
expect(html).not.toContain('10 / 10 maps meet spare target');
expect(html).not.toContain('Spare targets satisfied');
expect(html.match(/<tr[ >]/g)).toHaveLength(11); // One header plus ten lobby rows.
});
it('ages observations into an explicit stale state even without fresh poll data', () => {
expect(observationAge(now - 5000, now)).toEqual({ label: '5s ago', stale: false });
expect(observationAge(now - 90000, now).stale).toBe(false);
expect(observationAge(now - 90001, now)).toEqual({ label: 'Stale · 1m ago', stale: true });
expect(observationAge(now, now + 3600000)).toEqual({ label: 'Stale · 1h ago', stale: true });
expect(observationAge(now + 5000, now)).toEqual({ label: 'Check observation time', stale: true });
});
it('renders accessible tabs and hides mutation controls from viewers', () => {
const html = body(view(), false);
expect(html).toContain('role="tablist"');