Skip to content

Commit

Permalink
test(connect-popup): update test not to use trust-issues query param
Browse files Browse the repository at this point in the history
  • Loading branch information
karliatto committed Nov 10, 2023
1 parent 79036e8 commit c19bfad
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 26 deletions.
6 changes: 6 additions & 0 deletions packages/connect-popup/e2e/support/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,3 +125,9 @@ export const downloadLogs = async (logPage: Page, downloadLogPath: string) => {
await download.saveAs(downloadLogPath);
return download;
};

export const setTrustedHost = async (explorerPage: Page, explorerUrl: string) => {
await explorerPage.goto(`${explorerUrl}#/settings`);
await waitAndClick(explorerPage, ['@checkbox/trustedHost']);
await waitAndClick(explorerPage, ['@submit-button']);
};
2 changes: 1 addition & 1 deletion packages/connect-popup/e2e/tests/methods.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { buildOverview } from '../support/buildOverview';
import { ensureDirectoryExists } from '@trezor/node-utils';
import { getContexts, log, openPopup } from '../support/helpers';

const url = `${process.env.URL || 'http://localhost:8088/'}?trust-issues=true`;
const url = process.env.URL || 'http://localhost:8088/';

const emuScreenshots: Record<string, string> = {};

Expand Down
2 changes: 1 addition & 1 deletion packages/connect-popup/e2e/tests/passphrase.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
waitAndClick,
} from '../support/helpers';

const url = `${process.env.URL || 'http://localhost:8088/'}?trust-issues=true`;
const url = process.env.URL || 'http://localhost:8088/';
const bridgeVersion = '2.0.31';

const isWebExtension = process.env.IS_WEBEXTENSION === 'true';
Expand Down
22 changes: 2 additions & 20 deletions packages/connect-popup/e2e/tests/permissions.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { test, chromium, Page } from '@playwright/test';
import { TrezorUserEnvLink } from '@trezor/trezor-user-env-link';
import { waitAndClick } from '../support/helpers';
import { setTrustedHost } from '../support/helpers';

const url = process.env.URL || 'http://localhost:8088/';

Expand All @@ -16,22 +16,6 @@ test.beforeAll(async () => {
});

const fixtures = [
{
description: `iframe and host same origins but with trust-issues=true -> show permissions`,
queryString: '?trust-issues=true',
setTrustedHost: false,
expect: () => popup.waitForSelector("[data-test='@permissions/confirm-button']"),
},
{
description: `iframe and host same origins but with trust-issues=false -> no permissions shown`,
queryString: '?trust-issues=false',
setTrustedHost: false,
expect: () =>
popup.waitForSelector('//p[contains(., "Follow instructions on your device")]', {
state: 'visible',
strict: false,
}),
},
{
description:
'iframe and host same origins but with settings to trustedHost -> no permissions shown',
Expand All @@ -57,9 +41,7 @@ fixtures.forEach(f => {
const browserInstance = await chromium.launch();
const page = await browserInstance.newPage();
if (f.setTrustedHost) {
await page.goto(`${url}#/settings`);
await waitAndClick(page, ['@checkbox/trustedHost']);
await waitAndClick(page, ['@submit-button']);
await setTrustedHost(page, url);
}
await page.goto(`${url}${f.queryString}#/method/verifyMessage`);

Expand Down
5 changes: 2 additions & 3 deletions packages/connect-popup/e2e/tests/popup-close.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ import {
checkHasLogs,
} from '../support/helpers';

const host = process.env.URL || 'http://localhost:8088/';
const url = `${host}?trust-issues=true`;
const url = process.env.URL || 'http://localhost:8088/';

const WAIT_AFTER_TEST = 3000; // how long test should wait for more potential trezord requests

Expand Down Expand Up @@ -120,7 +119,7 @@ test.beforeAll(async () => {
// we are validating here this commit https://github.com/trezor/connect/commit/fc60c3c03d6e689f3de2d518cc51f62e649a20e2
test.afterEach(async ({ page, context }, testInfo) => {
const logPage = await context.newPage();
await logPage.goto(`${host}log.html`);
await logPage.goto(`${url}log.html`);

const hasLogs = await checkHasLogs(logPage);
if (hasLogs) {
Expand Down
2 changes: 1 addition & 1 deletion packages/connect-popup/e2e/tests/popup-error-page.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { test, Page } from '@playwright/test';
import { TrezorUserEnvLink } from '@trezor/trezor-user-env-link';

const url = `${process.env.URL || 'http://localhost:8088/'}?trust-issues=true`;
const url = process.env.URL || 'http://localhost:8088/';

const bridgeVersion = '2.0.31';

Expand Down

0 comments on commit c19bfad

Please sign in to comment.