-
Notifications
You must be signed in to change notification settings - Fork 5k
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: add simple notifications test, add page objects for test #27096
Closed
+251
−24
Closed
Changes from all commits
Commits
Show all changes
33 commits
Select commit
Hold shift + click to select a range
567c991
test: add simple notifications test, add page objects for test
cmd-ob 89b6f49
Merge branch 'develop' into e2e/enable-notifications
cmd-ob f0e999c
fix mocks imports
cmd-ob 4a1f27d
fix linting for privacy snapshot
cmd-ob 37268cd
Merge branch 'develop' into e2e/enable-notifications
cmd-ob 049afbb
use .ts for test file
cmd-ob a717b01
Merge branch 'develop' into e2e/enable-notifications
cmd-ob 7b98884
fix: selector getKnownMethodData should return empty object if user h…
jpuri c9869bd
fix: Update max gas limit with value returned from eth_estimateGas ap…
jpuri 2e25f51
test: [POM] create AccountListPage for e2e tests and migrate 4 test f…
cmd-ob 7bf5969
chore(3210): deprecated `Application open` metric event (#27102)
DDDDDanica d7129ea
fix: Fixed flaky test for custom screen size (#27067)
hjetpoluru c1bdb49
chore: remove dead code (#27211)
cryptotavares 8e40790
feat: upgrade notification controllers (#27224)
Prithpal-Sooriya f8b2c81
chore: Add currency conversion telemetry (#26876)
gambinish f1cf41a
fix: :pencil2: fix event property typo (#27228)
matteoscurati ce892c5
test: add simple notifications test, add page objects for test
cmd-ob 4423794
update user storage id
cmd-ob 0d821e2
Merge branch 'develop' into e2e/enable-notifications
cmd-ob 8714172
lint fix, make test .ts
cmd-ob c7f7fb2
Merge branch 'develop' into e2e/enable-notifications
cmd-ob 84e6b68
add logging to assertion, move go to notifications into header page
cmd-ob aa86704
Merge branch 'e2e/enable-notifications' of github.com:MetaMask/metama…
cmd-ob 914d372
Merge branch 'develop' into e2e/enable-notifications
cmd-ob 57f4446
remove account options menu page
cmd-ob 15ab081
update mock var name
cmd-ob 3b01e86
Merge branch 'develop' of github.com:MetaMask/metamask-extension into…
cmd-ob 8420d5b
update mocks
cmd-ob 63de77a
Merge branch 'develop' of github.com:MetaMask/metamask-extension into…
cmd-ob 09e9f2b
remove irrelevant mocks
cmd-ob 8cf86a7
use import onboarding flow, update mocks for account and notification…
cmd-ob 63aa7c1
Merge branch 'develop' of github.com:MetaMask/metamask-extension into…
cmd-ob c50fb47
update mock, change folder name to profile-sync
cmd-ob 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 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
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 { Driver } from '../../webdriver/driver'; | ||
import FirstTimeTurnOnNotificationsModal from '../pages/notifications/first-time-turn-on-modal'; | ||
import HeaderNavbar from '../pages/header-navbar'; | ||
|
||
/** | ||
* This function enables the notifications through the header options menu from the home page | ||
* | ||
* Note: this flow focuses on the journey of a user who is enabling this feature for the first time | ||
* | ||
* @param driver - The webdriver instance. | ||
*/ | ||
export const enableNotificationsFirstTime = async ( | ||
driver: Driver, | ||
): Promise<void> => { | ||
console.log(`Start enable notifications from home screen`); | ||
const header = new HeaderNavbar(driver); | ||
await header.goToNotifiationsList(); | ||
|
||
const turnOnNotificationsModal = new FirstTimeTurnOnNotificationsModal( | ||
driver, | ||
); | ||
await turnOnNotificationsModal.check_pageIsLoaded(); | ||
await turnOnNotificationsModal.clickTurnOnNotifications(); | ||
}; |
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
31 changes: 31 additions & 0 deletions
31
test/e2e/page-objects/pages/notifications/first-time-turn-on-modal.ts
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,31 @@ | ||
import { Driver } from '../../../webdriver/driver'; | ||
|
||
class FirstTimeTurnOnNotificationsModal { | ||
private driver: Driver; | ||
|
||
private readonly turnOnButton = | ||
'[data-testid="turn-on-notifications-button"]'; | ||
|
||
constructor(driver: Driver) { | ||
this.driver = driver; | ||
} | ||
|
||
async check_pageIsLoaded(): Promise<void> { | ||
try { | ||
await this.driver.waitForSelector(this.turnOnButton); | ||
} catch (e) { | ||
console.log( | ||
'Timeout while waiting for TurnOnNotificationsModal to be loaded', | ||
e, | ||
); | ||
throw e; | ||
} | ||
console.log('TurnOnNotificationsModal is loaded'); | ||
} | ||
|
||
async clickTurnOnNotifications(): Promise<void> { | ||
await this.driver.clickElementAndWaitToDisappear(this.turnOnButton, 10000); | ||
} | ||
} | ||
|
||
export default FirstTimeTurnOnNotificationsModal; |
49 changes: 49 additions & 0 deletions
49
test/e2e/page-objects/pages/notifications/notifications-list.ts
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,49 @@ | ||
import { Driver } from '../../../webdriver/driver'; | ||
|
||
class NotificationsListPage { | ||
private driver: Driver; | ||
|
||
private readonly backButton = '[data-testid="back-button"]'; | ||
|
||
private readonly notificationsSettingsButton = | ||
'[data-testid="notifications-settings-button"]'; | ||
|
||
private readonly noNotificationsReceivedPlaceholder = | ||
'[data-testid="notifications-list-placeholder"]'; | ||
|
||
constructor(driver: Driver) { | ||
this.driver = driver; | ||
} | ||
|
||
async check_pageIsLoaded(): Promise<void> { | ||
try { | ||
await this.driver.waitForMultipleSelectors([ | ||
this.backButton, | ||
this.notificationsSettingsButton, | ||
]); | ||
} catch (e) { | ||
console.log( | ||
'Timeout while waiting for notifications list page to be loaded', | ||
e, | ||
); | ||
throw e; | ||
} | ||
console.log('Notifications list page is loaded'); | ||
} | ||
|
||
async check_noNotificationsReceived(): Promise<void> { | ||
chloeYue marked this conversation as resolved.
Show resolved
Hide resolved
|
||
try { | ||
await this.driver.waitForSelector( | ||
this.noNotificationsReceivedPlaceholder, | ||
); | ||
} catch (e) { | ||
console.log( | ||
'Timed out while waiting for the empty notifications list placeholder to be displayed', | ||
e, | ||
); | ||
} | ||
console.log('Notifications list is empty as expected'); | ||
} | ||
} | ||
|
||
export default NotificationsListPage; |
45 changes: 45 additions & 0 deletions
45
test/e2e/tests/profile-sync/enable-notifications-first-time.ts
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,45 @@ | ||
import { | ||
withFixtures, | ||
defaultGanacheOptions, | ||
completeImportSRPOnboardingFlow, | ||
} from '../../helpers'; | ||
import { enableNotificationsFirstTime } from '../../page-objects/flows/enable-notifications'; | ||
import FixtureBuilder from '../../fixture-builder'; | ||
import NotificationsListPage from '../../page-objects/pages/notifications/notifications-list'; | ||
import { mockNotificationServices } from './mocks'; | ||
|
||
const NOTIFICATIONS_TEAM_SEED_PHRASE = | ||
'leisure swallow trip elbow prison wait rely keep supply hole general mountain'; | ||
|
||
const PASSWORD = 'notify_password'; | ||
|
||
describe('Notifications', function () { | ||
describe('from inside MetaMask', function () { | ||
it('enables notifications for the first time', async function () { | ||
await withFixtures( | ||
{ | ||
fixtures: new FixtureBuilder({ onboarding: true }) | ||
.withMetamaskNotifications() | ||
.build(), | ||
ganacheOptions: defaultGanacheOptions, | ||
title: this.test?.fullTitle(), | ||
testSpecificMock: mockNotificationServices, | ||
}, | ||
async ({ driver }) => { | ||
await driver.navigate(); | ||
await completeImportSRPOnboardingFlow( | ||
driver, | ||
NOTIFICATIONS_TEAM_SEED_PHRASE, | ||
PASSWORD, | ||
); | ||
await enableNotificationsFirstTime(driver); | ||
|
||
// should land on notifications list | ||
const notificationsListPage = new NotificationsListPage(driver); | ||
await notificationsListPage.check_pageIsLoaded(); | ||
await notificationsListPage.check_noNotificationsReceived(); | ||
}, | ||
); | ||
}); | ||
}); | ||
}); |
Large diffs are not rendered by default.
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
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.
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.
With this implementation, for notifications, we use
clickNotificationsMenuItem
in theAccountOptionsMenu
page, but we clicklockMetaMaskButton
using the selectors in theheader-navbar
page directly. However, thenotificationsMenuItem
and thelockMetaMaskButton
are on the same modal, which creates inconsistency. I suggest that we don't create a new page class forAccountOptionsMenu
because it only has a few buttons without complex interactions onAccountOptionsMenu
. We can just add thenotificationsMenuItem
selector in theheader-navbar
page and click on it directly here. This provides an easier implementation.