Skip to content

Commit

Permalink
feat(e2e): New test that actually works with a new tab
Browse files Browse the repository at this point in the history
  • Loading branch information
Vere-Grey committed Jan 24, 2025
1 parent 6c682fd commit 4df18e2
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ export class DashboardActions {
this.addStandardWalletButton = this.page.getByTestId('@switch-device/add-wallet-button');
this.hideBalanceButton = this.page.getByTestId('@quickActions/hideBalances');
this.portfolioFiatAmount = this.page.getByTestId('@dashboard/portfolio/fiat-amount');
this.deviceStatus = this.page.getByTestId('@deviceStatus');
this.deviceStatus = this.page.locator("[data-testid-alt='@deviceStatus']");
this.deviceStatusOnSwitchDevice = this.page
.getByTestId('@menu/switch-device')
.getByTestId('@deviceStatus');
.getByTestId("[data-testid-alt='@deviceStatus']");
this.solveIssuesButton = this.page.getByTestId('@switch-device/solve-issue-button');
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { BridgeTransport } from '@trezor/transport';
import * as messages from '@trezor/protobuf/src/messages';

import { test, expect } from '../../support/fixtures';
import { DashboardActions } from '../../support/pageActions/dashboardActions';

const stealBridgeSession = async () => {
const bridge = new BridgeTransport({ messages, id: 'foo-bar' });
Expand All @@ -15,11 +16,11 @@ const stealBridgeSession = async () => {

const testCases = [
{
description: 'Multiple sessions for view-only disabled',
description: 'Session overtaken by another - View-Only Disabled',
enableViewOnly: false,
},
{
description: 'Multiple sessions for view-only enabled',
description: 'Session overtaken by another - View-Only Enabled',
enableViewOnly: true,
},
];
Expand Down Expand Up @@ -68,4 +69,20 @@ test.describe('Multiple sessions', { tag: ['@group=suite'] }, () => {
});
});
}

test(
'Overtake session by opening suite new tab',
{ tag: ['@webOnly'] },
async ({ context, onboardingPage, dashboardPage }) => {
await onboardingPage.completeOnboarding();
await dashboardPage.discoveryShouldFinish();

const pageTwo = await context.newPage();
await pageTwo.goto('');
const dashboardPageTwo = new DashboardActions(pageTwo);
await dashboardPageTwo.discoveryShouldFinish();
await expect(dashboardPageTwo.deviceStatus).toHaveText('Connected');
await expect(dashboardPage.deviceStatus).toHaveText('Refresh');
},
);
});
4 changes: 2 additions & 2 deletions packages/suite-web/e2e/tests/suite/database-migration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ describe('Database migration', () => {
cy.getTestElement('@dashboard/graph', { timeout: 40000 }).should('be.visible');
cy.getTestElement('@account-menu/btc/normal/0').click();
cy.getTestElement('@menu/switch-device').click();
cy.getTestElement('@deviceStatus').should('have.text', 'Disconnected');
cy.getTestElement('@deviceStatus-disconnected');
cy.contains('[data-testid^="@switch-device/wallet-on-index"]', 'Passphrase wallet #1')
.find('input')
.should('be.checked');
Expand Down Expand Up @@ -152,7 +152,7 @@ describe('Database migration', () => {

cy.task('startEmu');
cy.disableFirmwareHashCheck(); // only applicable for the `to` version, not the older `from` version
cy.getTestElement('@deviceStatus').should('have.text', 'Connected');
cy.getTestElement('@deviceStatus-connected').should('be.visible');
cy.getTestElement('@account-subpage/back').last().click();

// checking the Send form
Expand Down
8 changes: 4 additions & 4 deletions packages/suite-web/e2e/tests/suite/passphrase-cardano.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ describe('Passphrase with cardano', () => {

// restart device
cy.task('stopEmu');
cy.getTestElement('@deviceStatus').should('have.text', 'Disconnected');
cy.getTestElement('@deviceStatus-disconnected');
cy.task('startEmu');
cy.getTestElement('@deviceStatus').should('have.text', 'Connected');
cy.getTestElement('@deviceStatus-connected');

// reveal cardano address
cy.getTestElement('@account-menu/ada/normal/0').click();
Expand All @@ -77,9 +77,9 @@ describe('Passphrase with cardano', () => {
// restart device again
// restart device
cy.task('stopEmu');
cy.getTestElement('@deviceStatus').should('have.text', 'Disconnected');
cy.getTestElement('@deviceStatus-disconnected');
cy.task('startEmu');
cy.getTestElement('@deviceStatus').should('have.text', 'Connected');
cy.getTestElement('@deviceStatus-connected');

// reveal cardano address, now enter wrong passphrase
cy.getTestElement('@wallet/receive/reveal-address-button').click();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ const DeviceStatusVisible = ({ device, connected, forceConnectionInfo }: DeviceS
<DeviceConnectionText
variant={connected ? 'primary' : 'tertiary'}
icon={connected ? 'link' : 'unlink'}
data-testid="@deviceStatus"
data-testid={connected ? '@deviceStatus-connected' : '@deviceStatus-disconnected'}
data-testid-alt="@deviceStatus"
>
{walletText && !forceConnectionInfo ? (
<TruncateWithTooltip delayShow={TOOLTIP_DELAY_LONG}>
Expand All @@ -65,7 +66,8 @@ export const DeviceStatusText = ({
<DeviceConnectionText
variant="warning"
icon="refresh"
data-testid="@deviceStatus"
data-testid={connected ? '@deviceStatus-connected' : '@deviceStatus-disconnected'}
data-testid-alt="@deviceStatus"
isAction
>
<Translation id="TR_SOLVE_ISSUE" />
Expand Down

0 comments on commit 4df18e2

Please sign in to comment.