feat(ui): ship offline operations cutover

This commit is contained in:
master
2026-03-08 03:12:01 +02:00
parent 93872e73ec
commit ff9de893d5
26 changed files with 1055 additions and 92 deletions

View File

@@ -0,0 +1,167 @@
import { expect, test, type Page, type Route } from '@playwright/test';
import type { StubAuthSession } from '../../src/app/testing/auth-fixtures';
const adminSession: StubAuthSession = {
subjectId: 'offline-ops-e2e-user',
tenant: 'tenant-default',
scopes: [
'admin',
'ui.read',
'ui.admin',
'orch:read',
'orch:operate',
'health:read',
'notify.viewer',
'policy:read',
],
};
const mockConfig = {
authority: {
issuer: '/authority',
clientId: 'stella-ops-ui',
authorizeEndpoint: '/authority/connect/authorize',
tokenEndpoint: '/authority/connect/token',
logoutEndpoint: '/authority/connect/logout',
redirectUri: 'https://127.0.0.1:4400/auth/callback',
postLogoutRedirectUri: 'https://127.0.0.1:4400/',
scope: 'openid profile email ui.read',
audience: '/gateway',
dpopAlgorithms: ['ES256'],
refreshLeewaySeconds: 60,
},
apiBaseUrls: {
authority: '/authority',
scanner: '/scanner',
policy: '/policy',
concelier: '/concelier',
attestor: '/attestor',
gateway: '/gateway',
},
quickstartMode: true,
setup: 'complete',
};
async function fulfillJson(route: Route, body: unknown): Promise<void> {
await route.fulfill({
status: 200,
contentType: 'application/json',
body: JSON.stringify(body),
});
}
async function navigateClientSide(page: Page, target: string): Promise<void> {
await page.evaluate((url) => {
window.history.pushState({}, '', url);
window.dispatchEvent(new PopStateEvent('popstate', { state: window.history.state }));
}, target);
}
async function setupHarness(page: Page): Promise<void> {
await page.addInitScript((session) => {
(window as { __stellaopsTestSession?: unknown }).__stellaopsTestSession = session;
}, adminSession);
await page.route('**/platform/envsettings.json', (route) => fulfillJson(route, mockConfig));
await page.route('**/config.json', (route) => fulfillJson(route, mockConfig));
await page.route('**/.well-known/openid-configuration', (route) =>
fulfillJson(route, {
issuer: 'https://127.0.0.1:4400/authority',
authorization_endpoint: 'https://127.0.0.1:4400/authority/connect/authorize',
token_endpoint: 'https://127.0.0.1:4400/authority/connect/token',
jwks_uri: 'https://127.0.0.1:4400/authority/.well-known/jwks.json',
response_types_supported: ['code'],
subject_types_supported: ['public'],
id_token_signing_alg_values_supported: ['RS256'],
}),
);
await page.route('**/authority/.well-known/jwks.json', (route) => fulfillJson(route, { keys: [] }));
await page.route('**/console/profile**', (route) =>
fulfillJson(route, {
subjectId: adminSession.subjectId,
username: 'offline-ops-e2e',
displayName: 'Offline Ops E2E',
tenant: adminSession.tenant,
roles: ['admin'],
scopes: adminSession.scopes,
}),
);
await page.route('**/console/token/introspect**', (route) =>
fulfillJson(route, {
active: true,
tenant: adminSession.tenant,
subject: adminSession.subjectId,
scopes: adminSession.scopes,
}),
);
await page.route('**/api/v2/context/regions', (route) =>
fulfillJson(route, [{ regionId: 'eu-west', displayName: 'EU West', sortOrder: 1, enabled: true }]),
);
await page.route('**/api/v2/context/environments**', (route) =>
fulfillJson(route, [
{
environmentId: 'prod',
regionId: 'eu-west',
environmentType: 'prod',
displayName: 'Prod',
sortOrder: 1,
enabled: true,
},
]),
);
await page.route('**/api/v2/context/preferences', (route) =>
fulfillJson(route, {
tenantId: adminSession.tenant,
actorId: adminSession.subjectId,
regions: ['eu-west'],
environments: ['prod'],
timeWindow: '24h',
stage: 'all',
updatedAt: '2026-03-08T12:00:00Z',
updatedBy: adminSession.subjectId,
}),
);
await page.route('**/doctor/api/v1/doctor/trends**', (route) => fulfillJson(route, []));
await page.route('**/api/v1/approvals**', (route) => fulfillJson(route, []));
await page.route('**/health', (route) =>
route.fulfill({
status: 200,
contentType: 'application/json',
body: JSON.stringify({ status: 'ok' }),
}),
);
}
test.beforeEach(async ({ page }) => {
await setupHarness(page);
});
test('offline kit exposes working canonical shortcuts and child routes', async ({ page }) => {
await page.goto('/ops/operations/offline-kit', { waitUntil: 'networkidle' });
await expect(page.getByRole('heading', { name: 'Offline Kit Management' })).toBeVisible();
await expect(page.getByRole('link', { name: 'Evidence Exports' })).toBeVisible();
await page.locator('a.tab-link', { hasText: 'Bundles' }).click();
await expect(page).toHaveURL(/\/ops\/operations\/offline-kit\/bundles$/);
await expect(page.getByText('Load New Bundle')).toBeVisible();
});
test('legacy offline aliases resolve into canonical operations routes', async ({ page }) => {
await page.goto('/ops/operations', { waitUntil: 'networkidle' });
await navigateClientSide(page, '/platform/ops/offline-kit/bundles?from=legacy');
await expect(page).toHaveURL(/\/ops\/operations\/offline-kit\/bundles\?from=legacy$/);
await expect(page.getByText('Bundle Management')).toBeVisible();
await navigateClientSide(page, '/ops/feeds/airgap/import');
await expect(page).toHaveURL(/\/ops\/operations\/feeds-airgap/);
await expect
.poll(() => {
const currentUrl = new URL(page.url());
return `${currentUrl.searchParams.get('tab')}:${currentUrl.searchParams.get('action')}`;
})
.toBe('airgap-bundles:import');
await expect(page.getByTestId('feeds-airgap-action-banner')).toContainText('Import workflow selected.');
});