Unify retained operation history in Activity
This commit is contained in:
@@ -4,12 +4,10 @@ import { writable } from 'svelte/store';
|
||||
import { get } from 'svelte/store';
|
||||
import type { ComponentProps } from 'svelte';
|
||||
import type { GameTelemetry } from '../../src/lib/telemetry.js';
|
||||
import type { FleetOperation } from '../../src/lib/fleet-overview.js';
|
||||
import ServerPage from '../../src/routes/servers/[name]/+page.svelte';
|
||||
import PlayerScoreboard from '../../src/lib/ui/components/PlayerScoreboard.svelte';
|
||||
import ConfigInspector from '../../src/lib/ui/components/ConfigInspector.svelte';
|
||||
import { uiNow } from '../../src/lib/ui/stores/servers.js';
|
||||
import { instanceActivity } from '../../src/lib/ui/server-activity.js';
|
||||
import { gameEvent } from '../helpers/telemetry.js';
|
||||
import { page } from '$app/stores';
|
||||
|
||||
@@ -57,18 +55,8 @@ it('omits the fixed instance selector while keeping promoted/live distinction',
|
||||
expect(body).toContain('Live files and active betas may differ');
|
||||
});
|
||||
|
||||
const op = (changes: Partial<FleetOperation> = {}): FleetOperation => ({ key: 'deployment:1', group: 'deployment:1', server: 'one', kind: 'deployment', label: 'Complete', activityLabel: 'Restart instance', resultState: 'cancelled', detail: 'Checking game status', href: '/provisioning/1', state: 'done', startedAt: '2026-10-06T12:00:00Z', ...changes });
|
||||
it('merges duplicate campaign records, retains provisioning and preserves the real outcome', () => {
|
||||
const rows = instanceActivity('one', [op(), op({ key: 'campaign:x:one', kind: 'campaign', href: '/campaigns/x' }), op({ key: 'other', server: 'two' })], [{
|
||||
id: 'x', action: 'promote', started_at: '2026-10-06T13:00:00Z', servers: [{ server: 'one', restart_state: 'failed', error: 'Restart failed', files_changed: 1 }]
|
||||
}]);
|
||||
expect(rows).toHaveLength(2);
|
||||
expect(rows[0]).toMatchObject({ label: 'Promote files · 1 file', state: 'failed', detail: 'Restart failed' });
|
||||
expect(rows[1]).toMatchObject({ label: 'Restart instance', state: 'cancelled', href: '/provisioning/1' });
|
||||
});
|
||||
|
||||
function pageBody(tab: string) {
|
||||
(page as unknown as ReturnType<typeof writable>).set({ 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: 'admin' } }, 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',
|
||||
@@ -79,7 +67,7 @@ function pageBody(tab: string) {
|
||||
}
|
||||
it('keeps match content out of the shared header and preserves the fleet return filter', () => {
|
||||
const body = pageBody('configuration');
|
||||
expect(body).toContain('Instance actions');
|
||||
expect(body).toContain('More actions');
|
||||
expect(body).toContain('href="/?filter=occupied"');
|
||||
expect(body).toContain('ec-1');
|
||||
expect(body).not.toContain('Active for');
|
||||
@@ -96,3 +84,10 @@ it('reports RCON failures independently of fresh telemetry and defers the reques
|
||||
expect(body).not.toContain('Telemetry API requests');
|
||||
expect(body).not.toContain('>Healthy<');
|
||||
});
|
||||
|
||||
it('uses the shared Activity view for server history', () => {
|
||||
const body = pageBody('history');
|
||||
expect(body).toContain('Open in Activity');
|
||||
expect(body).not.toContain('Loading campaign history');
|
||||
expect(body).not.toContain('>Provisioning history</a>');
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user