Skip to content

Commit

Permalink
Merge pull request #5 from Miki-Session/onboarding-modals
Browse files Browse the repository at this point in the history
Onboarding Warning modals
  • Loading branch information
burtonemily authored Nov 18, 2024
2 parents 9ca7776 + 99b1b74 commit 832635d
Show file tree
Hide file tree
Showing 5 changed files with 93 additions and 3 deletions.
27 changes: 27 additions & 0 deletions run/test/specs/locators/onboarding.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { StrategyExtractionObj } from '../../../types/testing';
import { LocatorsInterface } from './index';

// SHARED LOCATORS
Expand All @@ -20,6 +21,32 @@ export class ErrorMessage extends LocatorsInterface {
}
}

export class BackButton extends LocatorsInterface {
public build() {
switch (this.platform) {
case 'android':
return {
strategy: 'id',
selector: 'network.loki.messenger:id/back_button',
} as const;
case 'ios':
return {
strategy: 'accessibility id',
selector: 'Back',
} as const;
}
}
}

export class WarningModalQuitButton extends LocatorsInterface {
public build(): StrategyExtractionObj {
return {
strategy: 'id',
selector: 'Quit',
} as const;
}
}

// SPLASH SCREEN
export class CreateAccountButton extends LocatorsInterface {
public build() {
Expand Down
32 changes: 32 additions & 0 deletions run/test/specs/warning_modal_new_account.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { bothPlatformsIt } from '../../types/sessionIt';
import {
CreateAccountButton,
BackButton,
DisplayNameInput,
SlowModeRadio,
ContinueButton,
WarningModalQuitButton,
} from './locators/onboarding';
import { SupportedPlatformsType } from './utils/open_app';
import { openAppOnPlatformSingleDevice, closeApp } from './utils/open_app';
import { USERNAME } from '../../types/testing';

bothPlatformsIt('Warning modal new account', 'medium', warningModalNewAccount);

async function warningModalNewAccount(platform: SupportedPlatformsType) {
const { device } = await openAppOnPlatformSingleDevice(platform);
await device.clickOnElementAll(new CreateAccountButton(device));
await device.inputText(USERNAME.ALICE, new DisplayNameInput(device));
await device.clickOnElementAll(new ContinueButton(device));
// Checking that we're on the Message Notifications screen
await device.doesElementExist(new SlowModeRadio(device));
// Pressing Back on the Message Notifications screen
await device.clickOnElementAll(new BackButton(device));
// Verifying that pressing Back from the Message Notifications screen does not bring up a modal but instead shows the Display Name input field
await device.doesElementExist(new DisplayNameInput(device));
// Pressing Back on the Display Name screen to trigger the Warning modal
await device.clickOnElementAll(new BackButton(device));
await device.checkModalStrings('warning', 'onboardingBackAccountCreation');
await device.clickOnElementAll(new WarningModalQuitButton(device));
await closeApp(device);
}
29 changes: 29 additions & 0 deletions run/test/specs/warning_modal_restore_account.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { bothPlatformsIt } from '../../types/sessionIt';
import {
SeedPhraseInput,
BackButton,
SlowModeRadio,
ContinueButton,
AccountRestoreButton,
WarningModalQuitButton,
} from './locators/onboarding';
import { SupportedPlatformsType } from './utils/open_app';
import { openAppOnPlatformSingleDevice, closeApp } from './utils/open_app';

bothPlatformsIt('Warning modal restore account', 'medium', warningModalRestoreAccount);

async function warningModalRestoreAccount(platform: SupportedPlatformsType) {
const { device } = await openAppOnPlatformSingleDevice(platform);
const seedPhrase =
'eldest fazed hybrid buzzer nasty domestic digit pager unusual purged makeup assorted domestic';
await device.clickOnElementAll(new AccountRestoreButton(device));
await device.inputText(seedPhrase, new SeedPhraseInput(device));
await device.clickOnElementAll(new ContinueButton(device));
// Checking that we're on the Message Notifications screen
await device.doesElementExist(new SlowModeRadio(device).build());
// Pressing Back on the Message Notifications screen to trigger the Warning modal
await device.clickOnElementAll(new BackButton(device));
await device.checkModalStrings('warning', 'onboardingBackLoadAccount');
await device.clickOnElementAll(new WarningModalQuitButton(device));
await closeApp(device);
}
2 changes: 2 additions & 0 deletions run/types/DeviceWrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1794,6 +1794,8 @@ export class DeviceWrapper {
throw new Error(
`Modal description is incorrect. Expected description: ${expectedStringDescription}, Actual description: ${formattedDescription}`
);
} else {
console.log('Modal description is correct');
}
}

Expand Down
6 changes: 3 additions & 3 deletions run/types/testing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -322,9 +322,7 @@ export type AccessibilityId =
| 'Error message'
| 'Open URL'
| 'Terms of Service'
| 'Terms of service button'
| 'Privacy Policy'
| 'Privacy policy button'
| 'TabBarItemTitle'
| 'URL';

Expand Down Expand Up @@ -366,6 +364,8 @@ export type Id =
| 'Terms of Service'
| 'Privacy Policy'
| 'com.android.chrome:id/signin_fre_dismiss_button'
| 'com.android.chrome:id/negative_button';
| 'com.android.chrome:id/negative_button'
| 'network.loki.messenger:id/back_button'
| 'Quit';

export type TestRisk = 'high' | 'medium' | 'low' | undefined;

0 comments on commit 832635d

Please sign in to comment.