Add Prettier and ESLint tooling (Refs #77)
This commit is contained in:
@@ -11,20 +11,44 @@ import { uiNow } from '../../src/lib/ui/stores/servers.js';
|
||||
import { gameEvent } from '../helpers/telemetry.js';
|
||||
import { page } from '$app/stores';
|
||||
|
||||
vi.mock('$app/state', () => ({ page: { url: new URL('http://localhost/servers/t5_zombie_theater_1') } }));
|
||||
vi.mock('$app/stores', () => ({ page: writable({ params: { name: 't5_zombie_theater_1' }, url: new URL('http://localhost/servers/t5_zombie_theater_1') }) }));
|
||||
vi.mock('$app/navigation', () => ({ beforeNavigate: vi.fn(), afterNavigate: vi.fn(), goto: vi.fn() }));
|
||||
vi.mock('$app/state', () => ({
|
||||
page: { url: new URL('http://localhost/servers/t5_zombie_theater_1') }
|
||||
}));
|
||||
vi.mock('$app/stores', () => ({
|
||||
page: writable({
|
||||
params: { name: 't5_zombie_theater_1' },
|
||||
url: new URL('http://localhost/servers/t5_zombie_theater_1')
|
||||
})
|
||||
}));
|
||||
vi.mock('$app/navigation', () => ({
|
||||
beforeNavigate: vi.fn(),
|
||||
afterNavigate: vi.fn(),
|
||||
goto: vi.fn()
|
||||
}));
|
||||
|
||||
const report = (current = true): GameTelemetry => {
|
||||
const receivedAt = new Date(get(uiNow) - (current ? 10_000 : 300_000)).toISOString();
|
||||
const joined = new Date(Date.parse(receivedAt) - 60_000).toISOString();
|
||||
return { ...gameEvent('heartbeat', 4, 1), receivedAt, timing: { matchId: 1, players: {
|
||||
'12345678901234560': { serverJoinedAt: joined, matchJoinedAt: joined, roundStarted: 1 }
|
||||
} } };
|
||||
return {
|
||||
...gameEvent('heartbeat', 4, 1),
|
||||
receivedAt,
|
||||
timing: {
|
||||
matchId: 1,
|
||||
players: {
|
||||
'12345678901234560': {
|
||||
serverJoinedAt: joined,
|
||||
matchJoinedAt: joined,
|
||||
roundStarted: 1
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
it('keeps scoreboard columns focused and collapses player identifiers and timings', () => {
|
||||
const body = render(PlayerScoreboard, { props: { report: report(), matchElapsed: '4m 19s' } }).body;
|
||||
const body = render(PlayerScoreboard, {
|
||||
props: { report: report(), matchElapsed: '4m 19s' }
|
||||
}).body;
|
||||
expect(body).toContain('Live scoreboard');
|
||||
expect(body).toContain('Round 4');
|
||||
expect(body).toContain('Match 4m 19s');
|
||||
@@ -45,7 +69,9 @@ it('freezes historical timing and keeps unreported scores distinct from zero', (
|
||||
expect(body).toContain('Time on instance: 1m 00s');
|
||||
expect(body).not.toContain('Time on instance: 6m');
|
||||
const start = { ...gameEvent('game_start', 0, 1), receivedAt: report().receivedAt };
|
||||
expect(render(PlayerScoreboard, { props: { report: start } }).body).toContain('aria-label="Not yet reported"');
|
||||
expect(render(PlayerScoreboard, { props: { report: start } }).body).toContain(
|
||||
'aria-label="Not yet reported"'
|
||||
);
|
||||
});
|
||||
|
||||
it('omits the fixed instance selector while keeping promoted/live distinction', () => {
|
||||
@@ -56,13 +82,45 @@ it('omits the fixed instance selector while keeping promoted/live distinction',
|
||||
});
|
||||
|
||||
function pageBody(tab: string, role = 'admin') {
|
||||
(page as unknown as ReturnType<typeof writable>).set({ data: { user: { role } }, params: { name: 't5_zombie_theater_1' }, url: new URL(`http://localhost/servers/t5_zombie_theater_1?tab=${tab}&returnTo=%2F%3Ffilter%3Doccupied`) });
|
||||
(page as unknown as ReturnType<typeof writable>).set({
|
||||
data: { user: { role } },
|
||||
params: { name: 't5_zombie_theater_1' },
|
||||
url: new URL(
|
||||
`http://localhost/servers/t5_zombie_theater_1?tab=${tab}&returnTo=%2F%3Ffilter%3Doccupied`
|
||||
)
|
||||
});
|
||||
const telemetry = report();
|
||||
const server = { name: 't5_zombie_theater_1', game: 't5', map: 'zombie_theater', last_map: 'zombie_theater', health: 'online', last_players: 1,
|
||||
last_seen_at: telemetry.receivedAt, last_error: null, held: [], telemetry, status_source: 'telemetry', host_id: 'host-1', native_instance_id: 'instance-1',
|
||||
host: { name: 'ec-1', connected: true, lastHeartbeat: telemetry.receivedAt }, replySnippet: 'legacy private reply 192.0.2.123:28960',
|
||||
rcon_status: { last_seen_at: null, last_error: 'timeout: no reply' }, game_started_at: null, game_ended_at: null, active_since: null, inactive_since: null };
|
||||
const data = { serverSnapshot: { servers: [server], operations: [], serverNow: get(uiNow), integrations: {}, reservedNames: [] } } as unknown as ComponentProps<typeof ServerPage>['data'];
|
||||
const server = {
|
||||
name: 't5_zombie_theater_1',
|
||||
game: 't5',
|
||||
map: 'zombie_theater',
|
||||
last_map: 'zombie_theater',
|
||||
health: 'online',
|
||||
last_players: 1,
|
||||
last_seen_at: telemetry.receivedAt,
|
||||
last_error: null,
|
||||
held: [],
|
||||
telemetry,
|
||||
status_source: 'telemetry',
|
||||
host_id: 'host-1',
|
||||
native_instance_id: 'instance-1',
|
||||
host: { name: 'ec-1', connected: true, lastHeartbeat: telemetry.receivedAt },
|
||||
replySnippet: 'legacy private reply 192.0.2.123:28960',
|
||||
rcon_status: { last_seen_at: null, last_error: 'timeout: no reply' },
|
||||
game_started_at: null,
|
||||
game_ended_at: null,
|
||||
active_since: null,
|
||||
inactive_since: null
|
||||
};
|
||||
const data = {
|
||||
serverSnapshot: {
|
||||
servers: [server],
|
||||
operations: [],
|
||||
serverNow: get(uiNow),
|
||||
integrations: {},
|
||||
reservedNames: []
|
||||
}
|
||||
} as unknown as ComponentProps<typeof ServerPage>['data'];
|
||||
return render(ServerPage, { props: { data } }).body;
|
||||
}
|
||||
it('keeps match content out of the shared header and preserves the fleet return filter', () => {
|
||||
|
||||
Reference in New Issue
Block a user