-
Notifications
You must be signed in to change notification settings - Fork 13k
test: Add e2e test for change password in account security page #37765
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 was deleted.
Oops, something went wrong.
This file contains hidden or 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 hidden or 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 |
|---|---|---|
| @@ -0,0 +1,108 @@ | ||
| import { faker } from '@faker-js/faker'; | ||
|
|
||
| import { ADMIN_CREDENTIALS } from './config/constants'; | ||
| import { Users } from './fixtures/userStates'; | ||
| import { AccountSecurity } from './page-objects'; | ||
| import { setSettingValueById, updateOwnUserPassword } from './utils'; | ||
| import { test, expect } from './utils/test'; | ||
|
|
||
| test.use({ storageState: Users.admin.state }); | ||
|
|
||
| const RANDOM_PASSWORD = faker.string.alphanumeric(10); | ||
|
|
||
| test.describe.serial('account-security', () => { | ||
| let poAccountSecurity: AccountSecurity; | ||
|
|
||
| test.beforeEach(async ({ page }) => { | ||
| poAccountSecurity = new AccountSecurity(page); | ||
| await page.goto('/account/security'); | ||
| await page.waitForSelector('#main-content'); | ||
| }); | ||
|
|
||
| test.afterAll(async ({ api }) => | ||
| Promise.all([ | ||
| setSettingValueById(api, 'Accounts_AllowPasswordChange', true), | ||
| setSettingValueById(api, 'Accounts_TwoFactorAuthentication_Enabled', true), | ||
| setSettingValueById(api, 'E2E_Enable', false), | ||
| ]), | ||
| ); | ||
|
|
||
| test('should disable and enable email 2FA', async () => { | ||
| await poAccountSecurity.security2FASection.click(); | ||
| await expect(poAccountSecurity.email2FASwitch).toBeVisible(); | ||
| await poAccountSecurity.email2FASwitch.click(); | ||
| await poAccountSecurity.toastMessage.waitForDisplay(); | ||
| await poAccountSecurity.toastMessage.dismissToast(); | ||
|
|
||
| await poAccountSecurity.email2FASwitch.click(); | ||
| await poAccountSecurity.toastMessage.waitForDisplay(); | ||
| }); | ||
|
|
||
| // FIXME: This test should pass as soon as we provide the fix | ||
| test.skip('should be able to change password', async ({ api }) => { | ||
| await test.step('change password', async () => { | ||
| await poAccountSecurity.changePassword(RANDOM_PASSWORD, RANDOM_PASSWORD, ADMIN_CREDENTIALS.password); | ||
| await expect(poAccountSecurity.inputNewPassword).toHaveValue(''); | ||
| }); | ||
|
|
||
| await test.step('change back to the original password', async () => { | ||
| expect( | ||
| (await updateOwnUserPassword(api, { newPassword: ADMIN_CREDENTIALS.password, currentPassword: RANDOM_PASSWORD })).status(), | ||
| ).toBe(200); | ||
| }); | ||
| }); | ||
|
|
||
| test.describe('settings disabled', () => { | ||
| test.beforeAll(async ({ api }) => { | ||
| await Promise.all([ | ||
| setSettingValueById(api, 'Accounts_AllowPasswordChange', false), | ||
| setSettingValueById(api, 'Accounts_TwoFactorAuthentication_Enabled', false), | ||
| setSettingValueById(api, 'E2E_Enable', false), | ||
| ]); | ||
| }); | ||
|
|
||
| test('security tab is invisible when password change, 2FA and E2E are disabled', async ({ page }) => { | ||
| const securityTab = poAccountSecurity.sidebar.linkSecurity; | ||
| await expect(securityTab).not.toBeVisible(); | ||
| const mainContent = page.locator('#main-content').getByText('You are not authorized to view this page.').first(); | ||
| await expect(mainContent).toBeVisible(); | ||
| }); | ||
| }); | ||
|
|
||
| test.describe('account security sections', () => { | ||
| test.beforeAll(async ({ api }) => { | ||
| await Promise.all([ | ||
| setSettingValueById(api, 'Accounts_AllowPasswordChange', true), | ||
| setSettingValueById(api, 'Accounts_TwoFactorAuthentication_Enabled', false), | ||
| setSettingValueById(api, 'E2E_Enable', false), | ||
| ]); | ||
| }); | ||
|
|
||
| test.beforeEach(async () => { | ||
| await poAccountSecurity.securityHeader.waitFor({ state: 'visible' }); | ||
| }); | ||
|
|
||
| test('should display security tab and section when password change is enabled but 2FA and E2E are disabled', async () => { | ||
| await expect(poAccountSecurity.sidebar.linkSecurity).toBeVisible(); | ||
| await expect(poAccountSecurity.securityPasswordSection).toBeVisible(); | ||
| }); | ||
|
|
||
| test('can access 2FA setting when enabled but password change and E2E are disabled', async ({ api }) => { | ||
| await Promise.all([ | ||
| setSettingValueById(api, 'Accounts_AllowPasswordChange', false), | ||
| setSettingValueById(api, 'Accounts_TwoFactorAuthentication_Enabled', true), | ||
| setSettingValueById(api, 'E2E_Enable', false), | ||
| ]); | ||
| await expect(poAccountSecurity.security2FASection).toBeVisible(); | ||
| }); | ||
|
|
||
| test('can access E2E setting when enabled but password change and 2FA are disabled', async ({ api }) => { | ||
| await Promise.all([ | ||
| setSettingValueById(api, 'Accounts_AllowPasswordChange', false), | ||
| setSettingValueById(api, 'Accounts_TwoFactorAuthentication_Enabled', false), | ||
| setSettingValueById(api, 'E2E_Enable', true), | ||
| ]); | ||
| await expect(poAccountSecurity.securityE2EEncryptionSection).toBeVisible(); | ||
| }); | ||
| }); | ||
| }); | ||
This file contains hidden or 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 hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.