test(bstein-home): harden home e2e status mock

This commit is contained in:
codex 2026-04-21 19:17:20 -03:00
parent caf3d1befd
commit 1194481934
2 changed files with 28 additions and 1 deletions

2
Jenkinsfile vendored
View File

@ -520,7 +520,7 @@ PY
def props = fileExists('build.env') ? readProperties(file: 'build.env') : [:]
echo "Build complete for ${props['SEMVER'] ?: env.VERSION_TAG}"
}
archiveArtifacts artifacts: 'build/**', allowEmptyArchive: true, fingerprint: true
archiveArtifacts artifacts: 'build/**, frontend/coverage/**, frontend/test-results/**, frontend/playwright-report/**', allowEmptyArchive: true, fingerprint: true
}
}
}

View File

@ -1,6 +1,33 @@
import { expect, test } from "../../../frontend/node_modules/@playwright/test/index.mjs";
test.beforeEach(async ({ page }) => {
await page.addInitScript(() => {
const originalFetch = window.fetch.bind(window);
const jsonResponse = (body) =>
new Response(JSON.stringify(body), {
status: 200,
headers: { "content-type": "application/json" },
});
window.fetch = (resource, options) => {
const requestUrl = typeof resource === "string" ? resource : resource?.url || "";
const url = new URL(requestUrl, window.location.origin);
if (url.pathname === "/api/auth/config") {
return Promise.resolve(jsonResponse({ enabled: false }));
}
if (url.pathname === "/api/lab/status") {
return Promise.resolve(
jsonResponse({
connected: true,
atlas: { up: true },
oceanus: { up: false },
}),
);
}
return originalFetch(resource, options);
};
});
await page.route("**/api/auth/config", async (route) => {
await route.fulfill({
status: 200,