-
Notifications
You must be signed in to change notification settings - Fork 2
Creates tests for new network page feature WIP #33
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
// eslint-disable-next-line import/no-cycle | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this will need to be addressed, eventually |
||
import { test_Alice_2W } from './setup/sessionTest'; | ||
import { compareScreenshot, waitForElement } from './utilities/utils'; | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import { englishStrippedStr } from '../locale/localizedString'; | ||
import { test_Alice_1W } from './setup/sessionTest'; | ||
import { | ||
checkModalStrings, | ||
clickOnTestIdWithText, | ||
grabTextFromElement, | ||
waitForElement, | ||
waitForLoadingAnimationToFinish, | ||
waitForTestIdWithText, | ||
} from './utilities/utils'; | ||
|
||
/* Waiting for test id to be fixed | ||
// Links to test are: | ||
- Learn more Network link | ||
- Learn more staking link | ||
- How to create wallet link | ||
*/ | ||
Comment on lines
+12
to
+17
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. where are we about those test ids? |
||
|
||
test_Alice_1W('Learn more network link', async ({ aliceWindow1 }) => { | ||
await clickOnTestIdWithText(aliceWindow1, 'settings-section'); | ||
await clickOnTestIdWithText( | ||
aliceWindow1, | ||
'session-network-settings-menu-item', | ||
); | ||
await waitForLoadingAnimationToFinish(aliceWindow1, 'loading-spinner'); | ||
await clickOnTestIdWithText(aliceWindow1, 'learn-more-network-link'); | ||
await checkModalStrings( | ||
aliceWindow1, | ||
englishStrippedStr('urlOpen').toString(), | ||
englishStrippedStr('urlOpenDescription').toString(), | ||
); | ||
const el = await waitForElement( | ||
aliceWindow1, | ||
'data-testid', | ||
'open-url-confirm-button', | ||
); | ||
const href = await el.getAttribute('href'); | ||
console.log('href', href); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. do we want to log this? |
||
}); | ||
|
||
test_Alice_1W('Refreshing page works', async ({ aliceWindow1 }) => { | ||
// TODO Add string in once crowdin has been updated | ||
// const expectedText = englishStrippedStr('updated') | ||
// .withArgs({ relative_time: '0m' }) | ||
// .toString(); | ||
Comment on lines
+42
to
+45
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. have those been added yet? |
||
const expectedText = 'Last updated 0m ago'; | ||
await clickOnTestIdWithText(aliceWindow1, 'settings-section'); | ||
await clickOnTestIdWithText( | ||
aliceWindow1, | ||
'session-network-settings-menu-item', | ||
); | ||
await waitForLoadingAnimationToFinish(aliceWindow1, 'loading-spinner'); | ||
await clickOnTestIdWithText(aliceWindow1, 'refresh-button'); | ||
await waitForLoadingAnimationToFinish(aliceWindow1, 'loading-spinner'); | ||
await waitForTestIdWithText(aliceWindow1, 'last-updated-timestamp'); | ||
const returnedText = await grabTextFromElement( | ||
aliceWindow1, | ||
'data-testid', | ||
'last-updated-timestamp', | ||
); | ||
if (returnedText !== expectedText) { | ||
throw new Error(`Expected text: ${expectedText}, but got: ${returnedText}`); | ||
} | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,17 @@ | ||
import { Page } from '@playwright/test'; | ||
// eslint-disable-next-line import/no-cycle | ||
import { | ||
clickOnTestIdWithText, | ||
doesElementExist, | ||
typeIntoInput, | ||
waitForLoadingAnimationToFinish, | ||
} from '../utilities/utils'; | ||
|
||
export async function recoverFromSeed(window: Page, recoveryPhrase: string) { | ||
export async function recoverFromSeed( | ||
window: Page, | ||
recoveryPhrase: string, | ||
createDisplayName?: boolean, | ||
) { | ||
Comment on lines
+10
to
+14
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is this |
||
await clickOnTestIdWithText(window, 'existing-account-button'); | ||
await typeIntoInput(window, 'recovery-phrase-input', recoveryPhrase); | ||
await clickOnTestIdWithText(window, 'continue-button'); | ||
|
@@ -17,8 +22,12 @@ export async function recoverFromSeed(window: Page, recoveryPhrase: string) { | |
'display-name-input', | ||
); | ||
if (displayName) { | ||
throw new Error(`Display name was not found when restoring from seed`); | ||
if (createDisplayName) { | ||
await typeIntoInput(window, 'display-name-input', 'Alice'); | ||
await clickOnTestIdWithText(window, 'continue-button'); | ||
} else { | ||
throw new Error(`Display name was not found when restoring from seed`); | ||
} | ||
} | ||
|
||
return { window }; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,7 +43,7 @@ export async function waitForTestIdWithText( | |
const found = await window.waitForSelector(builtSelector, { | ||
timeout: maxWait, | ||
}); | ||
// console.info('found selector', builtSelector); | ||
console.info('found selector', builtSelector); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. do we want this commited? |
||
|
||
return found; | ||
} | ||
|
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.
why not make this
screenshotFolder
part of a templated string (with backtick?) I guess ts complains about the testName and others being there, but without the $ sign?