Remove standalone Activity log page (Refs #153)
This commit is contained in:
@@ -1,10 +1,8 @@
|
||||
import { beforeEach, afterEach, expect, it, vi } from 'vitest';
|
||||
import { render } from 'svelte/server';
|
||||
import type { ComponentProps } from 'svelte';
|
||||
import { writable, type Writable } from 'svelte/store';
|
||||
import { page } from '$app/stores';
|
||||
import ActivityLog from '../../src/lib/ui/components/ActivityLog.svelte';
|
||||
import ActivityPage from '../../src/routes/activity/+page.svelte';
|
||||
import {
|
||||
activityApiHref,
|
||||
activityHistoryHref,
|
||||
@@ -13,7 +11,9 @@ import {
|
||||
} from '../../src/lib/ui/activity-history.js';
|
||||
import type { ActivityPage as ActivityReport, ActivityRow } from '../../src/lib/activity.js';
|
||||
|
||||
vi.mock('$app/stores', () => ({ page: writable({ url: new URL('http://localhost/activity') }) }));
|
||||
vi.mock('$app/stores', () => ({
|
||||
page: writable({ url: new URL('http://localhost/servers/town?tab=history') })
|
||||
}));
|
||||
vi.mock('$app/navigation', () => ({ goto: vi.fn() }));
|
||||
vi.mock('$ui/stores/fleet.js', () => ({
|
||||
fleet: writable({ servers: [], operations: [], receivedAt: 0 })
|
||||
@@ -43,7 +43,7 @@ const report = (): ActivityReport => ({
|
||||
offset: 0,
|
||||
query: { limit: 25, offset: 0 }
|
||||
});
|
||||
function scope(path = '/activity') {
|
||||
function scope(path = '/servers/town?tab=history') {
|
||||
(page as unknown as Writable<{ url: URL }>).set({ url: new URL(`http://localhost${path}`) });
|
||||
}
|
||||
beforeEach(() => {
|
||||
@@ -62,7 +62,7 @@ it.each([
|
||||
['90', '90', 'Last 90 days'],
|
||||
['14', '14', 'Last 14 days']
|
||||
])('selects the current date range for days=%s on desktop and mobile', (days, value, label) => {
|
||||
scope(days ? `/activity?days=${days}` : '/activity');
|
||||
scope(days ? `/servers/town?tab=history&days=${days}` : '/servers/town?tab=history');
|
||||
const body = render(ActivityLog, { props: { initial: report() } }).body;
|
||||
for (const suffix of ['', '-mobile']) {
|
||||
const select = body.match(
|
||||
@@ -88,7 +88,8 @@ it('sends only supported normalized filters and enforces scoped identities', ()
|
||||
expect(params.has('tab')).toBe(false);
|
||||
expect(params.has('returnTo')).toBe(false);
|
||||
expect(
|
||||
activityQuery(new URL('https://example.test/activity?type=unknown&days=0')).type
|
||||
activityQuery(new URL('https://example.test/servers/town?tab=history&type=unknown&days=0'))
|
||||
.type
|
||||
).toBeUndefined();
|
||||
});
|
||||
|
||||
@@ -112,7 +113,9 @@ it('resets pagination when filtering and preserves the containing page, hash, an
|
||||
});
|
||||
|
||||
it('keeps provisioning excluded from log polling after filtering or clearing filters', () => {
|
||||
const url = new URL('http://localhost/activity?type=create&excludeProvisioning=false');
|
||||
const url = new URL(
|
||||
'http://localhost/servers/town?tab=history&type=create&excludeProvisioning=false'
|
||||
);
|
||||
const scope = { excludeProvisioning: true };
|
||||
expect(new URL(activityApiHref(url, scope), url).searchParams.get('excludeProvisioning')).toBe(
|
||||
'true'
|
||||
@@ -125,7 +128,9 @@ it('keeps provisioning excluded from log polling after filtering or clearing fil
|
||||
});
|
||||
|
||||
it('keeps maintenance excluded from log polling while preserving the Maintenance history scope', () => {
|
||||
const url = new URL('http://localhost/activity?source=maintenance&excludeMaintenance=false');
|
||||
const url = new URL(
|
||||
'http://localhost/servers/town?tab=history&source=maintenance&excludeMaintenance=false'
|
||||
);
|
||||
const logScope = { excludeProvisioning: true, excludeMaintenance: true };
|
||||
expect(
|
||||
new URL(activityApiHref(url, logScope), url).searchParams.get('excludeMaintenance')
|
||||
@@ -155,39 +160,8 @@ it('shows relative recent timestamps and preserves accurate older dates and inva
|
||||
);
|
||||
});
|
||||
|
||||
it('renders one page heading with provisioning management and filters removed', () => {
|
||||
const body = render(ActivityPage, {
|
||||
props: {
|
||||
data: {
|
||||
activity: report(),
|
||||
user: { role: 'admin' },
|
||||
setupRequired: false
|
||||
} as ComponentProps<typeof ActivityPage>['data']
|
||||
}
|
||||
}).body;
|
||||
expect(body.match(/<h1[ >]/g)).toHaveLength(1);
|
||||
expect(body).not.toContain('Manage servers');
|
||||
expect(body).not.toContain('href="/provisioning"');
|
||||
expect(body).not.toContain('<option value="create"');
|
||||
expect(body).not.toContain('<option value="provisioning"');
|
||||
expect(body).not.toContain('<option value="restart"');
|
||||
for (const value of ['update', 'health', 'maintenance', 'recovery'])
|
||||
expect(body).not.toContain(`<option value="${value}"`);
|
||||
expect(body).toContain('<option value="drift"');
|
||||
const viewer = render(ActivityPage, {
|
||||
props: {
|
||||
data: {
|
||||
activity: report(),
|
||||
user: { role: 'viewer' },
|
||||
setupRequired: false
|
||||
} as ComponentProps<typeof ActivityPage>['data']
|
||||
}
|
||||
}).body;
|
||||
expect(viewer).not.toContain('Manage servers');
|
||||
});
|
||||
|
||||
it('renders named operation links, shared source memberships, friendly resources, and one freshness indicator', () => {
|
||||
scope('/activity?state=succeeded&offset=25');
|
||||
scope('/servers/town?tab=history&state=succeeded&offset=25');
|
||||
const data = report();
|
||||
data.offset = 25;
|
||||
const body = render(ActivityLog, { props: { initial: data } }).body;
|
||||
@@ -199,7 +173,7 @@ it('renders named operation links, shared source memberships, friendly resources
|
||||
expect(body).toContain('shape-circle');
|
||||
expect(body).toContain('15 s ago');
|
||||
expect(body).toContain('datetime="2026-10-07T17:59:45Z"');
|
||||
expect(body).toContain('returnTo=%2Factivity');
|
||||
expect(body).toContain('returnTo=%2Fservers%2Ftown%3Ftab%3Dhistory');
|
||||
expect(body).toContain('state%3Dsucceeded');
|
||||
expect(body).toContain('offset%3D25');
|
||||
expect(body).toContain('26–26 of 52');
|
||||
@@ -209,6 +183,7 @@ it('renders named operation links, shared source memberships, friendly resources
|
||||
});
|
||||
|
||||
it('preserves deleted server evidence without linking to a replacement instance', () => {
|
||||
scope('/maintenance?view=activity');
|
||||
const data = report();
|
||||
data.rows = [{ ...row, serverDeletedAt: '2026-10-07T17:59:46Z' }];
|
||||
const body = render(ActivityLog, { props: { initial: data } }).body;
|
||||
@@ -239,7 +214,7 @@ it('offers one mobile filter sheet with distinct IDs and hides fixed scope contr
|
||||
});
|
||||
|
||||
it('offers useful empty and out-of-range page recovery', () => {
|
||||
scope('/activity?q=missing&offset=100');
|
||||
scope('/servers/town?tab=history&q=missing&offset=100');
|
||||
const data = report();
|
||||
data.rows = [];
|
||||
data.offset = 100;
|
||||
|
||||
Reference in New Issue
Block a user