Perk-a-cola redesign + surface RCON map/gametype/roster/health
Themes the fleet manager around the Electric Cherry perk-a-cola from Mob of the Dead — cherry-red art-deco label with electric cyan discharge. New design tokens (Alfa Slab One + Inter + JetBrains Mono, self-hosted), full redesign of layout/dashboard/cards/detail page, tokens pass on deployments/betas/pipeline/beta/diff, cherry+lightning favicon. Lights up server data that RCON was already fetching but the UI dropped. parsePlayerRoster() extracts num/score/ping/guid/name from both status dialects. Worker persists last_map/last_gametype/last_roster/last_seen_at/ last_error (new columns with idempotent boot-time ALTERs) and emits them over SSE. Fleet cards now show health dot, map · gametype, top-3 roster preview, and last-seen. Detail page adds a sortable full roster with distinct empty-lobby vs offline states. New health classifier (online/stale/offline) drives the visual state. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
+57
-1
@@ -1,5 +1,5 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { parseInfoLine, parsePlayerCount } from '../../src/lib/server/integrations/rcon.js';
|
||||
import { parseInfoLine, parsePlayerCount, parsePlayerRoster } from '../../src/lib/server/integrations/rcon.js';
|
||||
|
||||
describe('parsePlayerCount', () => {
|
||||
it('counts rows after --- --- separator (status dialect)', () => {
|
||||
@@ -57,3 +57,59 @@ describe('parseInfoLine', () => {
|
||||
expect(parseInfoLine('nothing here')).toEqual({});
|
||||
});
|
||||
});
|
||||
|
||||
describe('parsePlayerRoster', () => {
|
||||
it('extracts num/score/ping/guid/name from print dialect', () => {
|
||||
const body = [
|
||||
'print',
|
||||
'map: mp_kino',
|
||||
'num score ping guid name',
|
||||
'--- ----- ---- -------- ----',
|
||||
' 0 12 45 aaaaaaaabbbbbbbbccccccccdddddddd joe',
|
||||
' 1 0 72 11112222333344445555666677778888 jill h.',
|
||||
' 2 999 128 abcdef0123456789abcdef0123456789 Toaster'
|
||||
].join('\n');
|
||||
const roster = parsePlayerRoster(body);
|
||||
expect(roster).toHaveLength(3);
|
||||
expect(roster[0]).toEqual({
|
||||
num: 0,
|
||||
score: 12,
|
||||
ping: 45,
|
||||
guid: 'aaaaaaaabbbbbbbbccccccccdddddddd',
|
||||
name: 'joe'
|
||||
});
|
||||
// Names with spaces stay intact
|
||||
expect(roster[1].name).toBe('jill h.');
|
||||
expect(roster[2].ping).toBe(128);
|
||||
});
|
||||
|
||||
it('extracts score/ping/quoted-name from statusResponse dialect', () => {
|
||||
const body = [
|
||||
'statusResponse',
|
||||
'\\mapname\\mp_kino\\g_gametype\\zclassic',
|
||||
'10 45 "joe"',
|
||||
'0 72 "jill h."'
|
||||
].join('\n');
|
||||
const roster = parsePlayerRoster(body);
|
||||
expect(roster).toHaveLength(2);
|
||||
expect(roster[0]).toEqual({
|
||||
num: null,
|
||||
score: 10,
|
||||
ping: 45,
|
||||
guid: null,
|
||||
name: 'joe'
|
||||
});
|
||||
expect(roster[1].name).toBe('jill h.');
|
||||
});
|
||||
|
||||
it('returns empty array when no rows are present', () => {
|
||||
const empty = [
|
||||
'print',
|
||||
'map: mp_ascension',
|
||||
'num score ping guid name',
|
||||
'--- ----- ---- -------- ----'
|
||||
].join('\n');
|
||||
expect(parsePlayerRoster(empty)).toEqual([]);
|
||||
expect(parsePlayerRoster('nonsense')).toEqual([]);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user