Skip to content

Commit 217a00a

Browse files
committed
Add VITE_SKIP_AUTH flag to bypass Keycloak redirect in CI e2e tests
1 parent d0f4f05 commit 217a00a

2 files changed

Lines changed: 5 additions & 0 deletions

File tree

.gitlab-ci.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ run_unit_tests:
1919
run_cypress_tests:
2020
image: cypress/browsers:22.19.0
2121
stage: test
22+
variables:
23+
VITE_SKIP_AUTH: "true"
2224
rules:
2325
- if: '$CI_COMMIT_REF_NAME == "staging"'
2426
changes:

apps/model_catalog/src/index.jsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,13 @@ function renderApp(auth) {
2020
};
2121

2222
// In development, if VITE_DEV_TOKEN is set in .env.local, use it directly.
23+
// Set VITE_SKIP_AUTH=true to render the app without authentication (for CI/e2e tests).
2324
// Otherwise fall through to the normal Keycloak login flow.
2425
// See .env.local.example for setup instructions.
2526
if (import.meta.env.DEV && import.meta.env.VITE_DEV_TOKEN) {
2627
window.addEventListener("DOMContentLoaded", () => renderApp({ token: import.meta.env.VITE_DEV_TOKEN, authenticated: true }));
28+
} else if (import.meta.env.DEV && import.meta.env.VITE_SKIP_AUTH) {
29+
window.addEventListener("DOMContentLoaded", () => renderApp({ authenticated: false }));
2730
} else {
2831
window.addEventListener('DOMContentLoaded', () => initAuth(renderApp));
2932
}

0 commit comments

Comments
 (0)