-
Notifications
You must be signed in to change notification settings - Fork 136
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9de0f68
commit 201cb4d
Showing
3 changed files
with
40 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,6 +23,17 @@ const LEGACY_USER_EMAIL = '[email protected]'; | |
const LEGACY_USER_FIRST_NAME = 'Lucy'; | ||
const LEGACY_USER_LAST_NAME = 'Brennan'; | ||
|
||
const USER_DETAILS_EMAIL_ID = '#email'; | ||
const ADMIN_PERSONAL_INFO_EMAIL_ID = '#email'; | ||
const ADMIN_PERSONAL_INFO_FIRST_NAME_ID = '#firstName'; | ||
const ADMIN_PERSONAL_INFO_LAST_NAME_ID = '#lastName'; | ||
const ACCOUNT_INFORMATION_EMAIL_ID = '#email'; | ||
const ACCOUNT_INFORMATION_FIRST_NAME_ID = '#firstName'; | ||
const ACCOUNT_INFORMATION_LAST_NAME_ID = '#lastName'; | ||
const ACCOUNT_DROPDOWN_SELECTOR = '[data-testid="options"]'; | ||
const RESET_PASSWORD_EMAIL_ID = '#username'; | ||
const RESET_PASSWORD_NEW_PASSWORD_ID = '#password-new'; | ||
const RESET_PASSWORD_CONFIRM_NEW_PASSWORD_ID = '#password-confirm'; | ||
describe('user migration plugin', () => { | ||
|
||
before(() => { | ||
|
@@ -48,15 +59,19 @@ describe('user migration plugin', () => { | |
} | ||
|
||
function signOutViaUI() { | ||
cy.get('#pf-dropdown-toggle-id-6').click() | ||
cy.get('#user-dropdown').click() | ||
cy.get('#sign-out').get('a').contains('Sign out').click({force: true}); | ||
} | ||
|
||
function configureLoginSettings() { | ||
cy.visit('/admin/master/console/#/master/realm-settings/login'); | ||
cy.get('#kc-forgot-pw-switch') | ||
.check({force: true}); | ||
cy.get('.pf-c-alert__title').should('contain', "Forgot password changed successfully"); | ||
|
||
cy.get('#kc-forgot-pw-switch').then(($checkbox) => { | ||
if (!$checkbox.prop('checked')) { | ||
cy.wrap($checkbox).check({ force: true }); | ||
cy.get('.pf-c-alert__title').should('contain', "Forgot password changed successfully"); | ||
} | ||
}); | ||
} | ||
|
||
function configureMigrationPlugin() { | ||
|
@@ -103,28 +118,28 @@ describe('user migration plugin', () => { | |
cy.get('*[placeholder="Search user"').clear().type('*'); | ||
cy.get('.pf-c-input-group').get('.pf-c-button.pf-m-control').click(); | ||
cy.get('table').get('td[data-label="Username"]').get('a').contains(ADMIN_USERNAME).click(); | ||
cy.get('#kc-email').clear(); | ||
cy.get('#kc-email').clear().type(ADMIN_EMAIL); | ||
cy.get('*[data-testid="firstName-input"]').clear().type(ADMIN_USERNAME); | ||
cy.get('*[data-testid="lastName-input"]').clear().type(ADMIN_USERNAME); | ||
cy.get(USER_DETAILS_EMAIL_ID).clear(); | ||
cy.get(USER_DETAILS_EMAIL_ID).clear().type(ADMIN_EMAIL); | ||
cy.get('*[data-testid="firstName"]').clear().type(ADMIN_USERNAME); | ||
cy.get('*[data-testid="lastName"]').clear().type(ADMIN_USERNAME); | ||
cy.get('.pf-c-form__actions').get('button[type="submit"]').contains('Save').click({force: true}); | ||
|
||
} | ||
|
||
function configureAdminPersonalInfo() { | ||
cy.intercept('GET', '/realms/master/account/') | ||
cy.intercept('GET', '/realms/master/account/**') | ||
.as("accountDetails"); | ||
cy.visit('/realms/master/account/#/personal-info'); | ||
cy.visit('/realms/master/account'); | ||
cy.wait('@accountDetails'); | ||
|
||
// Wait a while, otherwise Keycloak overrides the inputs randomly | ||
cy.wait(2000); | ||
cy.get('#email-address').clear(); | ||
cy.get(ADMIN_PERSONAL_INFO_EMAIL_ID).clear(); | ||
// Wait for email to be cleared | ||
cy.wait(2000); | ||
cy.get('#email-address').clear().type(ADMIN_EMAIL); | ||
cy.get('#first-name').clear().type(ADMIN_USERNAME); | ||
cy.get('#last-name').clear().type(ADMIN_USERNAME); | ||
cy.get(ADMIN_PERSONAL_INFO_EMAIL_ID).clear().type(ADMIN_EMAIL); | ||
cy.get(ADMIN_PERSONAL_INFO_FIRST_NAME_ID).clear().type(ADMIN_USERNAME); | ||
cy.get(ADMIN_PERSONAL_INFO_LAST_NAME_ID).clear().type(ADMIN_USERNAME); | ||
|
||
cy.get('button').contains('Save').click(); | ||
|
||
|
@@ -238,14 +253,15 @@ describe('user migration plugin', () => { | |
} | ||
|
||
function updateAccountInformation() { | ||
cy.get('#email').should('have.value', LEGACY_USER_EMAIL); | ||
cy.get('#firstName').should('have.value', LEGACY_USER_FIRST_NAME); | ||
cy.get('#lastName').should('have.value', LEGACY_USER_LAST_NAME); | ||
cy.get(ACCOUNT_INFORMATION_EMAIL_ID).should('have.value', LEGACY_USER_EMAIL); | ||
cy.get(ACCOUNT_INFORMATION_FIRST_NAME_ID).should('have.value', LEGACY_USER_FIRST_NAME); | ||
cy.get(ACCOUNT_INFORMATION_LAST_NAME_ID).should('have.value', LEGACY_USER_LAST_NAME); | ||
cy.get("input").contains("Submit").click(); | ||
} | ||
|
||
function assertIsLoggedInAsLegacyUser() { | ||
cy.get('#landingLoggedInUser').should('contain', LEGACY_USER_FIRST_NAME + ' ' + LEGACY_USER_LAST_NAME); | ||
cy.get(ACCOUNT_DROPDOWN_SELECTOR) | ||
.should('contain', LEGACY_USER_FIRST_NAME + ' ' + LEGACY_USER_LAST_NAME); | ||
} | ||
|
||
it('should reset password after inputting wrong credentials', () => { | ||
|
@@ -275,7 +291,7 @@ describe('user migration plugin', () => { | |
.as('resetCredentials'); | ||
cy.get("a").contains("Forgot Password?").click(); | ||
cy.wait('@resetCredentials'); | ||
cy.get('#username').clear().type(LEGACY_USER_EMAIL); | ||
cy.get(RESET_PASSWORD_EMAIL_ID).clear().type(LEGACY_USER_EMAIL); | ||
cy.get('input[type=submit]').click(); | ||
cy.get('body').should('contain.text', | ||
'You should receive an email shortly with further instructions.'); | ||
|
@@ -298,8 +314,8 @@ describe('user migration plugin', () => { | |
} | ||
|
||
function inputNewPassword() { | ||
cy.get('#password-new').type(LEGACY_USER_PASSWORD); | ||
cy.get('#password-confirm').type(LEGACY_USER_PASSWORD); | ||
cy.get(RESET_PASSWORD_NEW_PASSWORD_ID).type(LEGACY_USER_PASSWORD); | ||
cy.get(RESET_PASSWORD_CONFIRM_NEW_PASSWORD_ID).type(LEGACY_USER_PASSWORD); | ||
cy.get('input[type=submit]').click(); | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters