Remove standalone Activity log page (Refs #153)
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
import { describe, expect, it, vi } from 'vitest';
|
||||
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
||||
import { render } from 'svelte/server';
|
||||
import type { ComponentProps } from 'svelte';
|
||||
import { writable } from 'svelte/store';
|
||||
import { writable, type Writable } from 'svelte/store';
|
||||
import { page } from '$app/stores';
|
||||
import HostOperations from '../../src/routes/hosts/operations/+page.svelte';
|
||||
import Hosts from '../../src/routes/hosts/+page.svelte';
|
||||
import type { HostOperationSummary } from '../../src/lib/hosts.js';
|
||||
|
||||
vi.mock('$app/stores', () => ({
|
||||
@@ -11,6 +13,14 @@ vi.mock('$app/stores', () => ({
|
||||
}));
|
||||
vi.mock('$app/navigation', () => ({ beforeNavigate: vi.fn() }));
|
||||
|
||||
function setPage(path: string) {
|
||||
(page as unknown as Writable<unknown>).set({
|
||||
url: new URL(`http://localhost${path}`),
|
||||
data: { user: { role: 'viewer' } }
|
||||
});
|
||||
}
|
||||
beforeEach(() => setPage('/hosts/operations'));
|
||||
|
||||
const operation: HostOperationSummary = {
|
||||
id: 'retained-op',
|
||||
hostId: 'host-1',
|
||||
@@ -29,6 +39,58 @@ const operation: HostOperationSummary = {
|
||||
};
|
||||
|
||||
describe('host operation history presentation', () => {
|
||||
it('keeps fleet-wide operation history reachable even when all hosts have been deleted', () => {
|
||||
setPage('/hosts');
|
||||
const body = render(Hosts, {
|
||||
props: {
|
||||
data: { user: null, setupRequired: false, hosts: [], serverNow: Date.now() }
|
||||
}
|
||||
}).body;
|
||||
expect(body).toContain('href="/hosts/operations"');
|
||||
expect(body).toContain('Operation history');
|
||||
});
|
||||
|
||||
it.each([
|
||||
[
|
||||
'/hosts/operations?operation=retained-op&host=host-1&filter=all',
|
||||
'/hosts/operations?host=host-1&filter=all',
|
||||
'Back to host operation history'
|
||||
],
|
||||
[
|
||||
'/hosts/operations?operation=retained-op&returnTo=%2Fservers%2Ftown%3Ftab%3Dhistory',
|
||||
'/servers/town?tab=history',
|
||||
'Back to server'
|
||||
],
|
||||
[
|
||||
'/hosts/operations?operation=retained-op&returnTo=%2Factivity%3Fhost%3Dhost-1',
|
||||
'/hosts/operations?host=host-1',
|
||||
'Back to host operation history'
|
||||
]
|
||||
])('returns from a selected operation to existing history: %s', (path, href, label) => {
|
||||
setPage(path);
|
||||
const body = render(HostOperations, {
|
||||
props: {
|
||||
data: {
|
||||
user: null,
|
||||
setupRequired: false,
|
||||
history: {
|
||||
operations: [],
|
||||
page: 1,
|
||||
pageSize: 25,
|
||||
totalPages: 1,
|
||||
total: 0,
|
||||
filter: 'all'
|
||||
},
|
||||
scope: { operation: operation.id, host: operation.hostId },
|
||||
hostName: operation.hostName
|
||||
}
|
||||
}
|
||||
}).body;
|
||||
expect(body).toContain(`href="${href}"`);
|
||||
expect(body).toContain(label);
|
||||
expect(body).not.toContain('href="/activity');
|
||||
});
|
||||
|
||||
it('uses readable operation, server and state labels while keeping identifiers in technical detail', () => {
|
||||
const body = render(HostOperations, {
|
||||
props: {
|
||||
|
||||
Reference in New Issue
Block a user