-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
test: [POM] create ResetPasswordPage for e2e tests and migrate 2 test files to POM #27244
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
83e4ff0
Cherry-picked files from devin-accounts-tests-migration branch
devin-ai-integration[bot] 4ef6cc7
corrections
chloeYue 4618b4a
correction
chloeYue 717e1b2
Reorder methods in AccountListPage: check_pageIsLoaded() first, follo…
devin-ai-integration[bot] 8691d35
Revert last commit 717e1b2 to undo changes in account-list-page.ts
devin-ai-integration[bot] c541f90
Merge branch 'develop' into devin-password-page-tests-migration
chloeYue 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 was deleted.
Oops, something went wrong.
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
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 |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import { Driver } from '../../webdriver/driver'; | ||
|
||
class ResetPasswordPage { | ||
private driver: Driver; | ||
|
||
private seedPhraseInput: string; | ||
|
||
private passwordInput: string; | ||
|
||
private confirmPasswordInput: string; | ||
|
||
private restoreButton: string; | ||
|
||
constructor(driver: Driver) { | ||
this.driver = driver; | ||
this.seedPhraseInput = '[data-testid="import-srp__srp-word-0"]'; | ||
this.passwordInput = '[data-testid="create-vault-password"]'; | ||
this.confirmPasswordInput = '[data-testid="create-vault-confirm-password"]'; | ||
this.restoreButton = '[data-testid="create-new-vault-submit-button"]'; | ||
} | ||
|
||
async check_pageIsLoaded(): Promise<void> { | ||
try { | ||
await this.driver.waitForMultipleSelectors([ | ||
this.passwordInput, | ||
this.confirmPasswordInput, | ||
]); | ||
} catch (e) { | ||
console.log( | ||
'Timeout while waiting for reset password page to be loaded', | ||
e, | ||
); | ||
throw e; | ||
} | ||
console.log('Reset password page is loaded'); | ||
} | ||
|
||
/** | ||
* Resets the password using the provided seed phrase and new password. | ||
* | ||
* @param seedPhrase - The seed phrase to verify account ownership | ||
* @param newPassword - The new password to set for the account | ||
*/ | ||
async resetPassword(seedPhrase: string, newPassword: string): Promise<void> { | ||
console.log(`Resetting password with new password: ${newPassword}`); | ||
await this.driver.pasteIntoField(this.seedPhraseInput, seedPhrase); | ||
await this.driver.fill(this.passwordInput, newPassword); | ||
await this.driver.fill(this.confirmPasswordInput, newPassword); | ||
await this.driver.clickElement(this.restoreButton); | ||
} | ||
} | ||
|
||
export default ResetPasswordPage; |
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
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 |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { withFixtures, defaultGanacheOptions } from '../../helpers'; | ||
import FixtureBuilder from '../../fixture-builder'; | ||
import { E2E_SRP } from '../../default-fixture'; | ||
import { Driver } from '../../webdriver/driver'; | ||
import HomePage from '../../page-objects/pages/homepage'; | ||
import LoginPage from '../../page-objects/pages/login-page'; | ||
import ResetPasswordPage from '../../page-objects/pages/reset-password-page'; | ||
import { loginWithBalanceValidation } from '../../page-objects/flows/login.flow'; | ||
|
||
const newPassword = 'this is the best password ever'; | ||
|
||
describe('Forgot password', function () { | ||
it('resets password and then unlock wallet with new password', async function () { | ||
await withFixtures( | ||
{ | ||
fixtures: new FixtureBuilder().build(), | ||
ganacheOptions: defaultGanacheOptions, | ||
title: this.test?.fullTitle(), | ||
}, | ||
async ({ driver }: { driver: Driver }) => { | ||
await loginWithBalanceValidation(driver); | ||
|
||
// Lock Wallet | ||
const homePage = new HomePage(driver); | ||
await homePage.headerNavbar.lockMetaMask(); | ||
|
||
// Click forgot password button and reset password | ||
await new LoginPage(driver).gotoResetPasswordPage(); | ||
|
||
const resetPasswordPage = new ResetPasswordPage(driver); | ||
await resetPasswordPage.check_pageIsLoaded(); | ||
await resetPasswordPage.resetPassword(E2E_SRP, newPassword); | ||
|
||
// Lock wallet again | ||
await homePage.headerNavbar.lockMetaMask(); | ||
|
||
// Check user can log in with new password | ||
await loginWithBalanceValidation(driver, newPassword); | ||
}, | ||
); | ||
}); | ||
}); |
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { Suite } from 'mocha'; | ||
import { defaultGanacheOptions, withFixtures } from '../../helpers'; | ||
import FixtureBuilder from '../../fixture-builder'; | ||
import { Driver } from '../../webdriver/driver'; | ||
import HomePage from '../../page-objects/pages/homepage'; | ||
import { loginWithBalanceValidation } from '../../page-objects/flows/login.flow'; | ||
|
||
describe('Migrate vault with old encryption', function (this: Suite) { | ||
it('successfully unlocks an old vault, locks it, and unlocks again', async function () { | ||
await withFixtures( | ||
{ | ||
fixtures: new FixtureBuilder().withKeyringControllerOldVault().build(), | ||
ganacheOptions: defaultGanacheOptions, | ||
title: this.test?.fullTitle(), | ||
}, | ||
async ({ driver }: { driver: Driver }) => { | ||
await loginWithBalanceValidation(driver); | ||
const homePage = new HomePage(driver); | ||
await homePage.headerNavbar.lockMetaMask(); | ||
await loginWithBalanceValidation(driver); | ||
}, | ||
); | ||
}); | ||
}); |
File renamed without changes.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: maybe to follow the same as what we did in the other PR, I would suggest to place the
checks
at the endThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh or maybe is it better to order everything alphabetically? As I see that in other places it is ordered alphabetically including the
check
s. In that case we can leave this as it is, but we can modify the order of the other page (linked PR above), in another PRThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for pointing out @seaona ! What I'm thinking for the order is:
check_pageIsLoaded()
first, followed byaction methods
ordered alphabetically, and then allcheck_ methods
ordered alphabetically(as they all start withcheck_
).The reason for placing
check_pageIsLoaded()
first is that all page classes will have this specific method, and when we create an object for the page, we usually need to call it before performing other actions. Thus, putting this specific method at the beginning will make it easier to find.What do you think about this approach? If you agree, we can make it a standard.