Skip to content

Commit

Permalink
refactor(e2e): improves the validation of view-only disabled flow
Browse files Browse the repository at this point in the history
better logging of test steps
  • Loading branch information
Vere-Grey committed Jan 27, 2025
1 parent d243c6a commit a7b9e6d
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { step } from '../common';

export class DevicePromptActions {
readonly confirmOnDevicePrompt: Locator;
private readonly connectDevicePrompt: Locator;
readonly connectDevicePrompt: Locator;
readonly modal: Locator;
private readonly paginatedText: Locator;
private readonly paginatedTextSeparator: Locator;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,33 @@ import { test, expect } from '../../support/fixtures';
import { DashboardActions } from '../../support/pageActions/dashboardActions';

const stealBridgeSession = async () => {
const bridge = new BridgeTransport({ messages, id: 'foo-bar' });
await bridge.init();
const enumerateRes = await bridge.enumerate();
if (!enumerateRes.success) return null;
await bridge.acquire({
input: { path: enumerateRes.payload[0].path, previous: null },
await test.step('Steal Bridge session', async () => {
const bridge = new BridgeTransport({ messages, id: 'foo-bar' });
await bridge.init();
const enumerateRes = await bridge.enumerate();
if (!enumerateRes.success) return null;
await bridge.acquire({
input: { path: enumerateRes.payload[0].path, previous: null },
});
});
};

const testCases = [
{
description: 'Session overtaken by another - View-Only Disabled',
testName: 'Session overtaken by another - View-Only Disabled',
enableViewOnly: false,
},
{
description: 'Session overtaken by another - View-Only Enabled',
testName: 'Session overtaken by another - View-Only Enabled',
enableViewOnly: true,
},
];

test.describe('Multiple sessions', { tag: ['@group=suite'] }, () => {
test.use({ emulatorSetupConf: { passphrase_protection: true } });

for (const { description, enableViewOnly } of testCases) {
test(description, async ({ page, onboardingPage, dashboardPage }) => {
for (const { testName, enableViewOnly } of testCases) {
test(testName, async ({ page, onboardingPage, dashboardPage, devicePrompt }) => {
await onboardingPage.completeOnboarding({ enableViewOnly });
await dashboardPage.discoveryShouldFinish();
await test.step('Bridge session taken by another suite session', async () => {
Expand All @@ -49,15 +51,24 @@ test.describe('Multiple sessions', { tag: ['@group=suite'] }, () => {
await expect(dashboardPage.deviceStatus).toHaveText('Connected');
});

// This is where the flow ends for view-only disabled
await test.step('Reload inactive suite session', async () => {
await stealBridgeSession();
await expect(dashboardPage.deviceStatus).toHaveText('Refresh');
await page.reload();
});

if (!enableViewOnly) {
await test.step('After reloading inactive suite session does not take Bridge session back', async () => {
await expect(devicePrompt.connectDevicePrompt).toHaveText(
'Failed to communicate with your Trezor',
);
});

// This is where the flow ends for view-only disabled
return;
}

await test.step('Reloading inactive suite session does not take Bridge session back', async () => {
await stealBridgeSession();
await expect(dashboardPage.deviceStatus).toHaveText('Refresh');
await page.reload();
await test.step('After reloading inactive suite session does not take Bridge session back', async () => {
await expect(dashboardPage.deviceStatus).toHaveText('Disconnected');
await dashboardPage.deviceSwitchingOpenButton.click();
await expect(dashboardPage.deviceStatusOnSwitchDevice).toHaveText('Disconnected');
Expand Down

0 comments on commit a7b9e6d

Please sign in to comment.