Skip to content

Commit

Permalink
test(extension): add tests for LW-11798 and LW-11799 (#1512)
Browse files Browse the repository at this point in the history
  • Loading branch information
wklos-iohk authored Nov 5, 2024
1 parent eb73d3d commit d2fc6bd
Show file tree
Hide file tree
Showing 6 changed files with 79 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/common/src/analytics/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ export enum PostHogAction {
SettingsCurrencySelectCurrencyClick = 'settings | currency | select currency | click',
SettingsCurrencyXClick = 'settings | currency | x | click',
SettingsBetaProgramOptInClick = 'settings | beta program | opt-in | click',
SettingsBetaProgramOptOutClick = 'settings | beta program | opt-out |click',
SettingsBetaProgramOptOutClick = 'settings | beta program | opt-out | click',
SettingsThemeLightModeClick = 'settings | theme | light mode | click',
SettingsThemeDarkModeClick = 'settings | theme | dark mode | click',
SettingsShowRecoveryPhraseClick = 'settings | show recovery phrase | click',
Expand Down
24 changes: 24 additions & 0 deletions packages/e2e-tests/src/assert/settings/SettingsPageAssert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,18 @@ class SettingsPageAssert {
expect(await SettingsPage.collateralLink.getTitleText()).to.equal(
await t('browserView.settings.wallet.collateral.title')
);
expect(await SettingsPage.hdWalletSyncLink.getTitleText()).to.equal(
await t('browserView.settings.wallet.walletSync.title')
);
expect(await SettingsPage.currencyLink.getTitleText()).to.equal(
await t('browserView.settings.preferences.currency.title')
);
expect(await SettingsPage.themeLink.getTitleText()).to.equal(
await t('browserView.settings.preferences.theme.title')
);
expect(await SettingsPage.betaProgramLink.getTitleText()).to.equal(
await t('browserView.settings.preferences.betaProgram.title')
);
expect(await SettingsPage.showRecoveryPhraseLink.getTitleText()).to.equal(
await t('browserView.settings.security.showPassphrase.title')
);
Expand Down Expand Up @@ -65,6 +77,18 @@ class SettingsPageAssert {
expect(await SettingsPage.collateralLink.getDescriptionText()).to.equal(
await t('browserView.settings.wallet.collateral.description')
);
expect(await SettingsPage.hdWalletSyncLink.getDescriptionText()).to.equal(
await t('browserView.settings.wallet.walletSync.description')
);
expect(await SettingsPage.currencyLink.getDescriptionText()).to.equal(
await t('browserView.settings.preferences.currency.description')
);
expect(await SettingsPage.themeLink.getDescriptionText()).to.equal(
await t('browserView.settings.preferences.theme.description')
);
expect(await SettingsPage.betaProgramLink.getDescriptionText()).to.equal(
await t('browserView.settings.preferences.betaProgram.description')
);
expect(await SettingsPage.showRecoveryPhraseLink.getDescriptionText()).to.equal(
await t('browserView.settings.security.showPassphrase.description')
);
Expand Down
30 changes: 30 additions & 0 deletions packages/e2e-tests/src/elements/settings/SettingsPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class SettingsPage extends CommonDrawerElements {
private readonly COLLATERAL_LINK_TEST_ID = 'settings-wallet-collateral-link';
private readonly CUSTOM_SUBMIT_API_LINK_TEST_ID = 'settings-wallet-custom-submit-api-link';
private readonly THEME_SWITCH_TEST_ID = '[data-testid="switch"]';
private readonly BETA_PROGRAM_SWITCH_TEST_ID = '[data-testid="settings-beta-program-switch"]';
private readonly SHOW_RECOVERY_PHRASE_LINK_TEST_ID = 'settings-show-recovery-phrase-link';
private readonly GENERATE_PAPER_WALLET_LINK_TEST_ID = 'settings-generate-paperwallet-link';
private readonly PASSPHRASE_VERIFICATION_LINK_TEST_ID = 'settings-passphrase-verification-link';
Expand All @@ -34,6 +35,10 @@ class SettingsPage extends CommonDrawerElements {
private readonly TNC_LINK_TEST_ID = 'settings-legal-tnc-link';
private readonly PRIVACY_POLICY_LINK_TEST_ID = 'settings-legal-privacy-policy-link';
private readonly COOKIE_POLICY_LINK_TEST_ID = 'settings-legal-cookie-policy-link';
private readonly WALLET_SYNC_LINK_TEST_ID = 'settings-wallet-wallet-sync';
private readonly CURRENCY_LINK_TEST_ID = 'settings-wallet-currency-link';
private readonly THEME_LINK_TEST_ID = 'settings-wallet-theme';
private readonly BETA_PROGRAM_LINK_TEST_ID = 'settings-beta-program-section';

get aboutLaceWidget(): typeof AboutLaceWidget {
return AboutLaceWidget;
Expand Down Expand Up @@ -88,6 +93,22 @@ class SettingsPage extends CommonDrawerElements {
return new SettingsLink(this.COLLATERAL_LINK_TEST_ID);
}

get hdWalletSyncLink() {
return new SettingsLink(this.WALLET_SYNC_LINK_TEST_ID);
}

get currencyLink() {
return new SettingsLink(this.CURRENCY_LINK_TEST_ID);
}

get themeLink() {
return new SettingsLink(this.THEME_LINK_TEST_ID);
}

get betaProgramLink() {
return new SettingsLink(this.BETA_PROGRAM_LINK_TEST_ID);
}

get customSubmitAPILink() {
return new SettingsLink(this.CUSTOM_SUBMIT_API_LINK_TEST_ID);
}
Expand Down Expand Up @@ -140,6 +161,10 @@ class SettingsPage extends CommonDrawerElements {
return $(this.THEME_SWITCH_TEST_ID);
}

get betaProgramSwitch(): ChainablePromiseElement<WebdriverIO.Element> {
return $(this.BETA_PROGRAM_SWITCH_TEST_ID);
}

get securitySettingsElements(): ChainablePromiseArray<WebdriverIO.ElementArray> {
return $$(this.SECURITY_SETTINGS_ELEMENTS);
}
Expand All @@ -152,6 +177,11 @@ class SettingsPage extends CommonDrawerElements {
await this.syncButton.waitForClickable();
await this.syncButton.click();
}

async clickBetaProgramSwitch(): Promise<void> {
await this.betaProgramSwitch.waitForClickable();
await this.betaProgramSwitch.click();
}
}

export default new SettingsPage();
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,16 @@ Feature: Analytics - Settings - Extended View
Then I validate latest analytics single event "settings | custom submit api | enable | click"
And I validate that 2 analytics event(s) have been sent

@LW-11798
Scenario: Analytics - Extended View - Beta Program - opt-in/opt-out
When I open settings from header menu
And I set up request interception for posthog analytics request(s)
And I click on "Beta Program" switch
Then I validate latest analytics single event "settings | beta program | opt-in | click"
When I click on "Beta Program" switch
Then I validate latest analytics single event "settings | beta program | opt-out | click"
And I validate that 2 analytics event(s) have been sent

# this test should be executed as the last one in this suite
@LW-8559
Scenario: Analytics - Extended View - Settings - Wallet removal events - Remove wallet
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,16 @@ Feature: Analytics - Settings - Popup View
Then I validate latest analytics single event "settings | custom submit api | enable | click"
And I validate that 2 analytics event(s) have been sent

@LW-11799
Scenario: Analytics - Popup View - Beta Program - opt-in/opt-out
When I open settings from header menu
And I set up request interception for posthog analytics request(s)
And I click on "Beta Program" switch
Then I validate latest analytics single event "settings | beta program | opt-in | click"
When I click on "Beta Program" switch
Then I validate latest analytics single event "settings | beta program | opt-out | click"
And I validate that 2 analytics event(s) have been sent

# this test should be executed as the last one in this suite
@LW-8571
Scenario: Analytics - Popup View - Settings - Wallet removal events - Remove wallet
Expand Down
4 changes: 4 additions & 0 deletions packages/e2e-tests/src/steps/settingsSteps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -400,3 +400,7 @@ Then(
await SaveYourPaperWalletDrawerAssert.assertSeeSaveYourPaperWalletPage(expectedPaperWalletName);
}
);

When(/^I click on "Beta Program" switch$/, async () => {
await SettingsPage.clickBetaProgramSwitch();
});

0 comments on commit d2fc6bd

Please sign in to comment.