Skip to content

test: add critical flow test for on-prem login redirect [WPB-25319]#21407

Open
JacquelineLehner wants to merge 1 commit into
devfrom
refinement/WPB-25319-onPrem-Login-Redirect
Open

test: add critical flow test for on-prem login redirect [WPB-25319]#21407
JacquelineLehner wants to merge 1 commit into
devfrom
refinement/WPB-25319-onPrem-Login-Redirect

Conversation

@JacquelineLehner
Copy link
Copy Markdown
Collaborator

@JacquelineLehner JacquelineLehner commented May 29, 2026

TaskWPB-25319 [Web][QA] Write Critical Flow -> On Prem Login Redirect

This PR introduces a critical flow E2E test (TC-8757) to verify the on-premise login redirect behavior. It ensures that users entering an email associated with a claimed domain on the SSO page are correctly prompted and redirected to the correct backend.

Refs: WPB-25319

Add a critical flow E2E test to verify the on-premise login redirect behaviour
when a user enters an email associated with a claimed domain on the SSO page.

Changes included:
- Add `onPremLoginRedirect-TC-8757.spec.ts` to test the redirect flow and
  verify the custom backend dialog.
- Implement `CustomBackendPage` POM.
- Update `brig.repository.e2e.ts` with `claimDomain` and `deleteDomain`
  API helpers to handle test setup and guaranteed teardown.
- Use FakerJS to ensure domain uniqueness per test run to prevent collisions.

Refs: WPB-25319
@sonarqubecloud
Copy link
Copy Markdown

@github-actions
Copy link
Copy Markdown
Contributor

🔗 Download Full Report Artifact

🧪 Playwright Test Summary

  • Passed: 15
  • Failed: 0
  • Skipped: 0
  • 🔁 Flaky: 0
  • 📊 Total: 15
  • Total Runtime: 102.3s (~ 1 min 42 sec)

);
}

public async deleteDomain(domain: string) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎨 Maybe call it deleteDomainClaim() or something in the sense of "unclaim" domain just so it's clear that it's not a domain which is being deleted here 🙈

Comment on lines +260 to +261
config_url: 'https://nginz-https.anta.wire.link/deeplink.json',
webapp_url: 'https://webapp.anta.wire.link',
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we maybe pass these config options as parameters? It feels a bit wrong to have them hardcoded and hidden in here. Maybe we could even re-use the env vars which will be added for the federation tests here, since they also point to Anta?

await test.step('Open login page and enter email with claimed domain', async () => {
await pageManager.openSSOPage();
await pages.singleSignOn().enterEmailOnSSOPage(email);
await pages.singleSignOn().ssoSignInButton.click();
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔧 I don't think you need to click the sign in button yourself. When testing it it automatically shows the dialog after entering it. It might still work if the button is clicked before the dialog opens automatically, but let's try to avoid undefined timing specific behavior :)


try {
await test.step('Claim domain and configure on-prem redirect', async () => {
await api.brig.claimDomain(domain);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The claiming of the domain is specified as precondition for the test, so no need to do it inside it. I'd suggest to put it in a beforeEach hook outside the test, this way you also don't need the manual try-finally block as you can just do the deletion inside a afterEach hook then :)

Comment on lines +52 to +61
const urlPattern = new RegExp(ON_PREM_WEBAPP_URL.replace(/\./g, '\\.'));

await Promise.all([
page.waitForURL(urlPattern, {
timeout: 20_000,
}),
pages.customBackend().connectButton.click(),
]);

await expect(page).toHaveURL(urlPattern);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why so complicated? In the end all you're doing is clicking a button and waiting for the URL to change, there's no need to start listening for the URL change before the button is clicked. Also the Pattern for matching the URL can be simplified by using String.raw to escape it automatically (no need to maintain the escape regex ourself 😉)

Suggested change
const urlPattern = new RegExp(ON_PREM_WEBAPP_URL.replace(/\./g, '\\.'));
await Promise.all([
page.waitForURL(urlPattern, {
timeout: 20_000,
}),
pages.customBackend().connectButton.click(),
]);
await expect(page).toHaveURL(urlPattern);
await page.getByRole('button', {name: 'Connect'}).click();
await expect(page).toHaveURL(new RegExp(String.raw`${ON_PREM_WEBAPP_URL}`), {timeout: 20_000});

Comment on lines +46 to +48
await expect(pages.customBackend().title).toBeVisible();
await expect(pages.customBackend().redirectWarningText).toBeVisible();
await expect(pages.customBackend().adminInfoText).toBeVisible();
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔧 Let's try not to be overly specific here. Testing the exact texts shown on the page isn't a good practice as they easily change which would break the test for no reason.
Looking into the test description I don't think it's necessary to assert the redirectWarningText and adminInfoText. I'd say it should be sufficient to just check the page contains the headline and optionally the domain of the backend the user will be redirected to:

Suggested change
await expect(pages.customBackend().title).toBeVisible();
await expect(pages.customBackend().redirectWarningText).toBeVisible();
await expect(pages.customBackend().adminInfoText).toBeVisible();
await expect(page.getByText("Connect to your organization's backend?")).toBeVisible();
await expect(page.getByText(ON_PREM_WEBAPP_URL)).toBeVisible();

This way the test is less likely to break for unrelated reasons which means less maintenance effort ;)

Also notice ho I inlined the locator for the title. This locator will most likely be only used once in here as it is very specific. I think we don't need the dedicated POM for now. Also having the title in the test itself makes it easier to read :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants