Files
crank/apps/ui/tests/e2e/observability.spec.js
T

75 lines
3.0 KiB
JavaScript

const { test, expect } = require('@playwright/test');
const { login } = require('./helpers');
test('shell and wizard expose stable diagnostics hooks', async ({ page }) => {
await login(page);
await page.goto('/');
await expect(page.locator('[data-testid="shell-avatar"]')).toBeVisible();
await page.locator('[data-testid="shell-avatar"]').click();
await expect(page.locator('[data-testid="shell-user-name"]').first()).toBeVisible();
await expect(page.locator('[data-testid="shell-user-role"]').first()).toBeVisible();
await page.goto('/wizard/');
await expect(page.locator('[data-testid="wizard-protocol-grid"]')).toBeVisible();
await expect(page.locator('[data-testid="wizard-protocol-rest"]')).toBeVisible();
await expect(page.locator('html')).toHaveAttribute('data-crank-bootstrap-state', 'ready');
});
test('secrets page exposes stable secret management hooks', async ({ page }) => {
await login(page);
await page.goto('/secrets');
await expect(page.locator('[data-testid="secret-create-button"]')).toBeVisible();
await page.locator('[data-testid="secret-create-button"]').click();
await expect(page.locator('[data-testid="secret-create-modal"]')).toBeVisible();
await expect(page.locator('[data-testid="secret-name-input"]')).toBeVisible();
await expect(page.locator('[data-testid="secret-kind-select"]')).toBeVisible();
await expect(page.locator('[data-testid="secret-submit-button"]')).toBeVisible();
await expect(page.locator('html')).toHaveAttribute('data-crank-bootstrap-state', 'ready');
});
test('API errors retain only bounded canonical support identities', async ({ page }) => {
await login(page);
await page.route('**/api/admin/workspaces/correlation-*/operations', async (route) => {
var hostile = route.request().url().includes('correlation-hostile');
await route.fulfill({
status: 503,
contentType: 'application/json',
headers: hostile
? { 'x-request-id': 'reflected;attacker', 'x-trace-id': 'NOT-A-TRACE' }
: {
'x-request-id': '01J5SAFELOCALREQUEST',
'x-trace-id': '0123456789abcdef0123456789abcdef',
},
body: JSON.stringify({ error: { message: 'safe failure' } }),
});
});
var safe = await page.evaluate(async () => {
try {
await window.CrankApi.listOperations('correlation-safe');
return null;
} catch (error) {
return { requestId: error.requestId, traceId: error.traceId };
}
});
expect(safe).toEqual({
requestId: '01J5SAFELOCALREQUEST',
traceId: '0123456789abcdef0123456789abcdef',
});
var hostile = await page.evaluate(async () => {
try {
await window.CrankApi.listOperations('correlation-hostile');
return null;
} catch (error) {
return {
hasRequestId: Object.prototype.hasOwnProperty.call(error, 'requestId'),
hasTraceId: Object.prototype.hasOwnProperty.call(error, 'traceId'),
};
}
});
expect(hostile).toEqual({ hasRequestId: false, hasTraceId: false });
});