Repository navigation
Avoid error dialog during login redirect - #3519
Piyushkumar481 wants to merge 4 commits into
Conversation
…ILED_TO_LOAD as fallback during manager initialization.
There was a problem hiding this comment.
Hi @Piyushkumar481 !
Thanks for opening a pull request!
I've pushed a few minor changes to your branch, focusing on edge cases when manager initialization fails.
Now, in case of the login redirect, it hides the errorOccurred error (your fix), but still shows a log.debug() message.
When something else fails during initialization, without any error message being set, it falls back to MANAGER_FAILED_TO_LOAD.
It's a bit more robuust like this, in my opinion.
I'm happy with the changes right now, I will double check with @Ekhorn on the test file. 👍
I see I accidentally used manager.isError instead of this.isError, will commit it soon
|
Ekhorn
left a comment
There was a problem hiding this comment.
This is an additional AI-assisted review.
The or-app and Manager changes look right: manager.init() now only returns false without an error for the auto-login redirect, which no longer opens the empty error dialog, and every other failure path still ends with an error set, so its dialog keeps a message.
The new regression test cannot fail in its current form, so it does not guard the fix yet; details inline.
|
|
||
| await expect(page.getByRole("heading", { name: "Sign in to your account" })).toBeVisible(); | ||
|
|
||
| const appearances = await page.evaluate(() => (window as any).__errorDialogAppearances); |
There was a problem hiding this comment.
page.addInitScript runs again in every new document, so this page.evaluate reads window.__errorDialogAppearances from the Keycloak sign-in page, where the init script has just created a fresh, empty array. Whatever the observer recorded on the manager page is discarded with that document, so the assertion passes with and without the or-app change: the dialog used to open on the manager page that loads after the check-sso round trip, just before it redirects to the sign-in page.
Collecting the appearances in the test through page.exposeFunction, which survives navigations, keeps the record across the redirect:
const errorDialogs: string[] = [];
await page.exposeFunction("reportErrorDialog", (url: string) => errorDialogs.push(url));The observer then calls (window as any).reportErrorDialog(location.href) instead of appearances.push(...), and the assertion becomes:
// The manager page loaded after the check-sso round trip used to show an empty "An error has occurred" dialog
// while redirecting to the sign-in page
expect(errorDialogs).toEqual([]);ui/AGENTS.md asks for a regression test that fails without the fix and a comment on the assertion recording what used to go wrong, so it is worth confirming the test fails with the or-app/src/index.ts change reverted.
|
|
||
| test.use({ storageState: { cookies: [], origins: [] } }); | ||
|
|
||
| test("does not show an error dialog during the unauthenticated login redirect", async ({ page, manager }) => { |
There was a problem hiding this comment.
ui/AGENTS.md asks for test names starting with "should ..." and @given/@when/@then scenario comments above app tests, like the other manager tests:
| test("does not show an error dialog during the unauthenticated login redirect", async ({ page, manager }) => { | |
| /** | |
| * @given An unauthenticated visitor | |
| * @when The start page of the "master" realm is opened | |
| * @then The manager redirects to the Keycloak sign-in page without showing an error dialog | |
| */ | |
| test("should not show an error dialog during the unauthenticated login redirect", async ({ page, manager }) => { |



What does this PR fix?
When an unauthenticated user opens the Manager, Keycloak's
check-ssoflow can trigger a login redirect. During this expected redirect, the Manager could briefly display an unwanted error dialog.Changes
manager.isErroris true.Testing