Skip to content

Commit

Permalink
test: Fix E2E tests sometimes failing because Keycloak redirects to t…
Browse files Browse the repository at this point in the history
…he admin account page instead of a normal user account page
  • Loading branch information
daniel-frak committed Jul 2, 2024
1 parent b32d71b commit 0ab395b
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions docker/e2e/cypress/e2e/migrating_users.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ describe('user migration plugin', () => {
configureLoginSettings();
configureMigrationPlugin();
configureEmails();
signOutViaUI();
})
signOutViaUIAndClearCache();
});

function signInAsAdmin() {
cy.visit('/admin');
Expand All @@ -58,9 +58,12 @@ describe('user migration plugin', () => {
cy.wait("@loginSubmit");
}

function signOutViaUI() {
function signOutViaUIAndClearCache() {
cy.get('#user-dropdown').click()
cy.get('#sign-out').get('a').contains('Sign out').click({force: true});
cy.clearAllCookies();
cy.clearAllLocalStorage();
cy.clearAllSessionStorage();
}

function configureLoginSettings() {
Expand Down Expand Up @@ -166,7 +169,7 @@ describe('user migration plugin', () => {
signInAsAdmin();
deleteTestUserIfExists().then(() => {
deletePasswordPoliciesIfExist()
.then(() => signOutViaUI());
.then(() => signOutViaUIAndClearCache());
});
});

Expand Down Expand Up @@ -332,7 +335,7 @@ describe('user migration plugin', () => {
it('should migrate user when password breaks policy', () => {
signInAsAdmin();
addSpecialCharactersPasswordPolicy();
signOutViaUI();
signOutViaUIAndClearCache();

signInAsLegacyUser();
provideNewPassword();
Expand Down

0 comments on commit 0ab395b

Please # to comment.