feat(ui): preserve platform setup canonical routes

This commit is contained in:
master
2026-03-08 11:12:42 +02:00
parent d0f2cc3b2c
commit 6870649abf
19 changed files with 478 additions and 42 deletions

View File

@@ -0,0 +1,195 @@
import { expect, test, type Page, type Route } from '@playwright/test';
import type { StubAuthSession } from '../../src/app/testing/auth-fixtures';
const operatorSession: StubAuthSession = {
subjectId: 'platform-setup-e2e-user',
tenant: 'tenant-default',
scopes: ['admin', 'ui.read', 'ui.admin', 'orch:read', 'orch:operate', 'release: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',
};
const topologyRegions = [{ regionId: 'eu-west', displayName: 'EU West', environmentCount: 1, targetCount: 2 }];
const topologyEnvironments = [
{
environmentId: 'prod',
regionId: 'eu-west',
environmentType: 'prod',
displayName: 'Production',
targetCount: 2,
},
];
const topologyAgents = [
{
agentId: 'agent-001',
agentName: 'Agent One',
regionId: 'eu-west',
environmentId: 'prod',
status: 'active',
assignedTargetCount: 2,
},
];
const promotionPaths = [
{
pathId: 'path-001',
regionId: 'eu-west',
sourceEnvironmentId: 'stage',
targetEnvironmentId: 'prod',
status: 'running',
requiredApprovals: 1,
},
];
async function fulfillJson(route: Route, body: unknown, status = 200): Promise<void> {
await route.fulfill({
status,
contentType: 'application/json',
body: JSON.stringify(body),
});
}
async function setupHarness(page: Page): Promise<void> {
await page.addInitScript((session) => {
(window as { __stellaopsTestSession?: unknown }).__stellaopsTestSession = session;
}, operatorSession);
await page.route('**/api/**', (route) => fulfillJson(route, {}));
await page.route('**/platform/envsettings.json', (route) => fulfillJson(route, mockConfig));
await page.route('**/platform/i18n/*.json', (route) => fulfillJson(route, {}));
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/branding**', (route) =>
fulfillJson(route, {
tenantId: operatorSession.tenant,
appName: 'Stella Ops',
logoUrl: null,
cssVariables: {},
}),
);
await page.route('**/console/profile**', (route) =>
fulfillJson(route, {
subjectId: operatorSession.subjectId,
username: 'platform-setup-e2e',
displayName: 'Platform Setup E2E',
tenant: operatorSession.tenant,
roles: ['platform-admin'],
scopes: operatorSession.scopes,
}),
);
await page.route('**/console/token/introspect**', (route) =>
fulfillJson(route, {
active: true,
tenant: operatorSession.tenant,
subject: operatorSession.subjectId,
scopes: operatorSession.scopes,
}),
);
await page.route('**/authority/console/tenants**', (route) =>
fulfillJson(route, {
tenants: [
{
tenantId: operatorSession.tenant,
displayName: 'Default Tenant',
isDefault: true,
isActive: true,
},
],
}),
);
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: 'Production',
sortOrder: 1,
enabled: true,
},
]),
);
await page.route('**/api/v2/context/preferences**', (route) =>
fulfillJson(route, {
tenantId: operatorSession.tenant,
actorId: operatorSession.subjectId,
regions: ['eu-west'],
environments: ['prod'],
timeWindow: '24h',
stage: 'all',
updatedAt: '2026-03-08T07:00:00Z',
updatedBy: operatorSession.subjectId,
}),
);
await page.route(/\/api\/v2\/topology\/regions(?:\?.*)?$/, (route) => fulfillJson(route, topologyRegions));
await page.route(/\/api\/v2\/topology\/environments(?:\?.*)?$/, (route) =>
fulfillJson(route, topologyEnvironments),
);
await page.route(/\/api\/v2\/topology\/agents(?:\?.*)?$/, (route) => fulfillJson(route, topologyAgents));
await page.route(/\/api\/v2\/topology\/promotion-paths(?:\?.*)?$/, (route) =>
fulfillJson(route, promotionPaths),
);
}
test.beforeEach(async ({ page }) => {
await setupHarness(page);
});
test('platform setup canonical leaves preserve ops urls during setup topology cutover', async ({ page }) => {
await page.goto('/ops/platform-setup', { waitUntil: 'networkidle' });
const regionsCard = page.locator('.setup-home__card').filter({ hasText: 'Regions & Environments' });
await regionsCard.getByRole('link', { name: 'Open' }).click();
await expect(page).toHaveURL(/\/ops\/platform-setup\/regions-environments(?:\?.*)?$/);
await expect(page.getByRole('heading', { name: 'Regions & Environments' })).toBeVisible();
await page.goto('/ops/platform-setup/promotion-paths', { waitUntil: 'networkidle' });
await expect(page).toHaveURL(/\/ops\/platform-setup\/promotion-paths(?:\?.*)?$/);
await expect(page.getByRole('heading', { name: 'Promotion Paths' })).toBeVisible();
await page.goto('/ops/platform-setup/workflows-gates', { waitUntil: 'networkidle' });
await expect(page).toHaveURL(/\/ops\/platform-setup\/workflows-gates(?:\?.*)?$/);
await expect(page.getByRole('heading', { name: 'Workflows & Gates' })).toBeVisible();
await page.goto('/ops/platform-setup/gate-profiles', { waitUntil: 'networkidle' });
await expect(page).toHaveURL(/\/ops\/platform-setup\/gate-profiles(?:\?.*)?$/);
await expect(page.getByRole('heading', { name: 'Gate Profiles' })).toBeVisible();
});

View File

@@ -281,7 +281,6 @@ test('topology and trust cutover keeps setup handoffs and legacy trust entry poi
await page.goto('/ops/platform-setup', { waitUntil: 'networkidle' });
const regionsCard = page.locator('.setup-home__card').filter({ hasText: 'Regions & Environments' });
await regionsCard.getByRole('link', { name: 'Open' }).click();
await expect(page).toHaveURL(/\/setup\/topology\/regions(?:\?.*)?$/);
await expect(page.getByRole('heading', { name: 'Topology' })).toBeVisible();
await expect(page).toHaveURL(/\/ops\/platform-setup\/regions-environments(?:\?.*)?$/);
await expect(page.getByRole('heading', { name: 'Regions & Environments' })).toBeVisible();
});