Add Prettier and ESLint tooling (Refs #77)

This commit is contained in:
2026-10-09 15:56:13 -04:00
parent 8ed059b8d3
commit 16469e2d43
711 changed files with 99737 additions and 28286 deletions
+36 -10
View File
@@ -5,16 +5,40 @@ import MatchPage from '../../src/routes/matches/[id]/+page.svelte';
import ChatPanel from '../../src/lib/ui/components/ChatPanel.svelte';
import type { MatchDetail } from '../../src/lib/match-history.js';
vi.mock('$app/stores', () => ({ page: writable({ url: new URL('http://localhost/matches/1'), data: { user: null } }) }));
vi.mock('$app/stores', () => ({
page: writable({ url: new URL('http://localhost/matches/1'), data: { user: null } })
}));
const match: MatchDetail = {
id: 1, server: 't5_zombie_theater_1', game: 't5', map: 'Kino Der Toten',
observedRound: 4, finalRound: 4, status: 'completed', startObserved: true,
startedAt: '2026-10-07T00:00:00Z', endedAt: '2026-10-07T00:01:00Z', durationMs: 60_000,
startPlayers: 1, uniquePlayers: 1, endPlayers: 1, players: [],
chat: [{ type: 'message', matchId: 1,
message: { time: '60:30', guid: 'abc', slot: 0, player: 'Player', message: '<script>hello</script>' },
context: { realTime: '2026-10-07T00:00:30Z', matchElapsedMs: 30_000, round: 4 } }]
id: 1,
server: 't5_zombie_theater_1',
game: 't5',
map: 'Kino Der Toten',
observedRound: 4,
finalRound: 4,
status: 'completed',
startObserved: true,
startedAt: '2026-10-07T00:00:00Z',
endedAt: '2026-10-07T00:01:00Z',
durationMs: 60_000,
startPlayers: 1,
uniquePlayers: 1,
endPlayers: 1,
players: [],
chat: [
{
type: 'message',
matchId: 1,
message: {
time: '60:30',
guid: 'abc',
slot: 0,
player: 'Player',
message: '<script>hello</script>'
},
context: { realTime: '2026-10-07T00:00:30Z', matchElapsedMs: 30_000, round: 4 }
}
]
};
describe('historical match chat', () => {
@@ -24,14 +48,16 @@ describe('historical match chat', () => {
expect(body).toContain('&lt;script>hello&lt;/script>');
expect(body).toContain('Message context');
expect(body).toContain('30s');
expect(body.replace(/<!--.*?-->/gs, '')).toMatch(/<dt>Round<\/dt><dd[^>]*>4<\/dd>/);
expect(body.replace(/<!--.*?-->/gs, '')).toMatch(/<dt>Round<\/dt>\s*<dd[^>]*>4<\/dd>/);
expect(body).not.toContain('Refresh chat');
expect(body).not.toContain('Live · 5s');
expect(body).not.toContain('Loading chat');
});
it('explains an offline host without claiming live updates or offering a manual refresh', () => {
const body = render(ChatPanel, { props: { server: 't5_zombie_theater_1', hostOffline: true, hostName: 'Dallas 1' } }).body.replaceAll(/<!--.*?-->/g, '');
const body = render(ChatPanel, {
props: { server: 't5_zombie_theater_1', hostOffline: true, hostName: 'Dallas 1' }
}).body.replaceAll(/<!--.*?-->/g, '');
expect(body).toContain('Chat resumes when Dallas 1 reconnects.');
expect(body).not.toContain('Live ·');
expect(body).not.toContain('Loading chat');