diff --git a/packages/e2e-utils/src/mocks/google.ts b/packages/e2e-utils/src/mocks/google.ts index f63861ea8bb..18548da04f9 100644 --- a/packages/e2e-utils/src/mocks/google.ts +++ b/packages/e2e-utils/src/mocks/google.ts @@ -53,10 +53,7 @@ export class GoogleMock { if (req.method === 'OPTIONS') { res.setHeader('Access-Control-Allow-Origin', '*'); res.setHeader('Access-Control-Allow-Methods', 'GET, POST, OPTIONS'); - res.setHeader( - 'Access-Control-Allow-Headers', - 'Content-Type, Authorization, dropbox-api-arg', - ); + res.setHeader('Access-Control-Allow-Headers', 'Content-Type, Authorization'); res.setHeader('Access-Control-Allow-Credentials', 'true'); return res.status(200).end(); @@ -65,10 +62,7 @@ export class GoogleMock { // Handle normal requests res.setHeader('Access-Control-Allow-Origin', '*'); res.setHeader('Access-Control-Allow-Methods', 'GET, POST, OPTIONS'); - res.setHeader( - 'Access-Control-Allow-Headers', - 'Content-Type, Authorization, dropbox-api-arg', - ); + res.setHeader('Access-Control-Allow-Headers', 'Content-Type, Authorization'); this.requests.push(req.url); if (this.nextResponse.length) { @@ -156,7 +150,7 @@ export class GoogleMock { app.get('/drive/v3/files/:id', express.json(), (req, res) => { const { id } = req.params; - console.log('[mockGoogleDrive]: get', req.params.id); + console.log('[mockGoogleDrive]: get file by id', req.params.id); const file = Object.values(this.files).find(f => f.id === id); if (file) { return res.send(file.data); @@ -171,6 +165,7 @@ export class GoogleMock { }); app.get('/drive/v3/files', express.json(), (_req, res) => { + console.log('[mockGoogleDrive]: get files'); res.json({ files: Object.values(this.files), }); diff --git a/packages/suite-desktop-core/e2e/support/enums/outputLabelId.ts b/packages/suite-desktop-core/e2e/support/enums/outputLabelId.ts new file mode 100644 index 00000000000..03c651db3b5 --- /dev/null +++ b/packages/suite-desktop-core/e2e/support/enums/outputLabelId.ts @@ -0,0 +1,5 @@ +export enum OutputLabelId { + BitcoinDefault1 = '1d7a8556bb5bda4895596c52017b98c9af29eda10770865e845d3848aa222d1c', + BitcoinLegacy6 = 'b649a09e6d5d02b3cb4648a42511177efb6abf44366f30a51c1b202d52335d18', + BitcoinLegacy10 = '40242836cc07b635569688d12d63041935b86feb2db3fe575be80f2c44e5b4cb', +} diff --git a/packages/suite-desktop-core/e2e/support/pageActions/metadataActions.ts b/packages/suite-desktop-core/e2e/support/pageActions/metadataActions.ts index 7935818bd45..fd0ba501e5d 100644 --- a/packages/suite-desktop-core/e2e/support/pageActions/metadataActions.ts +++ b/packages/suite-desktop-core/e2e/support/pageActions/metadataActions.ts @@ -6,28 +6,55 @@ import { MetadataProvider } from '../mocks/metadataProviderMock'; import { DevicePromptActions } from './devicePromptActions'; import { step } from '../common'; +interface MetadataSubmitOptions { + useButton?: boolean; +} + export class MetadataActions { private readonly metadataSubmitButton: Locator; + readonly metadataCancelButton: Locator; readonly metadataInput: Locator; - readonly editLabelButton = (accountId: string) => + readonly metadataModal: Locator; + + readonly addAccountLabelButton = (accountId: string) => + this.page.getByTestId(`${this.getAccountLabelTestId(accountId)}/add-label-button`); + readonly editAccountLabelButton = (accountId: string) => this.page.getByTestId(`${this.getAccountLabelTestId(accountId)}/edit-label-button`); - readonly successLabel = (accountId: string) => + readonly successAccountLabel = (accountId: string) => this.page.getByTestId(`${this.getAccountLabelTestId(accountId)}/success`); readonly accountLabel = (accountId: string) => this.page.getByTestId(`${this.getAccountLabelTestId(accountId)}/hover-container`); + readonly outputLabel = (outputId: string, txNumber: number) => + this.page.getByTestId(`${this.getOutputLabelTestId(outputId, txNumber)}/hover-container`); + readonly outputDropdownCopyAddress = (outputId: string, txNumber: number) => + this.page.getByTestId( + `${this.getOutputLabelTestId(outputId, txNumber)}/dropdown/copy-address`, + ); + readonly outputDropdownEditLabel = (outputId: string, txNumber: number) => + this.page.getByTestId( + `${this.getOutputLabelTestId(outputId, txNumber)}/dropdown/edit-label`, + ); + readonly metadataProviderButton = (provider: MetadataProvider) => + this.page.getByTestId(`@modal/metadata-provider/${provider}-button`); constructor( private readonly page: Page, private readonly devicePrompt: DevicePromptActions, ) { this.metadataSubmitButton = page.getByTestId('@metadata/submit'); + this.metadataCancelButton = page.getByTestId('@metadata/cancel'); this.metadataInput = page.getByTestId('@metadata/input'); + this.metadataModal = page.getByTestId('@modal/metadata-provider'); } private getAccountLabelTestId(accountId: string): string { return `@metadata/accountLabel/${accountId}`; } + private getOutputLabelTestId(outputId: string, txNumber: number): string { + return `@metadata/outputLabel/${outputId}-${txNumber}`; + } + @step() async passThroughInitMetadata( provider: MetadataProvider, @@ -35,37 +62,67 @@ export class MetadataActions { ) { await this.devicePrompt.confirmOnDevicePromptIsShown(); await TrezorUserEnvLink.pressYes(); - await this.page.getByTestId(`@modal/metadata-provider/${provider}-button`).click(); + await this.metadataProviderButton(provider).click(); if (options?.skipVerification) { return; } - await expect(this.page.getByTestId('@modal/metadata-provider')).not.toBeVisible({ + await expect(this.metadataModal).not.toBeVisible({ timeout: 30000, }); } @step() - async editLabel(accountId: string, newLabel: string) { + async editAccountLabel(accountId: string, newLabel: string) { await this.accountLabel(accountId).click(); - await this.editLabelButton(accountId).click(); - await this.metadataInput.fill(newLabel); - await this.metadataSubmitButton.click(); + await this.editAccountLabelButton(accountId).click(); + await this.fillLabelInput(newLabel, { useButton: true }); } @step() - async clickAddLabelButton(accountId: string) { + async clickAddAccountLabelButton(accountId: string) { await this.accountLabel(accountId).hover(); + await this.addAccountLabelButton(accountId).click(); + } + + @step() + async addAccountLabel(accountId: string, label: string) { + await this.clickAddAccountLabelButton(accountId); + await this.fillLabelInput(label); + } + + @step() + async clickAddOutputLabelButton(outputId: string, txNumber: number) { + await this.outputLabel(outputId, txNumber).hover(); await this.page - .getByTestId(`${this.getAccountLabelTestId(accountId)}/add-label-button`) + .getByTestId(`${this.getOutputLabelTestId(outputId, txNumber)}/add-label-button`) .click(); } @step() - async addLabel(accountId: string, label: string) { - await this.clickAddLabelButton(accountId); + async addOutputLabel(outputId: string, txNumber: number, label: string) { + await this.clickAddOutputLabelButton(outputId, txNumber); + await this.fillLabelInput(label); + } + + @step() + async editOutputLabel(outputId: string, txNumber: number, newLabel: string) { + await this.outputLabel(outputId, txNumber).click(); + await this.outputDropdownEditLabel(outputId, txNumber).click(); + await this.fillLabelInput(newLabel); + } + + @step() + async fillLabelInput(label: string, options?: MetadataSubmitOptions) { await this.metadataInput.fill(label); + + if (options?.useButton) { + await this.metadataSubmitButton.click(); + + return; + } + await this.page.keyboard.press('Enter'); } } diff --git a/packages/suite-desktop-core/e2e/tests/metadata/account-metadata.test.ts b/packages/suite-desktop-core/e2e/tests/metadata/account-metadata.test.ts index 90e658cfc48..7e21a99848e 100644 --- a/packages/suite-desktop-core/e2e/tests/metadata/account-metadata.test.ts +++ b/packages/suite-desktop-core/e2e/tests/metadata/account-metadata.test.ts @@ -29,7 +29,7 @@ test.describe('Account metadata', { tag: ['@group=metadata', '@webOnly'] }, () = await expect(page.getByTestId('@account-menu/btc/normal/0/label')).toHaveText('Bitcoin #1'); // Metadata flow - await metadataPage.clickAddLabelButton(AccountLabelId.BitcoinDefault1); + await metadataPage.clickAddAccountLabelButton(AccountLabelId.BitcoinDefault1); await metadataPage.passThroughInitMetadata(MetadataProvider.DROPBOX); // Edit label @@ -40,17 +40,21 @@ test.describe('Account metadata', { tag: ['@group=metadata', '@webOnly'] }, () = ); // Submit label changes via button - await metadataPage.editLabel(AccountLabelId.BitcoinDefault1, 'even cooler'); + await metadataPage.editAccountLabel(AccountLabelId.BitcoinDefault1, 'even cooler'); await expect(page.getByTestId('@account-menu/btc/normal/0/label')).toHaveText( 'even cooler', ); - await expect(metadataPage.successLabel(AccountLabelId.BitcoinDefault1)).toBeVisible(); - await expect(metadataPage.successLabel(AccountLabelId.BitcoinDefault1)).not.toBeVisible(); + await expect( + metadataPage.successAccountLabel(AccountLabelId.BitcoinDefault1), + ).toBeVisible(); + await expect( + metadataPage.successAccountLabel(AccountLabelId.BitcoinDefault1), + ).not.toBeVisible(); // Discard changes via escape await metadataPage.accountLabel(AccountLabelId.BitcoinDefault1).click(); - await metadataPage.editLabelButton(AccountLabelId.BitcoinDefault1).click(); + await metadataPage.editAccountLabelButton(AccountLabelId.BitcoinDefault1).click(); await metadataPage.metadataInput.fill('bcash is true bitcoin'); await page.keyboard.press('Escape'); await expect(page.getByTestId('@account-menu/btc/normal/0/label')).toHaveText( @@ -68,7 +72,7 @@ test.describe('Account metadata', { tag: ['@group=metadata', '@webOnly'] }, () = // Remove metadata by clearing input await metadataPage.accountLabel(AccountLabelId.BitcoinDefault1).hover(); - await metadataPage.editLabelButton(AccountLabelId.BitcoinDefault1).click(); + await metadataPage.editAccountLabelButton(AccountLabelId.BitcoinDefault1).click(); await metadataPage.metadataInput.clear(); await page.keyboard.press('Enter'); await expect(page.getByTestId('@account-menu/btc/normal/0/label')).toHaveText('Bitcoin #1'); @@ -77,13 +81,17 @@ test.describe('Account metadata', { tag: ['@group=metadata', '@webOnly'] }, () = await page.getByTestId('@account-menu/segwit').click(); await page.getByTestId('@account-menu/btc/segwit/0').click(); - await metadataPage.addLabel(AccountLabelId.BitcoinSegwit1, 'typing into one input'); - await expect(metadataPage.successLabel(AccountLabelId.BitcoinSegwit1)).toBeVisible(); + await metadataPage.addAccountLabel(AccountLabelId.BitcoinSegwit1, 'typing into one input'); + await expect(metadataPage.successAccountLabel(AccountLabelId.BitcoinSegwit1)).toBeVisible(); await page.getByTestId('@account-menu/btc/segwit/1').click(); - await expect(metadataPage.successLabel(AccountLabelId.BitcoinSegwit2)).not.toBeVisible(); - await expect(metadataPage.successLabel(AccountLabelId.BitcoinSegwit1)).not.toBeVisible(); + await expect( + metadataPage.successAccountLabel(AccountLabelId.BitcoinSegwit2), + ).not.toBeVisible(); + await expect( + metadataPage.successAccountLabel(AccountLabelId.BitcoinSegwit1), + ).not.toBeVisible(); // Check metadata requests when switching routes await page.getByTestId('@suite/menu/suite-index').click(); @@ -94,7 +102,7 @@ test.describe('Account metadata', { tag: ['@group=metadata', '@webOnly'] }, () = await page.getByTestId('@account-menu/add-account').click(); await settingsPage.coins.networkButton('btc').click(); await page.getByTestId('@add-account').click(); - await metadataPage.addLabel( + await metadataPage.addAccountLabel( AccountLabelId.BitcoinDefault3, 'adding label to a newly added account. does it work?', ); diff --git a/packages/suite-desktop-core/e2e/tests/metadata/dropbox-api-errors.test.ts b/packages/suite-desktop-core/e2e/tests/metadata/dropbox-api-errors.test.ts index 03b701f8973..d7b18391dc6 100644 --- a/packages/suite-desktop-core/e2e/tests/metadata/dropbox-api-errors.test.ts +++ b/packages/suite-desktop-core/e2e/tests/metadata/dropbox-api-errors.test.ts @@ -43,7 +43,7 @@ test.describe('Dropbox API errors', { tag: ['@group=metadata', '@webOnly'] }, () await page.getByTestId('@account-menu/btc/normal/0').click(); await metadataPage.accountLabel(AccountLabelId.BitcoinDefault1).click(); - await metadataPage.editLabelButton(AccountLabelId.BitcoinDefault1).click(); + await metadataPage.editAccountLabelButton(AccountLabelId.BitcoinDefault1).click(); // Simulated API responses for retries with malformed token must be supplied exactly at this point in the flow for (let i = 0; i < 4; i++) { @@ -121,7 +121,7 @@ test.describe('Dropbox API errors', { tag: ['@group=metadata', '@webOnly'] }, () }); await page.getByTestId('@account-menu/btc/normal/0').click(); - await metadataPage.editLabel(AccountLabelId.BitcoinDefault1, 'Kvooo'); + await metadataPage.editAccountLabel(AccountLabelId.BitcoinDefault1, 'Kvooo'); await expect(metadataPage.accountLabel(AccountLabelId.BitcoinDefault1)).toContainText( 'Kvooo', ); @@ -157,7 +157,7 @@ test.describe('Dropbox API errors', { tag: ['@group=metadata', '@webOnly'] }, () await page.getByTestId('@account-menu/btc/normal/0').click(); // just enter some label, this indicates that app did not crash - await metadataPage.editLabel(AccountLabelId.BitcoinDefault1, 'Kvooo'); + await metadataPage.editAccountLabel(AccountLabelId.BitcoinDefault1, 'Kvooo'); }); test.afterEach(async ({ metadataProviderMock }) => { diff --git a/packages/suite-desktop-core/e2e/tests/metadata/google-api-errors.test.ts b/packages/suite-desktop-core/e2e/tests/metadata/google-api-errors.test.ts index 08b853a2db1..9546f80843f 100644 --- a/packages/suite-desktop-core/e2e/tests/metadata/google-api-errors.test.ts +++ b/packages/suite-desktop-core/e2e/tests/metadata/google-api-errors.test.ts @@ -46,7 +46,7 @@ test.describe('Google API errors', { tag: ['@group=metadata', '@webOnly'] }, () await dashboardPage.discoveryShouldFinish(); await page.getByTestId('@account-menu/btc/normal/0').click(); - await metadataPage.clickAddLabelButton(AccountLabelId.BitcoinDefault1); + await metadataPage.clickAddAccountLabelButton(AccountLabelId.BitcoinDefault1); await metadataPage.passThroughInitMetadata(MetadataProvider.GOOGLE, { skipVerification: true, diff --git a/packages/suite-desktop-core/e2e/tests/metadata/metadata-lifecycle.test.ts b/packages/suite-desktop-core/e2e/tests/metadata/metadata-lifecycle.test.ts new file mode 100644 index 00000000000..4ef252a9451 --- /dev/null +++ b/packages/suite-desktop-core/e2e/tests/metadata/metadata-lifecycle.test.ts @@ -0,0 +1,108 @@ +import { AccountLabelId } from '../../support/enums/accountLabelId'; +import { test, expect } from '../../support/fixtures'; +import { MetadataProvider } from '../../support/mocks/metadataProviderMock'; + +test.describe( + 'Metadata - cancel metadata on device', + { tag: ['@group=metadata', '@webOnly'] }, + () => { + test.use({ + emulatorSetupConf: { + mnemonic: 'mnemonic_all', + passphrase_protection: true, + }, + }); + test.beforeEach(async ({ metadataProviderMock }) => { + await metadataProviderMock.start(MetadataProvider.DROPBOX); + }); + + test('user cancels metadata on device, choice is respected on subsequent runs but only for the cancelled wallet', async ({ + page, + onboardingPage, + dashboardPage, + settingsPage, + metadataPage, + devicePrompt, + trezorUserEnvLink, + }) => { + await onboardingPage.completeOnboarding({ enableViewOnly: false }); + await dashboardPage.discoveryShouldFinish(); + + await settingsPage.navigateTo('application'); + await expect( + page.getByTestId('@settings/metadata-switch').locator('input'), + ).not.toBeChecked(); + + // Navigate to account and hover over add label button + await page.getByTestId('@suite/menu/suite-index').click(); + await page.getByTestId('@account-menu/btc/normal/0').click(); + await metadataPage.clickAddAccountLabelButton(AccountLabelId.BitcoinDefault1); + await devicePrompt.confirmOnDevicePromptIsShown(); + await trezorUserEnvLink.pressNo(); + + // Reload app, cancel metadata again, and remember device + await page.reload(); + await devicePrompt.confirmOnDevicePromptIsShown(); + await trezorUserEnvLink.pressNo(); + + await dashboardPage.discoveryShouldFinish(); + await dashboardPage.deviceSwitchingOpenButton.click(); + await page.getByTestId('@viewOnlyStatus/disabled').click(); + await page.getByTestId('@viewOnly/radios/enabled').click(); + + await page.reload(); + + // Add another wallet, enable labeling on the new device + await page.getByTestId('@menu/switch-device').click(); + await page.getByTestId('@switch-device/add-hidden-wallet-button').click(); + await page.getByTestId('@passphrase/input').fill('abc'); + await page.getByTestId('@passphrase/hidden/submit-button').click(); + await expect(page.getByTestId('@passphrase/input')).not.toBeVisible(); + + await devicePrompt.confirmOnDevicePromptIsShown(); + await trezorUserEnvLink.pressYes(); + + await devicePrompt.confirmOnDevicePromptIsShown(); + await trezorUserEnvLink.pressYes(); + + await page + .getByTestId('@passphrase-confirmation/step1-open-unused-wallet-button') + .click(); + await page.getByTestId('@passphrase-confirmation/step2-button').click(); + await page.getByTestId('@passphrase/input').fill('abc'); + await page.getByTestId('@passphrase/hidden/submit-button').click(); + + await devicePrompt.confirmOnDevicePromptIsShown(); + await trezorUserEnvLink.pressYes(); + + await devicePrompt.confirmOnDevicePromptIsShown(); + await trezorUserEnvLink.pressYes(); + + await expect(page.getByTestId('@passphrase/input')).not.toBeVisible(); + await devicePrompt.confirmOnDevicePromptIsShown(); + await trezorUserEnvLink.pressYes(); + await devicePrompt.confirmOnDevicePromptIsShown(); + await trezorUserEnvLink.pressYes(); + + // Close connect to data provider modal + await page.getByTestId('@modal/close-button').click(); + + // Forget device and reload + await page.getByTestId('@menu/switch-device').click(); + + await page.getByTestId('@switch-device/wallet-on-index/0/eject-button').click(); + await page.getByTestId('@switch-device/eject').click(); + await page.getByTestId('@switch-device/wallet-on-index/0/eject-button').click(); + await page.getByTestId('@switch-device/eject').click(); + await page.reload(); + + // Enable labeling dialogue appears again + await devicePrompt.confirmOnDevicePromptIsShown(); + await trezorUserEnvLink.pressNo(); + }); + + test.afterEach(async ({ metadataProviderMock }) => { + await metadataProviderMock.stop(); + }); + }, +); diff --git a/packages/suite-desktop-core/e2e/tests/metadata/output-labeling.test.ts b/packages/suite-desktop-core/e2e/tests/metadata/output-labeling.test.ts new file mode 100644 index 00000000000..220d22a91f5 --- /dev/null +++ b/packages/suite-desktop-core/e2e/tests/metadata/output-labeling.test.ts @@ -0,0 +1,90 @@ +import fs from 'fs'; + +import { OutputLabelId } from '../../support/enums/outputLabelId'; +import { test, expect } from '../../support/fixtures'; +import { MetadataProvider } from '../../support/mocks/metadataProviderMock'; + +test.describe('Metadata - Output labeling', { tag: ['@group=metadata', '@webOnly'] }, () => { + test.use({ emulatorSetupConf: { mnemonic: 'mnemonic_all' } }); + test.beforeEach(async ({ metadataProviderMock }) => { + await metadataProviderMock.start(MetadataProvider.DROPBOX); + }); + + test('dropbox provider', async ({ page, onboardingPage, dashboardPage, metadataPage }) => { + await onboardingPage.completeOnboarding(); + await dashboardPage.discoveryShouldFinish(); + + await page.getByTestId('@account-menu/btc/normal/0').click(); + + await metadataPage.clickAddOutputLabelButton(OutputLabelId.BitcoinDefault1, 0); + + await metadataPage.passThroughInitMetadata(MetadataProvider.DROPBOX); + + await metadataPage.fillLabelInput('mnau cool label'); + + // go to legacy account 6, it has txs with multiple outputs + await page.getByTestId('@account-menu/legacy').click(); + await page.getByTestId('@account-menu/btc/legacy/5/label').click(); + + // Try to open multiple metadata inputs + await metadataPage.clickAddOutputLabelButton(OutputLabelId.BitcoinLegacy6, 0); + await metadataPage.clickAddOutputLabelButton(OutputLabelId.BitcoinLegacy6, 1); + + // Only one metadata input should be visible at a time + await expect(metadataPage.metadataInput).toHaveCount(1); + + await metadataPage.addOutputLabel(OutputLabelId.BitcoinLegacy6, 2, 'output 3'); + await expect(metadataPage.outputLabel(OutputLabelId.BitcoinLegacy6, 2)).toContainText( + 'output 3', + ); + + // label "send to myself tx" + await page.getByTestId('@account-menu/btc/legacy/9/label').click(); + await metadataPage.addOutputLabel(OutputLabelId.BitcoinLegacy10, 0, 'really to myself'); + await expect(metadataPage.outputLabel(OutputLabelId.BitcoinLegacy10, 0)).toContainText( + 'really to myself', + ); + + // Test that label can be edited and submitted by enter + await metadataPage.editOutputLabel(OutputLabelId.BitcoinLegacy10, 0, 'edited'); + await expect(metadataPage.outputLabel(OutputLabelId.BitcoinLegacy10, 0)).toContainText( + 'edited', + ); + + // Check that there is a copy address button + await metadataPage.outputLabel(OutputLabelId.BitcoinLegacy10, 0).click(); + await expect( + metadataPage.outputDropdownCopyAddress(OutputLabelId.BitcoinLegacy10, 0), + ).toBeVisible(); + + // Test that label can be edited and submitted by submit button + await metadataPage.outputDropdownEditLabel(OutputLabelId.BitcoinLegacy10, 0).click(); + await metadataPage.fillLabelInput('submitted by button', { useButton: true }); + await expect(metadataPage.outputLabel(OutputLabelId.BitcoinLegacy10, 0)).toContainText( + 'submitted by button', + ); + + await metadataPage.outputLabel(OutputLabelId.BitcoinLegacy10, 0).click(); + await metadataPage.outputDropdownEditLabel(OutputLabelId.BitcoinLegacy10, 0).click(); + await metadataPage.metadataInput.clear(); + await metadataPage.metadataInput.fill('write something that wont be saved'); + await metadataPage.metadataCancelButton.click(); + await expect(metadataPage.outputLabel(OutputLabelId.BitcoinLegacy10, 0)).toContainText( + 'submitted by button', + ); + + await page.getByTestId('@wallet/accounts/export-transactions/dropdown').click(); + await page.getByTestId('@wallet/accounts/export-transactions/csv').click(); + + const download = await page.waitForEvent('download'); + const downloadPath = await download.path(); + const fileContent = fs.readFileSync(downloadPath, 'utf8'); + const expectedSubstr = '1PmVvr5DNVYJygtDT7J312qmxpa5pceu9E;submitted by button'; + expect(fileContent).toContain(expectedSubstr); + expect(typeof fileContent).toBe('string'); + }); + + test.afterEach(async ({ metadataProviderMock }) => { + await metadataProviderMock.stop(); + }); +}); diff --git a/packages/suite-desktop-core/e2e/tests/metadata/remembered-device.test.ts b/packages/suite-desktop-core/e2e/tests/metadata/remembered-device.test.ts new file mode 100644 index 00000000000..6bf69194359 --- /dev/null +++ b/packages/suite-desktop-core/e2e/tests/metadata/remembered-device.test.ts @@ -0,0 +1,131 @@ +import { AccountLabelId } from '../../support/enums/accountLabelId'; +import { test, expect } from '../../support/fixtures'; +import { MetadataProvider } from '../../support/mocks/metadataProviderMock'; + +//Metadata - In settings, there is enable metadata switch. +//On enable, it initiates metadata right away (if device already has state). +//On disable, it throws away all metadata related records from memory. +test.describe('Remembered device', { tag: ['@group=metadata', '@webOnly'] }, () => { + const fileContent = { + version: '1.0.0', + accountLabel: 'already existing label', + outputLabels: {}, + addressLabels: {}, + }; + const aesKey: string = 'c785ef250807166bffc141960c525df97647fcc1bca57f6892ca3742ba86ed8d'; + + test.use({ + emulatorStartConf: { model: 'T2T1', wipe: true }, + emulatorSetupConf: { mnemonic: 'mnemonic_all' }, + }); + test.beforeEach(async ({ metadataProviderMock }) => { + await metadataProviderMock.start(MetadataProvider.GOOGLE); + await metadataProviderMock.setFileContent( + 'f7acc942eeb83921892a95085e409b3e6b5325db6400ae5d8de523a305291dca.mtdt', + fileContent, + aesKey, + ); + }); + + test('google provider', async ({ + page, + onboardingPage, + dashboardPage, + settingsPage, + metadataPage, + devicePrompt, + trezorUserEnvLink, + }) => { + await onboardingPage.completeOnboarding({ enableViewOnly: true }); + await dashboardPage.discoveryShouldFinish(); + + await page.getByTestId('@account-menu/btc/normal/0/label').click(); + + await settingsPage.navigateTo('application'); + await settingsPage.metadataSwitch.click(); + await metadataPage.passThroughInitMetadata(MetadataProvider.GOOGLE); + + // Now metadata is enabled, go to accounts and see what we got loaded from provider + await page.getByTestId('@account-menu/btc/normal/0').click(); + + await expect(page.getByTestId('@account-menu/btc/normal/0/label')).toContainText( + 'already existing label', + ); + + // device not saved, disconnect provider + // Now go back to settings, disconnect provider and check that we don't see metadata in app + await settingsPage.navigateTo('application'); + await page.getByTestId('@settings/metadata/disconnect-provider-button').click(); + await expect(page.getByTestId('@settings/metadata/connect-provider-button')).toBeVisible(); + await page.getByTestId('@account-menu/btc/normal/0').click(); + await expect(page.getByTestId('@account-menu/btc/normal/0/label')).not.toContainText( + 'already existing label', + ); + + // At this moment, there are no labels. But we still can see "add label" button, which inits metadata flow but without obtaining keys from device (they are saved!) + await metadataPage.clickAddAccountLabelButton(AccountLabelId.BitcoinDefault1); + await metadataPage.metadataProviderButton(MetadataProvider.GOOGLE).click(); + await expect(metadataPage.metadataModal).not.toBeVisible(); + await expect(page.getByTestId('@account-menu/btc/normal/0/label')).toContainText( + 'already existing label', + ); + + // device not saved, disable metadata + await settingsPage.navigateTo('application'); + await page.getByTestId('@settings/metadata-switch').click(); + await page.getByTestId('@account-menu/btc/normal/0').click(); + await expect(page.getByTestId('@account-menu/btc/normal/0/label')).not.toContainText( + 'label', + ); + await metadataPage.clickAddAccountLabelButton(AccountLabelId.BitcoinDefault1); + + // disabling metadata removed also all keys, so metadata init flow takes all steps now expect for providers, these stay connected + await devicePrompt.confirmOnDevicePromptIsShown(); + await trezorUserEnvLink.pressYes(); + await page.waitForTimeout(1000); + + // device saved, disconnect provider + await page.getByTestId('@menu/switch-device').click(); + await page.getByTestId('@switch-device/wallet-on-index/0').click(); + + await trezorUserEnvLink.stopEmu(); + + // Device is saved, when disconnected, user still can edit labels + await metadataPage.editAccountLabel( + AccountLabelId.BitcoinDefault1, + 'edited for remembered', + ); + await expect(page.getByTestId('@account-menu/btc/normal/0/label')).toContainText( + 'edited for remembered', + ); + + // Now again, lets try disconnecting provider + await settingsPage.navigateTo('application'); + await page.getByTestId('@settings/metadata/disconnect-provider-button').click(); + await page.getByTestId('@account-menu/btc/normal/0').click(); + + // Disconnecting removes labels + await expect(page.getByTestId('@account-menu/btc/normal/0/label')).toContainText('Bitcoin'); + + // Still possible to reconnect provider, we have keys still saved + await metadataPage.clickAddAccountLabelButton(AccountLabelId.BitcoinDefault1); + await metadataPage.metadataProviderButton(MetadataProvider.GOOGLE).click(); + await expect(metadataPage.metadataModal).not.toBeVisible(); + await metadataPage.fillLabelInput('mnau'); + await expect(page.getByTestId('@account-menu/btc/normal/0/label')).toContainText('mnau'); + + // device saved, disable metadata + await settingsPage.navigateTo('application'); + await page.getByTestId('@settings/metadata-switch').click(); + await page.getByTestId('@account-menu/btc/normal/0').click(); + + // Now it is not possible to add labels, keys are gone and device is not connected + await expect( + metadataPage.addAccountLabelButton(AccountLabelId.BitcoinDefault1), + ).not.toBeVisible(); + }); + + test.afterEach(async ({ metadataProviderMock }) => { + await metadataProviderMock.stop(); + }); +}); diff --git a/packages/suite-desktop-core/e2e/tests/metadata/switching-providers.test.ts b/packages/suite-desktop-core/e2e/tests/metadata/switching-providers.test.ts new file mode 100644 index 00000000000..c7e1dc2dcfc --- /dev/null +++ b/packages/suite-desktop-core/e2e/tests/metadata/switching-providers.test.ts @@ -0,0 +1,80 @@ +import { AccountLabelId } from '../../support/enums/accountLabelId'; +import { test, expect } from '../../support/fixtures'; +import { MetadataProvider } from '../../support/mocks/metadataProviderMock'; + +test.describe( + 'Metadata - switching between cloud providers', + { tag: ['@group=metadata', '@webOnly'] }, + () => { + const dropboxLabel = 'dropbox label'; + const googleLabel = 'google label'; + const defaultLabel = 'Bitcoin #1'; + + test('Start with one and switch to another', async ({ + page, + onboardingPage, + dashboardPage, + metadataPage, + settingsPage, + metadataProviderMock, + }) => { + await onboardingPage.completeOnboarding(); + await dashboardPage.discoveryShouldFinish(); + + // Navigate to account and verify initial state + await page.getByTestId('@account-menu/btc/normal/0').click(); + await expect(page.getByTestId('@account-menu/btc/normal/0/label')).toHaveText( + defaultLabel, + ); + + await metadataProviderMock.start(MetadataProvider.DROPBOX); + + // Add a label using Dropbox + await metadataPage.clickAddAccountLabelButton(AccountLabelId.BitcoinDefault1); + await metadataPage.passThroughInitMetadata(MetadataProvider.DROPBOX); + + await metadataPage.metadataInput.fill(dropboxLabel); + await page.keyboard.press('Enter'); + await expect(page.getByTestId('@account-menu/btc/normal/0/label')).toHaveText( + dropboxLabel, + ); + + // Disconnect Dropbox + await settingsPage.navigateTo('application'); + await page.getByTestId('@settings/metadata/disconnect-provider-button').click(); + await expect( + page.getByTestId('@settings/metadata/connect-provider-button'), + ).toBeVisible(); + + await metadataProviderMock.stop(); + + // Verify that labels are removed after disconnect + await page.getByTestId('@account-menu/btc/normal/0').click(); + await expect(page.getByTestId('@account-menu/btc/normal/0/label')).toBeVisible(); + await expect(page.getByTestId('@account-menu/btc/normal/0/label')).toHaveText( + defaultLabel, + ); + + await metadataProviderMock.start(MetadataProvider.GOOGLE); + + // Connect to Google and add a label + await metadataPage.clickAddAccountLabelButton(AccountLabelId.BitcoinDefault1); + await expect(page.getByTestId('@modal/metadata-provider')).toBeVisible(); + await expect( + page.getByTestId('@modal/metadata-provider/file-system-button'), + ).not.toBeVisible(); + await page.getByTestId('@modal/metadata-provider/google-button').click(); + await expect(page.getByTestId('@modal/metadata-provider')).not.toBeVisible(); + + await metadataPage.metadataInput.fill(googleLabel); + await page.keyboard.press('Enter'); + await expect(page.getByTestId('@account-menu/btc/normal/0/label')).toHaveText( + googleLabel, + ); + }); + + test.afterEach(async ({ metadataProviderMock }) => { + await metadataProviderMock.stop(); + }); + }, +); diff --git a/packages/suite-web/e2e/tests/metadata/metadata-lifecycle.test.ts b/packages/suite-web/e2e/tests/metadata/metadata-lifecycle.test.ts deleted file mode 100644 index 64dbd77eeab..00000000000 --- a/packages/suite-web/e2e/tests/metadata/metadata-lifecycle.test.ts +++ /dev/null @@ -1,112 +0,0 @@ -// @group_metadata -// @retry=2 - -import { onNavBar } from '../../support/pageObjects/topBarObject'; - -describe('Metadata - cancel metadata on device', () => { - beforeEach(() => { - cy.viewport('macbook-15').resetDb(); - }); - - it('user cancels metadata on device, choice is respected on subsequent runs but only for the cancelled wallet', () => { - // prepare test - cy.task('startEmu', { wipe: true, model: 'T2T1', version: '2.7.0' }); - cy.task('setupEmu', { - mnemonic: 'mnemonic_all', - passphrase_protection: true, - }); - cy.task('startBridge'); - cy.task('metadataStartProvider', 'dropbox'); - - // first go to settings, see that metadata is disabled by default. - cy.prefixedVisit('/'); - cy.passThroughInitialRun({ viewOnly: false }); - cy.discoveryShouldFinish(); - onNavBar.openSettings(); - cy.getTestElement('@settings/metadata-switch').within(() => { - cy.get('input').should('not.be.checked'); - }); - - // now go to accounts. application does not try to initiate metadata - cy.getTestElement('@suite/menu/suite-index').click(); - cy.getTestElement('@account-menu/btc/normal/0').click(); - Cypress.config('scrollBehavior', false); - // but even though metadata is disabled, on hover "add label" button appears - cy.hoverTestElement("@metadata/accountLabel/m/84'/0'/0'/hover-container"); - - // try to init metadata... - cy.getTestElement("@metadata/accountLabel/m/84'/0'/0'/add-label-button").click({ - force: true, - }); - Cypress.config('scrollBehavior', 'top'); - // ...but user cancels dialogue on device - cy.getConfirmActionOnDeviceModal(); - cy.task('pressNo'); - cy.wait(501); - - // cancelling labeling on device actually enables labeling globally so when user reloads app, - // metadata dialogue will be prompted. now user cancels dialogue on device again and remembers device - - cy.safeReload(); - // todo: this may timeout - - cy.getConfirmActionOnDeviceModal(); - cy.task('pressNo'); - - // set wallet to remembered - cy.discoveryShouldFinish(); - cy.getTestElement('@menu/switch-device').click(); - cy.getTestElement('@viewOnlyStatus/disabled').click(); - cy.getTestElement('@viewOnly/radios/enabled').click(); - cy.safeReload(); - - // but when user tries to add another wallet, there is enable labeling dialogue again - cy.getTestElement('@menu/switch-device').click(); - cy.getTestElement('@switch-device/add-hidden-wallet-button').click(); - cy.getTestElement('@passphrase/input').type('abc'); - cy.getTestElement('@passphrase/hidden/submit-button').click(); - cy.getTestElement('@passphrase/input').should('not.exist'); - cy.getConfirmActionOnDeviceModal(); - cy.task('pressYes'); - cy.getConfirmActionOnDeviceModal(); - cy.task('pressYes'); - cy.getTestElement('@passphrase-confirmation/step1-open-unused-wallet-button').click(); - cy.getTestElement('@passphrase-confirmation/step2-button').click(); - cy.getTestElement('@passphrase/input').type('abc'); - cy.getTestElement('@passphrase/hidden/submit-button').click(); - cy.task('pressYes'); - cy.task('pressYes'); - cy.getTestElement('@passphrase/input').should('not.exist'); - cy.getConfirmActionOnDeviceModal(); - cy.task('pressYes'); - cy.wait(501); - cy.getConfirmActionOnDeviceModal(); - cy.task('pressYes'); - cy.wait(501); - - // connect to data provider modal - // note: since recently, the first dialogue that appeared was "enable labeling on device" are we ok with this change of order? - cy.getTestElement('@modal/close-button').click(); - - // cy.getConfirmActionOnDeviceModal(); - // cy.task('pressNo'); - // cy.wait(501); - - cy.getTestElement('@accounts/empty-account/receive'); - - // forget device and reload -> enable labeling dialogue appears - // explanation: metadata.error is indexed by device.state and we treat this field as sensitive - // as keeping it might beat users plausible deniability - cy.getTestElement('@menu/switch-device').click(); - - cy.getTestElement('@switch-device/wallet-on-index/0/eject-button').click(); - cy.getTestElement('@switch-device/eject').click(); - cy.getTestElement('@switch-device/wallet-on-index/0/eject-button').click(); - cy.getTestElement('@switch-device/eject').click(); - - cy.safeReload(); - - cy.getConfirmActionOnDeviceModal(); // enable labeling dialogue; - cy.task('pressNo'); - }); -}); diff --git a/packages/suite-web/e2e/tests/metadata/output-labeling.test.ts b/packages/suite-web/e2e/tests/metadata/output-labeling.test.ts deleted file mode 100644 index c1b6f5077b5..00000000000 --- a/packages/suite-web/e2e/tests/metadata/output-labeling.test.ts +++ /dev/null @@ -1,113 +0,0 @@ -// @group_metadata -// @retry=2 - -import { rerouteMetadataToMockProvider, stubOpen } from '../../stubs/metadata'; - -// we could run this test for multiple providers but it does not give so much value at the moment -const providers = ['google'] as const; - -describe('Metadata - Output labeling', () => { - beforeEach(() => { - cy.viewport('macbook-13').resetDb(); - cy.task('rmDir', { dir: Cypress.config('downloadsFolder'), recursive: true, force: true }); - }); - - providers.forEach(provider => { - it(provider, () => { - const targetEl1 = - '@metadata/outputLabel/1d7a8556bb5bda4895596c52017b98c9af29eda10770865e845d3848aa222d1c-0/add-label-button'; - // prepare test - cy.task('startEmu', { wipe: true }); - cy.task('setupEmu', { mnemonic: 'mnemonic_all' }); - cy.task('startBridge'); - cy.task('metadataStartProvider', provider); - - const sentToMyselfEl = - '@metadata/outputLabel/40242836cc07b635569688d12d63041935b86feb2db3fe575be80f2c44e5b4cb-0'; - - cy.prefixedVisit('/', { - onBeforeLoad: (win: Window) => { - cy.stub(win, 'open').callsFake(stubOpen(win)); - cy.stub(win, 'fetch').callsFake(rerouteMetadataToMockProvider); - }, - }); - - cy.passThroughInitialRun(); - - cy.discoveryShouldFinish(); - cy.getTestElement('@account-menu/btc/normal/0').click(); - - cy.getTestElement(targetEl1).click({ force: true }); - cy.passThroughInitMetadata(provider); - cy.getTestElement('@metadata/input').type('mnau cool label{enter}'); - - cy.log('go to legacy account 6, it has txs with multiple outputs'); - cy.getTestElement('@account-menu/legacy').click(); - cy.getTestElement('@account-menu/btc/legacy/5/label').click(); - cy.getTestElement( - '@metadata/outputLabel/b649a09e6d5d02b3cb4648a42511177efb6abf44366f30a51c1b202d52335d18-0/add-label-button', - ).click({ force: true }); - - cy.getTestElement( - '@metadata/outputLabel/b649a09e6d5d02b3cb4648a42511177efb6abf44366f30a51c1b202d52335d18-1/add-label-button', - ).click({ force: true }); - cy.getTestElement('@metadata/submit').should('have.length', 1); - - cy.getTestElement( - '@metadata/outputLabel/b649a09e6d5d02b3cb4648a42511177efb6abf44366f30a51c1b202d52335d18-2/add-label-button', - ).click({ force: true }); - cy.getTestElement('@metadata/input').type('output 3{enter}'); - - cy.log('label "send to myself tx"'); - cy.getTestElement('@account-menu/btc/legacy/9/label').click(); - cy.getTestElement(`${sentToMyselfEl}/add-label-button`).click({ force: true }); - cy.getTestElement('@metadata/input').type('really to myself{enter}'); - - cy.getTestElement(sentToMyselfEl).click({ force: true }); - // dropdown/ - cy.getTestElement(`${sentToMyselfEl}/dropdown/edit-label`).click({ force: true }); - cy.getTestElement('@metadata/input').type(' edited{enter}'); - - // just check there is copy address button, as of cypress 13.4.0 there is some problem to click on it (breaks tests locally) - cy.getTestElement(`${sentToMyselfEl}`).click({ force: true }); - cy.getTestElement(`${sentToMyselfEl}/dropdown/copy-address`); - - // test that buttons work as well - submit button - cy.getTestElement(`${sentToMyselfEl}/dropdown/edit-label`).click({ force: true }); - cy.getTestElement('@metadata/input').clear(); - cy.getTestElement('@metadata/input').type('submitted by button'); - cy.getTestElement('@metadata/submit').click({ force: true }); - cy.getTestElement(`${sentToMyselfEl}`).should('contain', 'submitted by button'); - - // test that buttons work as well - cancel button - cy.getTestElement(`${sentToMyselfEl}`).click({ force: true }); - cy.getTestElement(`${sentToMyselfEl}/dropdown/edit-label`).click({ force: true }); - cy.getTestElement('@metadata/input').clear(); - cy.getTestElement('@metadata/input').type('write something that wont be saved'); - cy.getTestElement('@metadata/cancel').click({ force: true }); - cy.getTestElement(`${sentToMyselfEl}`).should('contain', 'submitted by button'); - - // validate that exporting transactions exports also labels - // note: having trouble using here due to inability to scroll to that element, so I am using force here - // onAccountsPage.exportDesiredTransactionType('csv'); - cy.getTestElement('@wallet/accounts/export-transactions/dropdown').click({ - force: true, - }); - cy.getTestElement(`@wallet/accounts/export-transactions/csv`).click({ - force: true, - }); - - cy.wait(1000); - cy.task('readDir', Cypress.config('downloadsFolder')).then((dir: any) => { - cy.task('readFile', `${Cypress.config('downloadsFolder')}/${dir[0]}`).then( - (file: any) => { - const expectedSubstr = - '1PmVvr5DNVYJygtDT7J312qmxpa5pceu9E;submitted by button'; - expect(file).to.include(expectedSubstr); - cy.wrap(file).should('be.a', 'string'); - }, - ); - }); - }); - }); -}); diff --git a/packages/suite-web/e2e/tests/metadata/remembered-device.test.ts b/packages/suite-web/e2e/tests/metadata/remembered-device.test.ts deleted file mode 100644 index 1b5599e78ff..00000000000 --- a/packages/suite-web/e2e/tests/metadata/remembered-device.test.ts +++ /dev/null @@ -1,163 +0,0 @@ -// @group_metadata -// @retry=2 - -import { rerouteMetadataToMockProvider, stubOpen } from '../../stubs/metadata'; -import { onNavBar } from '../../support/pageObjects/topBarObject'; - -const providers = [ - { - provider: 'google', - file: 'f7acc942eeb83921892a95085e409b3e6b5325db6400ae5d8de523a305291dca.mtdt', - }, - // should be enough to test only one provider - // { - // provider: 'dropbox', - // file: '/f7acc942eeb83921892a95085e409b3e6b5325db6400ae5d8de523a305291dca.mtdt', - // }, -] as const; - -describe( - `Metadata - In settings, there is enable metadata switch. ` + - `On enable, it initiates metadata right away (if device already has state).` + - `On disable, it throws away all metadata related records from memory.`, - () => { - beforeEach(() => { - // use portrait mode monitor to prevent scrolling in settings - cy.viewport('macbook-13').resetDb(); - }); - - providers.forEach(f => { - it(f.provider, () => { - // prepare test - cy.task('stopBridge'); - cy.task('startEmu', { wipe: true }); - cy.task('setupEmu', { mnemonic: 'mnemonic_all' }); - cy.task('startBridge'); - cy.task('metadataStartProvider', f.provider); - cy.task('metadataSetFileContent', { - provider: f.provider, - file: f.file, - content: { - version: '1.0.0', - accountLabel: 'already existing label', - outputLabels: {}, - addressLabels: {}, - }, - aesKey: 'c785ef250807166bffc141960c525df97647fcc1bca57f6892ca3742ba86ed8d', - }); - - cy.prefixedVisit('/', { - onBeforeLoad: (win: Window) => { - cy.stub(win, 'open').callsFake(stubOpen(win)); - cy.stub(win, 'fetch').callsFake(rerouteMetadataToMockProvider); - }, - }); - cy.log( - 'Wait for discovery to finish. There is "add label" button, but no actual metadata appeared', - ); - cy.passThroughInitialRun(); - cy.discoveryShouldFinish(); - - cy.getTestElement('@account-menu/btc/normal/0').click(); - - cy.getTestElement('@account-menu/btc/normal/0/label').should('contain', 'Bitcoin'); - - cy.log('Go to settings and enable metadata'); - onNavBar.openSettings(); - cy.getTestElement('@settings/metadata-switch').click({ force: true }); - cy.passThroughInitMetadata(f.provider); - - cy.log( - 'Now metadata is enabled, go to accounts and see what we got loaded from provider', - ); - cy.getTestElement('@account-menu/btc/normal/0').click(); - cy.getTestElement('@account-menu/btc/normal/0/label').should( - 'contain', - 'already existing label', - ); - - // device not saved, disconnect provider - cy.log( - "Now go back to settings, disconnect provider and check that we don't see metadata in app", - ); - onNavBar.openSettings(); - cy.getTestElement('@settings/metadata/disconnect-provider-button').click(); - cy.getTestElement('@settings/metadata/connect-provider-button'); - cy.getTestElement('@account-menu/btc/normal/0').click(); - cy.getTestElement('@account-menu/btc/normal/0/label').should( - 'not.contain', - 'already existing label', - ); - - cy.log( - 'At this moment, there are no labels. But we still can see "add label" button, which inits metadata flow but without obtaining keys from device (they are saved!)', - ); - cy.hoverTestElement("@metadata/accountLabel/m/84'/0'/0'/hover-container"); - cy.getTestElement("@metadata/accountLabel/m/84'/0'/0'/add-label-button").click(); - cy.getTestElement(`@modal/metadata-provider/${f.provider}-button`).click(); - cy.getTestElement('@modal/metadata-provider').should('not.exist'); - cy.getTestElement('@account-menu/btc/normal/0/label').should( - 'contain', - 'already existing label', - ); - - // device not saved, disable metadata - onNavBar.openSettings(); - cy.getTestElement('@settings/metadata-switch').click({ force: true }); - cy.getTestElement('@account-menu/btc/normal/0').click(); - cy.getTestElement('@account-menu/btc/normal/0/label').should( - 'not.contain', - 'label', - ); - cy.hoverTestElement("@metadata/accountLabel/m/84'/0'/0'/hover-container"); - cy.getTestElement("@metadata/accountLabel/m/84'/0'/0'/add-label-button").click(); - cy.log( - 'disabling metadata removed also all keys, so metadata init flow takes all steps now expect for providers, these stay connected', - ); - cy.getConfirmActionOnDeviceModal(); - cy.task('pressYes'); - cy.wait(501); - - // device saved, disconnect provider - cy.getTestElement('@menu/switch-device').click(); - cy.getTestElement('@switch-device/wallet-on-index/0').click(); - cy.task('stopEmu'); - - cy.log('Device is saved, when disconnected, user still can edit labels'); - cy.getTestElement("@metadata/accountLabel/m/84'/0'/0'/edit-label-button").click({ - force: true, - }); - cy.getTestElement('@metadata/input').type(' edited for remembered{enter}'); - - cy.log('Now again, lets try disconnecting provider'); - onNavBar.openSettings(); - cy.getTestElement('@settings/metadata/disconnect-provider-button').click(); - cy.getTestElement('@account-menu/btc/normal/0').click(); - cy.log('Disconnecting removes labels'); - cy.getTestElement('@account-menu/btc/normal/0/label').should('contain', 'Bitcoin'); - - cy.log('Still possible to reconnect provider, we have keys still saved'); - // todo: sometimes modal appears and closes immediately before cypress being able to focus - // it, probably a race-condition in suite killing it with some action. adding wait :( - cy.wait(1000); - cy.hoverTestElement("@metadata/accountLabel/m/84'/0'/0'/hover-container"); - cy.getTestElement("@metadata/accountLabel/m/84'/0'/0'/add-label-button").click(); - - cy.getTestElement(`@modal/metadata-provider/${f.provider}-button`).click(); - cy.getTestElement('@modal/metadata-provider').should('not.exist'); - cy.getTestElement('@metadata/input').type('mnau{enter}'); - - // device saved, disable metadata - onNavBar.openSettings(); - cy.getTestElement('@settings/metadata-switch').click({ force: true }); - cy.getTestElement('@account-menu/btc/normal/0').click(); - cy.log( - 'Now it is not possible to add labels, keys are gone and device is not connected', - ); - cy.getTestElement("@metadata/accountLabel/m/84'/0'/0'/add-label-button").should( - 'not.exist', - ); - }); - }); - }, -); diff --git a/packages/suite-web/e2e/tests/metadata/switching-providers.test.ts b/packages/suite-web/e2e/tests/metadata/switching-providers.test.ts deleted file mode 100644 index 182038b5bea..00000000000 --- a/packages/suite-web/e2e/tests/metadata/switching-providers.test.ts +++ /dev/null @@ -1,61 +0,0 @@ -// @group_metadata -// @retry=2 - -import { rerouteMetadataToMockProvider, stubOpen } from '../../stubs/metadata'; -import { onNavBar } from '../../support/pageObjects/topBarObject'; - -describe(`Metadata - switching between cloud providers`, () => { - beforeEach(() => { - // use portrait mode monitor to prevent scrolling in settings - cy.viewport('macbook-13').resetDb(); - }); - - it('Start with one and switch to another', () => { - // prepare test - cy.task('startEmu', { wipe: true }); - cy.task('setupEmu', { mnemonic: 'mnemonic_all' }); - cy.task('startBridge'); - cy.task(`metadataStartProvider`, 'dropbox'); - cy.task(`metadataStartProvider`, 'google'); - - cy.prefixedVisit('/', { - onBeforeLoad: (win: Window) => { - cy.stub(win, 'open').callsFake(stubOpen(win)); - cy.stub(win, 'fetch').callsFake(rerouteMetadataToMockProvider); - }, - }); - cy.passThroughInitialRun(); - cy.discoveryShouldFinish(); - cy.getTestElement('@account-menu/btc/normal/0').click(); - - cy.getTestElement('@account-menu/btc/normal/0/label').should('contain', 'Bitcoin'); - - cy.getTestElement("@metadata/accountLabel/m/84'/0'/0'/add-label-button").click({ - force: true, - }); - cy.passThroughInitMetadata('dropbox'); - - cy.getTestElement('@metadata/input').type('dropbox label {enter}'); - cy.getTestElement('@account-menu/btc/normal/0/label').should('contain', 'dropbox label'); - - onNavBar.openSettings(); - cy.getTestElement('@settings/metadata/disconnect-provider-button').click(); - cy.getTestElement('@settings/metadata/connect-provider-button').should('be.visible'); - - cy.getTestElement('@account-menu/btc/normal/0').click(); - cy.log('Disconnecting removes labels'); - cy.getTestElement('@account-menu/btc/normal/0/label').should('contain', 'Bitcoin'); - - cy.getTestElement("@metadata/accountLabel/m/84'/0'/0'/add-label-button").click({ - force: true, - }); - - cy.getTestElement('@modal/metadata-provider').should('be.visible'); - cy.getTestElement('@modal/metadata-provider/file-system-button').should('not.exist'); - cy.getTestElement('@modal/metadata-provider/google-button').click(); - cy.getTestElement('@modal/metadata-provider').should('not.exist'); - - cy.getTestElement('@metadata/input').type('google label {enter}'); - cy.getTestElement('@account-menu/btc/normal/0/label').should('contain', 'google label'); - }); -});