-
Notifications
You must be signed in to change notification settings - Fork 3
feat: add new tests #46
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
Show all changes
8 commits
Select commit
Hold shift + click to select a range
75e94c1
feat: add linked delete group test
Miki-Session 6757fea
feat: add network page fetch test
Miki-Session ff13cfb
feat: bring in more network page tests
Miki-Session 65a6896
feat: add warning modal tests
Miki-Session 12a6560
chore: add strings
Miki-Session d5804c8
feat: also kill child processes
Miki-Session 115a200
chore: remove comments
Miki-Session 861db0b
fix: address PR feedback
Miki-Session 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 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
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
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,112 @@ | ||
| import { englishStrippedStr } from '../localization/englishStrippedStr'; | ||
| import { sleepFor } from '../promise_utils'; | ||
| import { Global, LeftPane, Settings } from './locators'; | ||
| import { test_Alice_1W } from './setup/sessionTest'; | ||
| import { validateNetworkData } from './utilities/network_api'; | ||
| import { | ||
| assertUrlIsReachable, | ||
| checkModalStrings, | ||
| clickOn, | ||
| waitForLoadingAnimationToFinish, | ||
| waitForTestIdWithText, | ||
| } from './utilities/utils'; | ||
|
|
||
| test_Alice_1W('Network page values', async ({ aliceWindow1 }) => { | ||
| await clickOn(aliceWindow1, LeftPane.settingsButton); | ||
| await clickOn(aliceWindow1, Settings.networkPageMenuItem); | ||
|
|
||
| const response = await fetch('http://networkv1.getsession.org/info'); | ||
| if (!response.ok) { | ||
| throw new Error(`Network API returned ${response.status}`); | ||
| } | ||
| const data = await response.json(); | ||
| validateNetworkData(data); | ||
|
|
||
| // SESH Price - 2 decimals "$1.23 USD" | ||
| const seshPrice = `$${data.price.usd.toFixed(2)} USD`; | ||
|
|
||
| // Staking Reward Pool - whole number with commas "1,234,567 SESH" | ||
| const stakingRewardPool = `${data.token.staking_reward_pool.toLocaleString( | ||
| 'en-US', | ||
| )} SESH`; | ||
|
|
||
| // Market Cap - round to whole number with commas, "$1,234,567 USD" | ||
| const marketCap = `$${Math.round(data.price.usd_market_cap).toLocaleString( | ||
| 'en-US', | ||
| )} USD`; | ||
|
|
||
| await waitForTestIdWithText( | ||
| aliceWindow1, | ||
| Settings.seshPrice.selector, | ||
| seshPrice, | ||
| ); | ||
| await waitForTestIdWithText( | ||
| aliceWindow1, | ||
| Settings.stakingRewardPoolAmount.selector, | ||
| stakingRewardPool, | ||
| ); | ||
| await waitForTestIdWithText( | ||
| aliceWindow1, | ||
| Settings.marketCapAmount.selector, | ||
| marketCap, | ||
| ); | ||
| }); | ||
|
|
||
| test_Alice_1W('Network page network link', async ({ aliceWindow1 }) => { | ||
| const url = 'https://docs.getsession.org/session-network'; | ||
| await clickOn(aliceWindow1, LeftPane.settingsButton); | ||
| await clickOn(aliceWindow1, Settings.networkPageMenuItem); | ||
| await clickOn(aliceWindow1, Settings.learnMoreNetworkLink); | ||
| await checkModalStrings( | ||
| aliceWindow1, | ||
| englishStrippedStr('urlOpen').toString(), | ||
| englishStrippedStr('urlOpenDescription').withArgs({ url }).toString(), | ||
| 'openUrlModal', | ||
| ); | ||
| await assertUrlIsReachable(url); | ||
| }); | ||
|
|
||
| test_Alice_1W('Network page staking link', async ({ aliceWindow1 }) => { | ||
| const url = 'https://docs.getsession.org/session-network/staking'; | ||
| await clickOn(aliceWindow1, LeftPane.settingsButton); | ||
| await clickOn(aliceWindow1, Settings.networkPageMenuItem); | ||
| await clickOn(aliceWindow1, Settings.learnMoreAboutStakingLink); | ||
| await checkModalStrings( | ||
| aliceWindow1, | ||
| englishStrippedStr('urlOpen').toString(), | ||
| englishStrippedStr('urlOpenDescription').withArgs({ url }).toString(), | ||
| 'openUrlModal', | ||
| ); | ||
| await assertUrlIsReachable(url); | ||
| }); | ||
|
|
||
| test_Alice_1W('Network page refresh', async ({ aliceWindow1 }) => { | ||
| const zeroMinAgoText = englishStrippedStr('updated') | ||
| .withArgs({ relative_time: '0m' }) | ||
| .toString(); | ||
| const oneMinAgoText = englishStrippedStr('updated') | ||
| .withArgs({ relative_time: '1m' }) | ||
| .toString(); | ||
| await clickOn(aliceWindow1, LeftPane.settingsButton); | ||
| await clickOn(aliceWindow1, Settings.networkPageMenuItem); | ||
| await waitForLoadingAnimationToFinish( | ||
| aliceWindow1, | ||
| Global.loadingSpinner.selector, | ||
| ); | ||
| await sleepFor(65_000); // Wait 60+5 seconds to ensure timestamp changes to "1m ago" | ||
| await waitForTestIdWithText( | ||
| aliceWindow1, | ||
| Settings.lastUpdatedTimestamp.selector, | ||
| oneMinAgoText, | ||
| ); | ||
| await clickOn(aliceWindow1, Settings.refreshButton); | ||
| await waitForLoadingAnimationToFinish( | ||
| aliceWindow1, | ||
| Global.loadingSpinner.selector, | ||
| ); | ||
| await waitForTestIdWithText( | ||
| aliceWindow1, | ||
| Settings.lastUpdatedTimestamp.selector, | ||
| zeroMinAgoText, | ||
| ); | ||
| }); | ||
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,60 @@ | ||
| import { englishStrippedStr } from '../localization/englishStrippedStr'; | ||
| import { Global, Onboarding } from './locators'; | ||
| import { sessionTestOneWindow } from './setup/sessionTest'; | ||
| import { | ||
| checkModalStrings, | ||
| clickOn, | ||
| clickOnWithText, | ||
| typeIntoInput, | ||
| } from './utilities/utils'; | ||
|
|
||
| sessionTestOneWindow('Warning modal new account', async ([aliceWindow1]) => { | ||
| await clickOn(aliceWindow1, Onboarding.createAccountButton); | ||
| await clickOn(aliceWindow1, Global.backButton); | ||
| await checkModalStrings( | ||
| aliceWindow1, | ||
| englishStrippedStr('warning').toString(), | ||
| englishStrippedStr('onboardingBackAccountCreation').toString(), | ||
| 'confirmModal', | ||
| ); | ||
| await clickOnWithText( | ||
| aliceWindow1, | ||
| Global.confirmButton, | ||
| englishStrippedStr('quitButton').toString(), | ||
| ); | ||
| // Wait for window to close (confirms restart was triggered) | ||
| await aliceWindow1.waitForEvent('close', { timeout: 5000 }); | ||
|
|
||
| // Test ends - app is restarting but we can't verify the aftermath | ||
| // Playwright cannot keep track of Electron's `window.restart` IPC call | ||
| // so this will have to do | ||
| }); | ||
|
|
||
| sessionTestOneWindow( | ||
| 'Warning modal restore account', | ||
| async ([aliceWindow1]) => { | ||
| const seedPhrase = | ||
| 'eldest fazed hybrid buzzer nasty domestic digit pager unusual purged makeup assorted domestic'; | ||
| await clickOn(aliceWindow1, Onboarding.iHaveAnAccountButton); | ||
| await typeIntoInput(aliceWindow1, 'recovery-phrase-input', seedPhrase); | ||
| await clickOn(aliceWindow1, Global.continueButton); | ||
| await clickOn(aliceWindow1, Global.backButton); | ||
| await checkModalStrings( | ||
| aliceWindow1, | ||
| englishStrippedStr('warning').toString(), | ||
| englishStrippedStr('onboardingBackLoadAccount').toString(), | ||
| 'confirmModal', | ||
| ); | ||
| await clickOnWithText( | ||
| aliceWindow1, | ||
| Global.confirmButton, | ||
| englishStrippedStr('quitButton').toString(), | ||
| ); | ||
| // Wait for window to close (confirms restart was triggered) | ||
| await aliceWindow1.waitForEvent('close', { timeout: 5000 }); | ||
|
|
||
| // Test ends - app is restarting but we can't verify the aftermath | ||
| // Playwright cannot keep track of Electron's `window.restart` IPC call | ||
| // so this will have to do | ||
| }, | ||
| ); |
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 |
|---|---|---|
| @@ -1,10 +1,26 @@ | ||
| import { Page } from '@playwright/test'; | ||
| import { execSync } from 'child_process'; | ||
|
|
||
| import { sleepFor } from '../../promise_utils'; | ||
| import { getTrackedElectronPids } from './open'; | ||
|
|
||
| export const forceCloseAllWindows = async (windows: Array<Page>) => { | ||
| return Promise.race([ | ||
| await Promise.race([ | ||
| Promise.all(windows.map((w) => w.close())), | ||
| async () => sleepFor(4000), | ||
| sleepFor(4000), | ||
| ]); | ||
|
|
||
| // Also kill child processes | ||
| const pids = getTrackedElectronPids(); | ||
| pids.forEach((pid) => { | ||
| try { | ||
| const killCommand = | ||
| process.platform === 'win32' | ||
| ? `taskkill /F /T /PID ${pid}` // /T kills child processes on Windows | ||
| : `pkill -9 -P ${pid}; kill -9 ${pid}`; // Kill children then parent on Unix | ||
| execSync(killCommand, { stdio: 'ignore' }); | ||
| } catch (e) { | ||
| // This is fine - process already dead or doesn't exist | ||
| } | ||
| }); | ||
| }; |
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.