Show live match links and elapsed time (Refs #115)
CI / checks (push) Successful in 5m0s

This commit is contained in:
2026-10-09 23:47:46 -04:00
parent 3e0b4db736
commit a0663e43b8
2 changed files with 69 additions and 13 deletions
+38
View File
@@ -103,6 +103,43 @@ it('keeps mobile filters and sorting in one labelled sheet with distinct control
expect(new Set(ids).size).toBe(ids.length);
expect(body).toContain('Updates every 10 seconds');
});
it('links in-progress matches to their live server with the current filters and page', () => {
scope('?matchGame=t6&matchPage=2&matchStatus=active');
const data = report();
data.matches = [
{ ...match, server: 'Weekend lobby #1', status: 'active', endedAt: null, durationMs: null }
];
const body = render(MatchHistory, { props: { initial: data } }).body;
const rows = body.slice(body.indexOf('<tbody'), body.indexOf('</tbody>'));
expect(rows.match(/<a\b/g)).toHaveLength(1);
expect(rows).toContain(
'href="/servers/Weekend%20lobby%20%231?returnTo=%2Fmatches%3FmatchGame%3Dt6%26matchPage%3D2%26matchStatus%3Dactive"'
);
expect(rows).toContain('aria-label="View live Town Survival match on Weekend lobby #1');
expect(rows).not.toContain('href="/matches/1');
data.matches[0].server_deleted_at = '2026-10-06T19:59:00Z';
const deleted = render(MatchHistory, { props: { initial: data } }).body;
expect(deleted).not.toContain('href="/servers/');
expect(deleted).toContain('Historical instance');
});
it.each([
['2026-10-06T19:59:48Z', '12s'],
['2026-10-06T19:36:28Z', '23m 32s'],
['2026-10-06T18:20:00Z', '1h 40m'],
['2026-10-06 19:36:28', '23m 32s'],
['2026-10-06T20:00:05Z', '0s']
])('shows running time from %s on desktop and mobile', (startedAt, duration) => {
const data = report();
data.matches = [{ ...match, status: 'active', startedAt, endedAt: null, durationMs: null }];
const body = render(MatchHistory, { props: { initial: data } }).body.replaceAll(
/<!--.*?-->/g,
''
);
expect(body).toContain(`In progress · ${duration}</small>`);
expect(body).toContain(`<span>${duration}</span>`);
expect(body).not.toContain('Duration was not recorded.');
});
it('labels unfinished rounds and missing durations without inventing final results or detail links', () => {
const data = report();
data.matches = [
@@ -112,6 +149,7 @@ it('labels unfinished rounds and missing durations without inventing final resul
expect(body).toContain('Interrupted');
expect(body).toContain('Highest observed');
expect(body).not.toContain('href="/matches/1');
expect(body).not.toContain('href="/servers/');
expect(body).toContain('>—</span>');
expect(body).toContain('>0</td>');
});