-
-
Notifications
You must be signed in to change notification settings - Fork 272
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(e2e): Migrated remembered device test
- Loading branch information
1 parent
cffe429
commit 11961ea
Showing
6 changed files
with
146 additions
and
179 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
132 changes: 132 additions & 0 deletions
132
packages/suite-desktop-core/e2e/tests/metadata/remembered-device.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
import { TrezorUserEnvLink } from '@trezor/trezor-user-env-link'; | ||
|
||
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, | ||
}) => { | ||
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(); | ||
}); | ||
}); |
Oops, something went wrong.