From d38ecb3a150e33b088ae0362dd537c72704d3a5c Mon Sep 17 00:00:00 2001 From: Martin Vere Cihlar Date: Thu, 12 Dec 2024 09:22:41 +0100 Subject: [PATCH 1/2] refactor(e2e): Renames core playwright object - page --- .../e2e/support/analytics.ts | 8 +-- .../suite-desktop-core/e2e/support/bridge.ts | 4 +- .../e2e/support/fixtures.ts | 53 +++++++-------- .../support/pageActions/dashboardActions.ts | 30 ++++---- .../support/pageActions/onboardingActions.ts | 24 +++---- .../support/pageActions/settingsActions.ts | 68 +++++++++---------- .../support/pageActions/suiteGuideActions.ts | 42 ++++++------ .../e2e/support/pageActions/walletActions.ts | 24 +++---- .../e2e/tests/settings/autodetect.test.ts | 2 +- .../e2e/tests/settings/coins.test.ts | 2 +- .../tests/settings/custom-firmware.test.ts | 2 +- .../e2e/tests/settings/general.test.ts | 2 +- .../e2e/tests/settings/safety-checks.test.ts | 8 +-- .../settings/t1b1-device-settings.test.ts | 4 +- .../settings/t2b1-device-settings.test.ts | 6 +- .../settings/t2t1-device-settings.test.ts | 8 +-- 16 files changed, 143 insertions(+), 144 deletions(-) diff --git a/packages/suite-desktop-core/e2e/support/analytics.ts b/packages/suite-desktop-core/e2e/support/analytics.ts index 3950a616e8a..09844037102 100644 --- a/packages/suite-desktop-core/e2e/support/analytics.ts +++ b/packages/suite-desktop-core/e2e/support/analytics.ts @@ -5,11 +5,11 @@ import { Requests, EventPayload } from '@trezor/suite-web/e2e/support/types'; import { urlSearchParams } from '@trezor/suite/src/utils/suite/metadata'; export class AnalyticsFixture { - private window: Page; + private page: Page; requests: Requests = []; - constructor(window: Page) { - this.window = window; + constructor(page: Page) { + this.page = page; } //TODO: #15811 To be refactored @@ -25,7 +25,7 @@ export class AnalyticsFixture { //TODO: #15811 To be refactored async interceptAnalytics() { - await this.window.route('**://data.trezor.io/suite/log/**', route => { + await this.page.route('**://data.trezor.io/suite/log/**', route => { const url = route.request().url(); const params = urlSearchParams(url); this.requests.push(params); diff --git a/packages/suite-desktop-core/e2e/support/bridge.ts b/packages/suite-desktop-core/e2e/support/bridge.ts index e5ecd31ac5e..8d917a1bac3 100644 --- a/packages/suite-desktop-core/e2e/support/bridge.ts +++ b/packages/suite-desktop-core/e2e/support/bridge.ts @@ -20,6 +20,6 @@ export const expectBridgeToBeStopped = async (request: APIRequestContext) => { // Bridge should be ready to check `/status` endpoint. export const waitForAppToBeInitialized = async (suite: any) => await Promise.race([ - expect(suite.window.getByTestId('@welcome/title')).toBeVisible(), - expect(suite.window.getByTestId('@dashboard/graph')).toBeVisible(), + expect(suite.page.getByTestId('@welcome/title')).toBeVisible(), + expect(suite.page.getByTestId('@dashboard/graph')).toBeVisible(), ]); diff --git a/packages/suite-desktop-core/e2e/support/fixtures.ts b/packages/suite-desktop-core/e2e/support/fixtures.ts index 86cb1e92b0d..16a3b0f3b87 100644 --- a/packages/suite-desktop-core/e2e/support/fixtures.ts +++ b/packages/suite-desktop-core/e2e/support/fixtures.ts @@ -1,5 +1,5 @@ /* eslint-disable react-hooks/rules-of-hooks */ -import { test as base, ElectronApplication, Page } from '@playwright/test'; +import { test as base, Page } from '@playwright/test'; import { SetupEmu, @@ -23,8 +23,8 @@ type Fixtures = { emulatorSetupConf: SetupEmu; apiURL: string; trezorUserEnvLink: TrezorUserEnvLinkClass; - appContext: ElectronApplication | undefined; - window: Page; + electronWindow: Page | undefined; + page: Page; dashboardPage: DashboardActions; settingsPage: SettingsActions; suiteGuidePage: SuiteGuide; @@ -44,7 +44,7 @@ const test = base.extend({ trezorUserEnvLink: async ({}, use) => { await use(TrezorUserEnvLink); }, - appContext: async ( + electronWindow: async ( { trezorUserEnvLink, startEmulator, @@ -71,7 +71,7 @@ const test = base.extend({ colorScheme, videoFolder: testInfo.outputDir, }); - await use(suite.electronApp); + await use(suite.window); await suite.electronApp.close(); // Ensure cleanup after tests } else { if (startEmulator) { @@ -80,14 +80,13 @@ const test = base.extend({ await use(undefined); } }, - window: async ({ appContext, page }, use, testInfo) => { - if (appContext) { - await page.close(); // Close the default chromium page - const window = await appContext.firstWindow(); - await window.context().tracing.start({ screenshots: true, snapshots: true }); - await use(window); + page: async ({ electronWindow, page: webPage }, use, testInfo) => { + if (electronWindow) { + await webPage.close(); // Close the default chromium page + await electronWindow.context().tracing.start({ screenshots: true, snapshots: true }); + await use(electronWindow); const tracePath = `${testInfo.outputDir}/trace.electron.zip`; - await window.context().tracing.stop({ path: tracePath }); + await electronWindow.context().tracing.stop({ path: tracePath }); testInfo.attachments.push({ name: 'trace', path: tracePath, @@ -99,40 +98,40 @@ const test = base.extend({ contentType: 'video/webm', }); } else { - await page.context().addInitScript(() => { + await webPage.context().addInitScript(() => { // Tells the app to attach Redux Store to window object. packages/suite-web/src/support/useCypress.ts window.Playwright = true; }); - await page.goto('./'); - await use(page); + await webPage.goto('./'); + await use(webPage); } }, - dashboardPage: async ({ window }, use) => { - const dashboardPage = new DashboardActions(window); + dashboardPage: async ({ page }, use) => { + const dashboardPage = new DashboardActions(page); await use(dashboardPage); }, - settingsPage: async ({ window, apiURL }, use) => { - const settingsPage = new SettingsActions(window, apiURL); + settingsPage: async ({ page, apiURL }, use) => { + const settingsPage = new SettingsActions(page, apiURL); await use(settingsPage); }, - suiteGuidePage: async ({ window }, use) => { - const suiteGuidePage = new SuiteGuide(window); + suiteGuidePage: async ({ page }, use) => { + const suiteGuidePage = new SuiteGuide(page); await use(suiteGuidePage); }, - walletPage: async ({ window }, use) => { - const walletPage = new WalletActions(window); + walletPage: async ({ page }, use) => { + const walletPage = new WalletActions(page); await use(walletPage); }, - onboardingPage: async ({ window, emulatorStartConf }, use, testInfo) => { + onboardingPage: async ({ page, emulatorStartConf }, use, testInfo) => { const onboardingPage = new OnboardingActions( - window, + page, emulatorStartConf.model ?? TrezorUserEnvLink.defaultModel, testInfo, ); await use(onboardingPage); }, - analytics: async ({ window }, use) => { - const analytics = new AnalyticsFixture(window); + analytics: async ({ page }, use) => { + const analytics = new AnalyticsFixture(page); await use(analytics); }, }); diff --git a/packages/suite-desktop-core/e2e/support/pageActions/dashboardActions.ts b/packages/suite-desktop-core/e2e/support/pageActions/dashboardActions.ts index 4e558e41776..9be72f4d365 100644 --- a/packages/suite-desktop-core/e2e/support/pageActions/dashboardActions.ts +++ b/packages/suite-desktop-core/e2e/support/pageActions/dashboardActions.ts @@ -3,7 +3,7 @@ import { Locator, Page, expect } from '@playwright/test'; import { NetworkSymbol } from '@suite-common/wallet-config'; export class DashboardActions { - private readonly window: Page; + private readonly page: Page; readonly dashboardMenuButton: Locator; readonly discoveryHeader: Locator; readonly discoveryBar: Locator; @@ -11,24 +11,24 @@ export class DashboardActions { readonly deviceSwitchingOpenButton: Locator; readonly modal: Locator; readonly walletAtIndex = (index: number) => - this.window.getByTestId(`@switch-device/wallet-on-index/${index}`); + this.page.getByTestId(`@switch-device/wallet-on-index/${index}`); readonly walletAtIndexEjectButton = (index: number) => - this.window.getByTestId(`@switch-device/wallet-on-index/${index}/eject-button`); + this.page.getByTestId(`@switch-device/wallet-on-index/${index}/eject-button`); readonly confirmDeviceEjectButton: Locator; readonly addStandardWalletButton: Locator; readonly balanceOfNetwork = (symbol: NetworkSymbol) => - this.window.getByTestId(`@wallet/coin-balance/value-${symbol}`); - - constructor(window: Page) { - this.window = window; - this.dashboardMenuButton = this.window.getByTestId('@suite/menu/suite-index'); - this.discoveryHeader = this.window.getByRole('heading', { name: 'Dashboard' }); - this.discoveryBar = this.window.getByTestId('@wallet/discovery-progress-bar'); - this.dashboardGraph = this.window.getByTestId('@dashboard/graph'); - this.deviceSwitchingOpenButton = this.window.getByTestId('@menu/switch-device'); - this.modal = this.window.getByTestId('@modal'); - this.confirmDeviceEjectButton = this.window.getByTestId('@switch-device/eject'); - this.addStandardWalletButton = this.window.getByTestId('@switch-device/add-wallet-button'); + this.page.getByTestId(`@wallet/coin-balance/value-${symbol}`); + + constructor(page: Page) { + this.page = page; + this.dashboardMenuButton = this.page.getByTestId('@suite/menu/suite-index'); + this.discoveryHeader = this.page.getByRole('heading', { name: 'Dashboard' }); + this.discoveryBar = this.page.getByTestId('@wallet/discovery-progress-bar'); + this.dashboardGraph = this.page.getByTestId('@dashboard/graph'); + this.deviceSwitchingOpenButton = this.page.getByTestId('@menu/switch-device'); + this.modal = this.page.getByTestId('@modal'); + this.confirmDeviceEjectButton = this.page.getByTestId('@switch-device/eject'); + this.addStandardWalletButton = this.page.getByTestId('@switch-device/add-wallet-button'); } async navigateTo() { diff --git a/packages/suite-desktop-core/e2e/support/pageActions/onboardingActions.ts b/packages/suite-desktop-core/e2e/support/pageActions/onboardingActions.ts index 5515a563d22..30cdb3b249e 100644 --- a/packages/suite-desktop-core/e2e/support/pageActions/onboardingActions.ts +++ b/packages/suite-desktop-core/e2e/support/pageActions/onboardingActions.ts @@ -20,21 +20,21 @@ export class OnboardingActions { isModelWithSecureElement = () => ['T2B1', 'T3T1'].includes(this.model); constructor( - public window: Page, + public page: Page, model: Model, testInfo: TestInfo, ) { this.model = model; this.testInfo = testInfo; - this.welcomeTitle = this.window.getByTestId('@welcome/title'); - this.analyticsHeading = this.window.getByTestId('@analytics/consent/heading'); - this.analyticsContinueButton = this.window.getByTestId('@analytics/continue-button'); - this.onboardingContinueButton = this.window.getByTestId('@onboarding/exit-app-button'); - this.onboardingViewOnlySkipButton = this.window.getByTestId('@onboarding/viewOnly/skip'); - this.viewOnlyTooltipGotItButton = this.window.getByTestId('@viewOnlyTooltip/gotIt'); - this.connectDevicePrompt = this.window.getByTestId('@connect-device-prompt'); - this.authenticityStartButton = this.window.getByTestId('@authenticity-check/start-button'); - this.authenticityContinueButton = this.window.getByTestId( + this.welcomeTitle = this.page.getByTestId('@welcome/title'); + this.analyticsHeading = this.page.getByTestId('@analytics/consent/heading'); + this.analyticsContinueButton = this.page.getByTestId('@analytics/continue-button'); + this.onboardingContinueButton = this.page.getByTestId('@onboarding/exit-app-button'); + this.onboardingViewOnlySkipButton = this.page.getByTestId('@onboarding/viewOnly/skip'); + this.viewOnlyTooltipGotItButton = this.page.getByTestId('@viewOnlyTooltip/gotIt'); + this.connectDevicePrompt = this.page.getByTestId('@connect-device-prompt'); + this.authenticityStartButton = this.page.getByTestId('@authenticity-check/start-button'); + this.authenticityContinueButton = this.page.getByTestId( '@authenticity-check/continue-button', ); } @@ -42,7 +42,7 @@ export class OnboardingActions { async optionallyDismissFwHashCheckError() { await expect(this.welcomeTitle).toBeVisible({ timeout: 10000 }); // dismisses the error modal only if it appears (handle it async in parallel, not necessary to block the rest of the flow) - this.window + this.page .$('[data-testid="@device-compromised/back-button"]') .then(dismissFwHashCheckButton => dismissFwHashCheckButton?.click()); } @@ -67,7 +67,7 @@ export class OnboardingActions { // Desktop starts with already disabled firmware hash check. Web needs to disable it. await expect(this.welcomeTitle).toBeVisible({ timeout: 10000 }); // eslint-disable-next-line @typescript-eslint/no-shadow - await this.window.evaluate(SuiteActions => { + await this.page.evaluate(SuiteActions => { window.store.dispatch({ type: SuiteActions.DEVICE_FIRMWARE_HASH_CHECK, payload: { isDisabled: true }, diff --git a/packages/suite-desktop-core/e2e/support/pageActions/settingsActions.ts b/packages/suite-desktop-core/e2e/support/pageActions/settingsActions.ts index 3727c67a101..cb11b2f601a 100644 --- a/packages/suite-desktop-core/e2e/support/pageActions/settingsActions.ts +++ b/packages/suite-desktop-core/e2e/support/pageActions/settingsActions.ts @@ -36,7 +36,7 @@ const backgroundImages = { }; export class SettingsActions { - private readonly window: Page; + private readonly page: Page; private readonly apiURL: string; private readonly TIMES_CLICK_TO_SET_DEBUG_MODE = 5; readonly settingsMenuButton: Locator; @@ -59,56 +59,56 @@ export class SettingsActions { readonly pinSubmitButton: Locator; //coin Advance settings readonly networkButton = (symbol: NetworkSymbol) => - this.window.getByTestId(`@settings/wallet/network/${symbol}`); + this.page.getByTestId(`@settings/wallet/network/${symbol}`); readonly networkSymbolAdvanceSettingsButton = (symbol: NetworkSymbol) => - this.window.getByTestId(`@settings/wallet/network/${symbol}/advance`); + this.page.getByTestId(`@settings/wallet/network/${symbol}/advance`); readonly coinBackendSelector: Locator; readonly coinBackendSelectorOption = (backend: BackendType) => - this.window.getByTestId(`@settings/advance/${backend}`); + this.page.getByTestId(`@settings/advance/${backend}`); readonly coinAddressInput: Locator; readonly coinAdvanceSettingSaveButton: Locator; readonly themeInput: Locator; readonly themeInputOption = (theme: Theme) => - this.window.getByTestId(`@theme/color-scheme-select/option/${theme}`); + this.page.getByTestId(`@theme/color-scheme-select/option/${theme}`); readonly languageInput: Locator; readonly languageInputOption = (language: Language) => - this.window.getByTestId(`@settings/language-select/option/${language}`); - readonly pinInput = (index: number) => this.window.getByTestId(`@pin/input/${index}`); + this.page.getByTestId(`@settings/language-select/option/${language}`); + readonly pinInput = (index: number) => this.page.getByTestId(`@pin/input/${index}`); - constructor(window: Page, apiURL: string) { - this.window = window; + constructor(page: Page, apiURL: string) { + this.page = page; this.apiURL = apiURL; - this.settingsMenuButton = this.window.getByTestId('@suite/menu/settings'); - this.settingsHeader = this.window.getByTestId('@settings/menu/title'); - this.debugTabButton = this.window.getByTestId('@settings/menu/debug'); - this.applicationTabButton = this.window.getByTestId('@settings/menu/general'); - this.deviceTabButton = this.window.getByTestId('@settings/menu/device'); - this.coinsTabButton = this.window.getByTestId('@settings/menu/wallet'); - this.earlyAccessJoinButton = this.window.getByTestId('@settings/early-access-join-button'); - this.earlyAccessConfirmCheck = this.window.getByTestId( + this.settingsMenuButton = this.page.getByTestId('@suite/menu/settings'); + this.settingsHeader = this.page.getByTestId('@settings/menu/title'); + this.debugTabButton = this.page.getByTestId('@settings/menu/debug'); + this.applicationTabButton = this.page.getByTestId('@settings/menu/general'); + this.deviceTabButton = this.page.getByTestId('@settings/menu/device'); + this.coinsTabButton = this.page.getByTestId('@settings/menu/wallet'); + this.earlyAccessJoinButton = this.page.getByTestId('@settings/early-access-join-button'); + this.earlyAccessConfirmCheck = this.page.getByTestId( '@settings/early-access-confirm-check', ); - this.earlyAccessConfirmButton = this.window.getByTestId( + this.earlyAccessConfirmButton = this.page.getByTestId( '@settings/early-access-confirm-button', ); - this.earlyAccessSkipButton = this.window.getByTestId('@settings/early-access-skip-button'); - this.settingsCloseButton = this.window.getByTestId('@settings/menu/close'); - this.modal = this.window.getByTestId('@modal'); - this.deviceLabelInput = this.window.getByTestId('@settings/device/label-input'); - this.deviceLabelSubmit = this.window.getByTestId('@settings/device/label-submit'); - this.confirmOnDevicePrompt = this.window.getByTestId('@prompts/confirm-on-device'); - this.homescreenGalleryButton = this.window.getByTestId( + this.earlyAccessSkipButton = this.page.getByTestId('@settings/early-access-skip-button'); + this.settingsCloseButton = this.page.getByTestId('@settings/menu/close'); + this.modal = this.page.getByTestId('@modal'); + this.deviceLabelInput = this.page.getByTestId('@settings/device/label-input'); + this.deviceLabelSubmit = this.page.getByTestId('@settings/device/label-submit'); + this.confirmOnDevicePrompt = this.page.getByTestId('@prompts/confirm-on-device'); + this.homescreenGalleryButton = this.page.getByTestId( '@settings/device/homescreen-gallery', ); - this.notificationSuccessToast = this.window.getByTestId('@toast/settings-applied').first(); - this.coinBackendSelector = this.window.getByTestId('@settings/advance/select-type/input'); - this.coinAddressInput = this.window.getByTestId('@settings/advance/url'); - this.coinAdvanceSettingSaveButton = this.window.getByTestId( + this.notificationSuccessToast = this.page.getByTestId('@toast/settings-applied').first(); + this.coinBackendSelector = this.page.getByTestId('@settings/advance/select-type/input'); + this.coinAddressInput = this.page.getByTestId('@settings/advance/url'); + this.coinAdvanceSettingSaveButton = this.page.getByTestId( '@settings/advance/button/save', ); - this.themeInput = this.window.getByTestId('@theme/color-scheme-select/input'); - this.languageInput = this.window.getByTestId('@settings/language-select/input'); - this.pinSubmitButton = this.window.getByTestId('@pin/submit-button'); + this.themeInput = this.page.getByTestId('@theme/color-scheme-select/input'); + this.languageInput = this.page.getByTestId('@settings/language-select/input'); + this.pinSubmitButton = this.page.getByTestId('@pin/submit-button'); } async navigateTo() { @@ -205,12 +205,12 @@ export class SettingsActions { async changeDeviceBackground(image: keyof typeof backgroundImages) { await test.step('Change display background image', async () => { // To solve the flakiness of the test, we need to wait for the image to load - const buttonImageLoad = this.window.waitForResponse( + const buttonImageLoad = this.page.waitForResponse( `${this.apiURL}${backgroundImages[image].path}`, ); await this.homescreenGalleryButton.click(); await buttonImageLoad; - await this.window.getByTestId(backgroundImages[image].locator).click(); + await this.page.getByTestId(backgroundImages[image].locator).click(); await expect(this.confirmOnDevicePrompt).toBeVisible(); await TrezorUserEnvLink.pressYes(); await this.confirmOnDevicePrompt.waitFor({ state: 'detached' }); diff --git a/packages/suite-desktop-core/e2e/support/pageActions/suiteGuideActions.ts b/packages/suite-desktop-core/e2e/support/pageActions/suiteGuideActions.ts index 681cac9933c..bde3d892c46 100644 --- a/packages/suite-desktop-core/e2e/support/pageActions/suiteGuideActions.ts +++ b/packages/suite-desktop-core/e2e/support/pageActions/suiteGuideActions.ts @@ -6,7 +6,7 @@ import { capitalizeFirstLetter } from '@trezor/utils'; const anyTestIdEndingWithClose = '[data-testid$="close"]'; export class SuiteGuide { - private readonly window: Page; + private readonly page: Page; readonly guideButton: Locator; readonly supportAndFeedbackButton: Locator; readonly bugFormButton: Locator; @@ -14,7 +14,7 @@ export class SuiteGuide { readonly bugLocationDropdown: Locator; readonly bugLocationDropdownInput: Locator; readonly bugLocationDropdownOption = (location: FeedbackCategory) => - this.window.getByTestId(`@guide/feedback/suggestion-dropdown/select/option/${location}`); + this.page.getByTestId(`@guide/feedback/suggestion-dropdown/select/option/${location}`); readonly bugInputTextField: Locator; readonly submitButton: Locator; readonly closeButton: Locator; @@ -22,30 +22,30 @@ export class SuiteGuide { readonly searchInput: Locator; readonly searchResults: Locator; readonly articleWithText = (text: string) => - this.window.locator(`[data-testid^="@guide/node"]`, { hasText: text }); + this.page.locator(`[data-testid^="@guide/node"]`, { hasText: text }); readonly toastNotifications: Locator; readonly feedbackSuccessToast: Locator; readonly articleHeader: Locator; - constructor(window: Page) { - this.window = window; - this.guideButton = this.window.getByTestId('@guide/button-open'); - this.supportAndFeedbackButton = this.window.getByTestId('@guide/button-feedback'); - this.bugFormButton = this.window.getByTestId('@guide/feedback/bug'); - this.feedbackFormButton = this.window.getByTestId('@guide/feedback/suggestion'); - this.bugLocationDropdown = this.window.getByTestId('@guide/feedback/suggestion-dropdown'); - this.bugLocationDropdownInput = this.window.getByTestId( + constructor(page: Page) { + this.page = page; + this.guideButton = this.page.getByTestId('@guide/button-open'); + this.supportAndFeedbackButton = this.page.getByTestId('@guide/button-feedback'); + this.bugFormButton = this.page.getByTestId('@guide/feedback/bug'); + this.feedbackFormButton = this.page.getByTestId('@guide/feedback/suggestion'); + this.bugLocationDropdown = this.page.getByTestId('@guide/feedback/suggestion-dropdown'); + this.bugLocationDropdownInput = this.page.getByTestId( '@guide/feedback/suggestion-dropdown/select/input', ); - this.bugInputTextField = this.window.getByTestId('@guide/feedback/suggestion-form'); - this.submitButton = this.window.getByTestId('@guide/feedback/submit-button'); - this.closeButton = this.window.getByTestId('@guide/button-close'); - this.guidePanel = this.window.getByTestId('@guide/panel'); - this.searchInput = this.window.getByTestId('@guide/search'); - this.searchResults = this.window.getByTestId('@guide/search/results'); - this.toastNotifications = this.window.locator('[data-testid-alt="@toast"]'); - this.feedbackSuccessToast = this.window.getByTestId('@toast/user-feedback-send-success'); - this.articleHeader = this.window.getByTestId('@guide/article').locator('h1'); + this.bugInputTextField = this.page.getByTestId('@guide/feedback/suggestion-form'); + this.submitButton = this.page.getByTestId('@guide/feedback/submit-button'); + this.closeButton = this.page.getByTestId('@guide/button-close'); + this.guidePanel = this.page.getByTestId('@guide/panel'); + this.searchInput = this.page.getByTestId('@guide/search'); + this.searchResults = this.page.getByTestId('@guide/search/results'); + this.toastNotifications = this.page.locator('[data-testid-alt="@toast"]'); + this.feedbackSuccessToast = this.page.getByTestId('@toast/user-feedback-send-success'); + this.articleHeader = this.page.getByTestId('@guide/article').locator('h1'); } async openPanel() { @@ -63,7 +63,7 @@ export class SuiteGuide { await this.bugFormButton.click(); await this.selectBugLocation(args.location); // stability necessity - await this.window.waitForTimeout(250); + await this.page.waitForTimeout(250); await this.bugInputTextField.fill(args.report); await this.submitButton.click(); } diff --git a/packages/suite-desktop-core/e2e/support/pageActions/walletActions.ts b/packages/suite-desktop-core/e2e/support/pageActions/walletActions.ts index 3ff5120a862..e915846df25 100644 --- a/packages/suite-desktop-core/e2e/support/pageActions/walletActions.ts +++ b/packages/suite-desktop-core/e2e/support/pageActions/walletActions.ts @@ -3,7 +3,7 @@ import { Locator, Page, expect } from '@playwright/test'; import { NetworkSymbol } from '@suite-common/wallet-config'; export class WalletActions { - private readonly window: Page; + private readonly page: Page; readonly walletMenuButton: Locator; readonly searchInput: Locator; readonly accountChevron: Locator; @@ -11,18 +11,18 @@ export class WalletActions { readonly walletStakingButton: Locator; readonly stakeAddress: Locator; - constructor(window: Page) { - this.window = window; - this.walletMenuButton = this.window.getByTestId('@suite/menu/wallet-index'); - this.searchInput = this.window.getByTestId('@wallet/accounts/search-icon'); - this.accountChevron = this.window.getByTestId('@account-menu/arrow'); + constructor(page: Page) { + this.page = page; + this.walletMenuButton = this.page.getByTestId('@suite/menu/wallet-index'); + this.searchInput = this.page.getByTestId('@wallet/accounts/search-icon'); + this.accountChevron = this.page.getByTestId('@account-menu/arrow'); this.cardanoAccountLabels = { - normal: this.window.getByTestId('@account-menu/ada/normal/0/label'), - legacy: this.window.getByTestId('@account-menu/ada/legacy/0/label'), - ledger: this.window.getByTestId('@account-menu/ada/ledger/0/label'), + normal: this.page.getByTestId('@account-menu/ada/normal/0/label'), + legacy: this.page.getByTestId('@account-menu/ada/legacy/0/label'), + ledger: this.page.getByTestId('@account-menu/ada/ledger/0/label'), }; - this.walletStakingButton = this.window.getByTestId('@wallet/menu/staking'); - this.stakeAddress = this.window.getByTestId('@cardano/staking/address'); + this.walletStakingButton = this.page.getByTestId('@wallet/menu/staking'); + this.stakeAddress = this.page.getByTestId('@cardano/staking/address'); } async filterTransactions(transaction: string) { @@ -45,7 +45,7 @@ export class WalletActions { } async getAccountsCount(symbol: NetworkSymbol) { - return await this.window + return await this.page .locator(`[data-testid*="@account-menu/${symbol}"][tabindex]`) .count(); } diff --git a/packages/suite-desktop-core/e2e/tests/settings/autodetect.test.ts b/packages/suite-desktop-core/e2e/tests/settings/autodetect.test.ts index 2485232a33d..7dc5df850eb 100644 --- a/packages/suite-desktop-core/e2e/tests/settings/autodetect.test.ts +++ b/packages/suite-desktop-core/e2e/tests/settings/autodetect.test.ts @@ -41,7 +41,7 @@ testCases.forEach(({ testName, userPreferences, text, textColor, bodyBackgroundC await onboardingPage.optionallyDismissFwHashCheckError(); await expect(onboardingPage.analyticsHeading).toHaveText(text); await expect(onboardingPage.analyticsHeading).toHaveCSS('color', textColor); - await expect(onboardingPage.window.locator('body')).toHaveCSS( + await expect(onboardingPage.page.locator('body')).toHaveCSS( 'background-color', bodyBackgroundColor, ); diff --git a/packages/suite-desktop-core/e2e/tests/settings/coins.test.ts b/packages/suite-desktop-core/e2e/tests/settings/coins.test.ts index 465bd9d5c31..cfe5ebba79e 100644 --- a/packages/suite-desktop-core/e2e/tests/settings/coins.test.ts +++ b/packages/suite-desktop-core/e2e/tests/settings/coins.test.ts @@ -15,7 +15,7 @@ test.describe('Coin Settings', { tag: ['@group=settings'] }, () => { test('go to wallet settings page, check BTC, activate all coins, deactivate all coins, set custom backend', async ({ dashboardPage, settingsPage, - window: page, + page, }) => { const defaultUnchecked: NetworkSymbol[] = [ 'ltc', diff --git a/packages/suite-desktop-core/e2e/tests/settings/custom-firmware.test.ts b/packages/suite-desktop-core/e2e/tests/settings/custom-firmware.test.ts index c96e241d453..ec13a1aa781 100644 --- a/packages/suite-desktop-core/e2e/tests/settings/custom-firmware.test.ts +++ b/packages/suite-desktop-core/e2e/tests/settings/custom-firmware.test.ts @@ -12,7 +12,7 @@ test.describe('Custom firmware', { tag: ['@group=settings'] }, () => { await settingsPage.deviceTabButton.click(); }); - test('Custom firmware installation', async ({ window: page }) => { + test('Custom firmware installation', async ({ page }) => { await test.step('Start `Install firmware` flow', async () => { await page.getByTestId('@settings/device/custom-firmware-modal-button').click(); await expect(page.getByTestId('@firmware-modal/install-button')).toBeDisabled(); diff --git a/packages/suite-desktop-core/e2e/tests/settings/general.test.ts b/packages/suite-desktop-core/e2e/tests/settings/general.test.ts index 60c4e328eff..f52a020ffc4 100644 --- a/packages/suite-desktop-core/e2e/tests/settings/general.test.ts +++ b/packages/suite-desktop-core/e2e/tests/settings/general.test.ts @@ -20,7 +20,7 @@ test.describe('General settings', { tag: ['@group=settings'] }, () => { analytics, settingsPage, dashboardPage, - window: page, + page, }) => { await test.step('Check default currency is USD', async () => { await expect(page.getByTestId('@dashboard/index')).toContainText('$0.00'); diff --git a/packages/suite-desktop-core/e2e/tests/settings/safety-checks.test.ts b/packages/suite-desktop-core/e2e/tests/settings/safety-checks.test.ts index 44ee9683034..be06fad7048 100644 --- a/packages/suite-desktop-core/e2e/tests/settings/safety-checks.test.ts +++ b/packages/suite-desktop-core/e2e/tests/settings/safety-checks.test.ts @@ -9,13 +9,13 @@ test.describe('Safety Checks Settings', { tag: ['@group=settings'] }, () => { }); test('There is button in device settings, that opens safety checks modal.', async ({ - window: page, + page, }) => { await page.getByTestId('@settings/device/safety-checks-button').click(); await expect(page.getByTestId('@safety-checks-apply')).toBeVisible(); }); - test('Only one level is selected at a time', async ({ window: page }) => { + test('Only one level is selected at a time', async ({ page }) => { // Open the safety checks modal. await page.getByTestId('@settings/device/safety-checks-button').click(); @@ -38,7 +38,7 @@ test.describe('Safety Checks Settings', { tag: ['@group=settings'] }, () => { ).toHaveCount(1); }); - test('Apply button is enabled only when value is changed', async ({ window: page }) => { + test('Apply button is enabled only when value is changed', async ({ page }) => { // Open the safety checks modal. await page.getByTestId('@settings/device/safety-checks-button').click(); @@ -48,7 +48,7 @@ test.describe('Safety Checks Settings', { tag: ['@group=settings'] }, () => { }); test('Device safety_check setting is changed after pressing the apply button', async ({ - window: page, + page, trezorUserEnvLink, }) => { await page.getByTestId('@settings/device/safety-checks-button').click(); diff --git a/packages/suite-desktop-core/e2e/tests/settings/t1b1-device-settings.test.ts b/packages/suite-desktop-core/e2e/tests/settings/t1b1-device-settings.test.ts index 05bb0fcb936..3b9748fbede 100644 --- a/packages/suite-desktop-core/e2e/tests/settings/t1b1-device-settings.test.ts +++ b/packages/suite-desktop-core/e2e/tests/settings/t1b1-device-settings.test.ts @@ -10,7 +10,7 @@ test.describe('T1B1 - Device settings', { tag: ['@group=settings'] }, () => { await settingsPage.deviceTabButton.click(); }); - test('enable pin', async ({ window: page, trezorUserEnvLink, settingsPage }) => { + test('enable pin', async ({ page, trezorUserEnvLink, settingsPage }) => { await page.getByTestId('@settings/device/pin-switch').click(); await expect(page.getByTestId('@prompts/confirm-on-device')).toBeVisible(); await trezorUserEnvLink.pressYes(); @@ -22,7 +22,7 @@ test.describe('T1B1 - Device settings', { tag: ['@group=settings'] }, () => { await expect(page.getByTestId('@toast/pin-changed')).toBeVisible(); }); - test('pin mismatch', async ({ window: page, trezorUserEnvLink }) => { + test('pin mismatch', async ({ page, trezorUserEnvLink }) => { await page.getByTestId('@settings/device/pin-switch').click(); await expect(page.getByTestId('@prompts/confirm-on-device')).toBeVisible(); await trezorUserEnvLink.pressYes(); diff --git a/packages/suite-desktop-core/e2e/tests/settings/t2b1-device-settings.test.ts b/packages/suite-desktop-core/e2e/tests/settings/t2b1-device-settings.test.ts index c736c1196ef..484fcd5580e 100644 --- a/packages/suite-desktop-core/e2e/tests/settings/t2b1-device-settings.test.ts +++ b/packages/suite-desktop-core/e2e/tests/settings/t2b1-device-settings.test.ts @@ -16,7 +16,7 @@ test.describe.serial('T2B1 - Device settings', { tag: ['@group=settings'] }, () await settingsPage.deviceTabButton.click(); }); - test('change all possible device settings', async ({ settingsPage, window: page }) => { + test('change all possible device settings', async ({ settingsPage, page }) => { await test.step('Verify firmware modal', async () => { await page.getByTestId('@settings/device/update-button').click(); await page.getByTestId('@modal/close-button').click(); @@ -31,7 +31,7 @@ test.describe.serial('T2B1 - Device settings', { tag: ['@group=settings'] }, () await settingsPage.changeDeviceBackground('circleweb'); }); - test('Device Wipe', async ({ window: page, trezorUserEnvLink }) => { + test('Device Wipe', async ({ page, trezorUserEnvLink }) => { await page.getByTestId('@settings/device/open-wipe-modal-button').click(); await page.getByTestId('@wipe/checkbox-1').click(); await page.getByTestId('@wipe/checkbox-2').click(); @@ -40,7 +40,7 @@ test.describe.serial('T2B1 - Device settings', { tag: ['@group=settings'] }, () //TODO: Verification? }); - test('Backup in settings', async ({ window: page }) => { + test('Backup in settings', async ({ page }) => { await expect(page.getByTestId('@settings/device/check-seed-button')).toBeEnabled(); await page.getByTestId('@settings/device/failed-backup-row').waitFor({ state: 'detached' }); await page.getByTestId('@settings/device/check-seed-button').click(); diff --git a/packages/suite-desktop-core/e2e/tests/settings/t2t1-device-settings.test.ts b/packages/suite-desktop-core/e2e/tests/settings/t2t1-device-settings.test.ts index 6a8f441c60f..5839889787e 100644 --- a/packages/suite-desktop-core/e2e/tests/settings/t2t1-device-settings.test.ts +++ b/packages/suite-desktop-core/e2e/tests/settings/t2t1-device-settings.test.ts @@ -9,7 +9,7 @@ test.describe('T2T1 - Device settings', { tag: ['@group=settings'] }, () => { }); test('change all possible device settings', async ({ - window: page, + page, settingsPage, trezorUserEnvLink, }) => { @@ -32,7 +32,7 @@ test.describe('T2T1 - Device settings', { tag: ['@group=settings'] }, () => { }); }); - test('Device Wipe', async ({ window: page, trezorUserEnvLink }) => { + test('Device Wipe', async ({ page, trezorUserEnvLink }) => { await page.getByTestId('@settings/device/open-wipe-modal-button').click(); await page.getByTestId('@wipe/checkbox-1').click(); await page.getByTestId('@wipe/checkbox-2').click(); @@ -41,7 +41,7 @@ test.describe('T2T1 - Device settings', { tag: ['@group=settings'] }, () => { //TODO: Any verification? }); - test('Backup in settings', async ({ window: page }) => { + test('Backup in settings', async ({ page }) => { await expect(page.getByTestId('@settings/device/check-seed-button')).toBeVisible(); await page.getByTestId('@settings/device/failed-backup-row').waitFor({ state: 'detached' }); await page.getByTestId('@settings/device/check-seed-button').click(); @@ -55,7 +55,7 @@ test.describe('T2T1 - Device settings', { tag: ['@group=settings'] }, () => { test.describe('T2T1 - older firmware < 2.5.4', { tag: ['@group=settings'] }, () => { test.use({ emulatorStartConf: { wipe: true, model: 'T2T1', version: '2.5.3' } }); - test('Cannot change homescreen in firmware < 2.5.4', async ({ window: page }) => { + test('Cannot change homescreen in firmware < 2.5.4', async ({ page }) => { await expect(page.getByTestId('@settings/device/homescreen-gallery')).toBeDisabled(); await expect(page.getByTestId('@settings/device/homescreen-upload')).toBeDisabled(); }); From 05dc662641840b4d175c7f29f58a843ed5e68432 Mon Sep 17 00:00:00 2001 From: Martin Vere Cihlar Date: Mon, 16 Dec 2024 08:27:56 +0100 Subject: [PATCH 2/2] fix(e2e): Fix Linting --- .../e2e/support/pageActions/settingsActions.ts | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/packages/suite-desktop-core/e2e/support/pageActions/settingsActions.ts b/packages/suite-desktop-core/e2e/support/pageActions/settingsActions.ts index cb11b2f601a..586ff179525 100644 --- a/packages/suite-desktop-core/e2e/support/pageActions/settingsActions.ts +++ b/packages/suite-desktop-core/e2e/support/pageActions/settingsActions.ts @@ -97,15 +97,11 @@ export class SettingsActions { this.deviceLabelInput = this.page.getByTestId('@settings/device/label-input'); this.deviceLabelSubmit = this.page.getByTestId('@settings/device/label-submit'); this.confirmOnDevicePrompt = this.page.getByTestId('@prompts/confirm-on-device'); - this.homescreenGalleryButton = this.page.getByTestId( - '@settings/device/homescreen-gallery', - ); + this.homescreenGalleryButton = this.page.getByTestId('@settings/device/homescreen-gallery'); this.notificationSuccessToast = this.page.getByTestId('@toast/settings-applied').first(); this.coinBackendSelector = this.page.getByTestId('@settings/advance/select-type/input'); this.coinAddressInput = this.page.getByTestId('@settings/advance/url'); - this.coinAdvanceSettingSaveButton = this.page.getByTestId( - '@settings/advance/button/save', - ); + this.coinAdvanceSettingSaveButton = this.page.getByTestId('@settings/advance/button/save'); this.themeInput = this.page.getByTestId('@theme/color-scheme-select/input'); this.languageInput = this.page.getByTestId('@settings/language-select/input'); this.pinSubmitButton = this.page.getByTestId('@pin/submit-button');