Skip to content
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

QA - New: Notification setting tests and getting ready for notification service testing #1900

Merged
merged 2 commits into from
Oct 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,17 @@ function NotificationToggle({
title={channel.title}
subtitle={channel.subtitle}
background={theme.background}
rightComponent={<Switch value={checked} onValueChange={onChange} />}
rightComponent={
<Switch
testID={
checked
? `${channel.title}_enabled_switch`
: `${channel.title}_disabled_switch`
}
value={checked}
onValueChange={onChange}
/>
}
/>
)
}
Expand Down
3 changes: 2 additions & 1 deletion packages/core-mobile/e2e/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
]
},
"testPathIgnorePatterns": [
"./e2e/tests/plusIcon/send/sendBitcoin.e2e.ts"
"./e2e/tests/plusIcon/send/sendBitcoin.e2e.ts",
"./e2e/tests/notification/sendNotification.e2e.ts"
]
}
3 changes: 2 additions & 1 deletion packages/core-mobile/e2e/configs/regressionConfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
]
},
"testPathIgnorePatterns": [
"<rootDir>/tests/plusIcon/send/sendBitcoin.e2e.ts"
"<rootDir>/tests/plusIcon/send/sendBitcoin.e2e.ts",
"<rootDir>/tests/notification/sendNotification.e2e.ts"
]
}
3 changes: 2 additions & 1 deletion packages/core-mobile/e2e/configs/reuseStateConfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"./e2e/tests/settings/showRecoveryPhrase.e2e.smoke.ts",
"./e2e/tests/login/recoverMetaMaskWallet.e2e.smoke.ts",
"./e2e/tests/login/unlockWithRecoveryPhrase.e2e.ts",
"./e2e/tests/plusIcon/send/sendBitcoin.e2e.ts"
"./e2e/tests/plusIcon/send/sendBitcoin.e2e.ts",
"./e2e/tests/notification/sendNotification.e2e.ts"
]
}
12 changes: 8 additions & 4 deletions packages/core-mobile/e2e/helpers/loginRecoverWallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import existingRecoveryPhrasePage from '../pages/existingRecoveryPhrase.page'
import Actions from '../helpers/actions'

class LoginRecoverWallet {
async recoverMnemonicWallet() {
async recoverMnemonicWallet(isBalanceNotificationOn = false) {
const recoveryPhrase: string = process.env.E2E_MNEMONIC as string
await ExistingRecoveryPhrasePage.tapAccessExistingWallet()
await ExistingRecoveryPhrasePage.tapRecoveryPhraseBtn()
Expand All @@ -21,7 +21,11 @@ class LoginRecoverWallet {
await CreatePinPage.tapNumpadZero()
await CreatePinPage.tapAgreeAndContinueBtn()
await commonElsPage.tapGetStartedButton()
await commonElsPage.tapNotNow()
if (isBalanceNotificationOn) {
await commonElsPage.tapTurnOnNotifications()
} else {
await commonElsPage.tapNotNow()
}
await PortfolioPage.verifyPorfolioScreen()
}

Expand All @@ -30,7 +34,7 @@ class LoginRecoverWallet {
await commonElsPage.checkIfMainnet()
}

async recoverWalletLogin() {
async recoverWalletLogin(isBalanceNotificationOn = false) {
const isVisibleNo = await Actions.expectToBeVisible(
existingRecoveryPhrasePage.forgotPinBtn
)
Expand All @@ -39,7 +43,7 @@ class LoginRecoverWallet {
await this.enterPin()
await accountManagePage.switchToFirstAccount()
} else {
await this.recoverMnemonicWallet()
await this.recoverMnemonicWallet(isBalanceNotificationOn)
}
}
}
Expand Down
7 changes: 5 additions & 2 deletions packages/core-mobile/e2e/helpers/warmup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ import Action from './actions'
import { Platform } from './constants'
import loginRecoverWallet from './loginRecoverWallet'

export const warmup = async (newInstance = false) => {
export const warmup = async (
newInstance = false,
isBalanceNotificationOn = false
) => {
const permissions: DevicePermissions = { notifications: 'YES', camera: 'YES' }
const initialArgs: DeviceLaunchAppConfig = {
permissions: permissions,
Expand All @@ -31,7 +34,7 @@ export const warmup = async (newInstance = false) => {
console.log('Jailbroken warning handled!!!')
}
try {
await loginRecoverWallet.recoverWalletLogin()
await loginRecoverWallet.recoverWalletLogin(isBalanceNotificationOn)
} catch (e) {
console.log('Skipped login process...')
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,8 @@ export default {
saveButton: 'Save',
securityAndPrivacy: 'Security & Privacy',
showRecoveryPhrase: 'Show recovery phrase',
carrotSvg: 'carrot_svg'
carrotSvg: 'carrot_svg',
notifications: 'Notifications',
deleteWalletBtn: 'Delete Wallet',
iUnderstand: 'I understand, continue'
}
3 changes: 2 additions & 1 deletion packages/core-mobile/e2e/locators/commonEls.loc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ export default {
getStartedBtn: 'Get Started',
retryBtn: 'Retry',
testnetBanner: 'testnet_banner',
notNow: 'Not Now'
notNow: 'Not Now',
turnOnNotifications: 'Turn on Notifications'
}
20 changes: 20 additions & 0 deletions packages/core-mobile/e2e/pages/burgerMenu/burgerMenu.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,18 @@ class BurgerMenuPage {
return by.text(burgerMenu.securityAndPrivacy)
}

get notifications() {
return by.text(burgerMenu.notifications)
}

get deleteWalletBtn() {
return by.text(burgerMenu.deleteWalletBtn)
}

get iUnderstand() {
return by.text(burgerMenu.iUnderstand)
}

async swipeLeft() {
await Actions.swipeLeft(
by.id(burgerMenu.carrotSvg),
Expand All @@ -52,6 +64,9 @@ class BurgerMenuPage {
await Actions.tapElementAtIndex(this.burgerMenuButton, 0)
}

async tapNotifications() {
await Actions.tapElementAtIndex(this.notifications, 0)
}
async tapCurrency() {
await Actions.tapElementAtIndex(this.currency, 0)
}
Expand All @@ -72,6 +87,11 @@ class BurgerMenuPage {
await this.tapBackbutton()
await this.dismissBurgerMenu()
}

async deleteWallet() {
await Actions.tapElementAtIndex(this.deleteWalletBtn, 0)
await Actions.tapElementAtIndex(this.iUnderstand, 0)
}
}

export default new BurgerMenuPage()
83 changes: 83 additions & 0 deletions packages/core-mobile/e2e/pages/burgerMenu/notifications.page.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
import actions from '../../helpers/actions'
import commonElsPage from '../commonEls.page'
import burgerMenuPage from './burgerMenu.page'

class Notifications {
get stakeEnabledSwitch() {
return by.id('Stake_enabled_switch')
}

get stakeDisabledSwitch() {
return by.id('Stake_disabled_switch')
}

get balanceEnabledSwitch() {
return by.id('Balance_enabled_switch')
}

get balanceDisabledSwitch() {
return by.id('Balance_disabled_switch')
}

async tapStakeSwitch(on = true) {
if (on) {
await actions.tap(this.stakeDisabledSwitch)
} else {
await actions.tap(this.stakeEnabledSwitch)
}
}

async tapBalanceSwitch(on = true) {
if (on) {
await actions.tap(this.balanceDisabledSwitch)
} else {
await actions.tap(this.balanceEnabledSwitch)
}
}

async switchBalanceNotification(on = true) {
await burgerMenuPage.tapBurgerMenuButton()
await burgerMenuPage.tapNotifications()
await this.tapBalanceSwitch(on)
await commonElsPage.tapBackButton()
await burgerMenuPage.dismissBurgerMenu()
}

async verifyNotificationsSwitches(stake: boolean, balance: boolean) {
if (stake && balance) {
// both switches are ON
await actions.waitForElement(this.stakeEnabledSwitch)
await actions.waitForElement(this.balanceEnabledSwitch)
} else if (stake && !balance) {
// only stake switch is ON
await actions.waitForElement(this.stakeEnabledSwitch)
await actions.waitForElement(this.balanceDisabledSwitch)
} else if (!stake && balance) {
// only balance switch is ON
await actions.waitForElement(this.stakeDisabledSwitch)
await actions.waitForElement(this.balanceEnabledSwitch)
} else if (!stake && !balance) {
// both switches are OFF
await actions.waitForElement(this.stakeDisabledSwitch)
await actions.waitForElement(this.balanceDisabledSwitch)
}
}

async verifyPushNotification() {
// TODO: currently push notification is broken on internal build. We can update the methods once it's fixed
console.log('verify push notification is received')
}

async tapPushNotification() {
// TODO: currently push notification is broken on internal build. We can update the methods once it's fixed
console.log('verify the deeplink works properly')
await device.launchApp() // temporary solution
}

async verifyNoPushNotification() {
// TODO: currently push notification is broken on internal build. We can update the methods once it's fixed
console.log('verify the push notification is NOT received')
}
}

export default new Notifications()
8 changes: 8 additions & 0 deletions packages/core-mobile/e2e/pages/commonEls.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ class CommonElsPage {
return by.text(commonEls.notNow)
}

get turnOnNotifications() {
return by.text(commonEls.turnOnNotifications)
}

async tapBackButton(index = 0) {
await Actions.tapElementAtIndex(this.backButton, index)
}
Expand Down Expand Up @@ -118,6 +122,10 @@ class CommonElsPage {
console.log('Not now button not found')
}
}

async tapTurnOnNotifications() {
await Actions.tapElementAtIndex(this.turnOnNotifications, 0)
}
}

export default new CommonElsPage()
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { warmup } from '../../helpers/warmup'
import sendLoc from '../../locators/send.loc'
import accountManagePage from '../../pages/accountManage.page'
import notificationsPage from '../../pages/burgerMenu/notifications.page'
import portfolioPage from '../../pages/portfolio.page'
import sendPage from '../../pages/send.page'

describe('Send Notification', () => {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The push notification is broken currently. I added a file and folder as a placeholder and a reminder for future work. I marked the test to be ignored in config files.

beforeAll(async () => {
await warmup(false, true)
await accountManagePage.createSecondAccount()
})

it('should receive send notification', async () => {
await sendPage.sendTokenTo2ndAccount(
sendLoc.avaxToken,
sendLoc.sendingAmount
)
await device.sendToHome()
await notificationsPage.verifyPushNotification()
await notificationsPage.tapPushNotification()
await portfolioPage.verifyPorfolioScreen()
})

it('should not receive send notification', async () => {
await notificationsPage.switchBalanceNotification(false)
await sendPage.sendTokenTo2ndAccount(
sendLoc.avaxToken,
sendLoc.sendingAmount
)
await device.sendToHome()
await notificationsPage.verifyNoPushNotification()
await device.launchApp()
await portfolioPage.verifyPorfolioScreen()
})
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import { warmup } from '../../helpers/warmup'
import burgerMenuPage from '../../pages/burgerMenu/burgerMenu.page'
import notificationsPage from '../../pages/burgerMenu/notifications.page'
import commonElsPage from '../../pages/commonEls.page'

describe('Notification setting', () => {
it('should turn on balance notification when log in', async () => {
await warmup(false, true)
await burgerMenuPage.tapBurgerMenuButton()
await burgerMenuPage.tapNotifications()
await notificationsPage.verifyNotificationsSwitches(false, true)
await commonElsPage.tapBackButton()
await burgerMenuPage.deleteWallet()
})

it('should turn off balance notification when log in', async () => {
await warmup()
await burgerMenuPage.tapBurgerMenuButton()
await burgerMenuPage.tapNotifications()
await notificationsPage.verifyNotificationsSwitches(false, false)
})
it('should turn on all notifications', async () => {
await notificationsPage.tapStakeSwitch()
await notificationsPage.verifyNotificationsSwitches(true, false)
await commonElsPage.tapBackButton()
await burgerMenuPage.tapNotifications()
await notificationsPage.tapBalanceSwitch()
await notificationsPage.verifyNotificationsSwitches(true, true)
await commonElsPage.tapBackButton()
await burgerMenuPage.tapNotifications()
await notificationsPage.verifyNotificationsSwitches(true, true)
})
it('should turn off all notifications', async () => {
await notificationsPage.tapStakeSwitch(false)
await notificationsPage.verifyNotificationsSwitches(false, true)
await commonElsPage.tapBackButton()
await burgerMenuPage.tapNotifications()
await notificationsPage.tapBalanceSwitch(false)
await notificationsPage.verifyNotificationsSwitches(false, false)
await commonElsPage.tapBackButton()
await burgerMenuPage.tapNotifications()
await notificationsPage.verifyNotificationsSwitches(false, false)
})
})
Loading