Skip to content

Commit

Permalink
test(connect-popup): stabilize popup-close test
Browse files Browse the repository at this point in the history
(cherry picked from commit 25c183f)
  • Loading branch information
mroz22 authored and komret committed Nov 8, 2023
1 parent 3c5bc5d commit c853e54
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions packages/connect-popup/e2e/tests/popup-close.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ let responses: Response[] = [];
let releasePromise: Deferred<void> | undefined;
// popup window reference
let popup: Page;
let logPage: Page;
// let logPage: Page;
let popupClosedPromise: Promise<undefined> | undefined;

test.beforeAll(async () => {
Expand All @@ -32,7 +32,7 @@ test.beforeAll(async () => {
// - host bridge that is used in this test on trezor.io domain, or
// - run it all locally in CI (./docker/docker-compose.connect.explorer.test.yml)
[/* '2.0.27', */ '2.0.31'].forEach(bridgeVersion => {
test.beforeEach(async ({ page, context }) => {
test.beforeEach(async ({ page }) => {
requests = [];
responses = [];
releasePromise = createDeferred();
Expand All @@ -57,8 +57,12 @@ test.beforeAll(async () => {
log('beforeEach', 'startBridge');
await TrezorUserEnvLink.api.startBridge(bridgeVersion);
log('beforeEach', 'open log page');
logPage = await context.newPage();
await logPage.goto(`${host}log.html`);

// this would be very useful but is breaking one of the tests. could be
// that it inconsciously uncovers a bug in how npm pacakge is focusing popup
// logPage = await context.newPage();
// await logPage.goto(`${host}log.html`);

await page.goto(`${url}#/method/verifyMessage`);
await page.waitForSelector("button[data-test='@submit-button']", { state: 'visible' });

Expand Down Expand Up @@ -156,6 +160,8 @@ test.beforeAll(async () => {
}) => {
// user canceled dialog on device
await TrezorUserEnvLink.send({ type: 'emulator-press-no' });
await TrezorUserEnvLink.send({ type: 'emulator-press-yes' });

await page.waitForTimeout(WAIT_AFTER_TEST);

responses.forEach(response => {
Expand Down Expand Up @@ -304,7 +310,11 @@ test.beforeAll(async () => {
test('popup should close and open new one when popup is in error state and user triggers new call', async ({
page,
}) => {
// user canceled interaction on device
await TrezorUserEnvLink.api.pressNo();
await TrezorUserEnvLink.api.pressYes();

// await page.pause();

// Error page is displayed.
await findElementByDataTest(popup, '@connect-ui/error');
Expand All @@ -319,6 +329,9 @@ test.beforeAll(async () => {

// We cancel the request since we already tested what we wanted.
await waitAndClick(popup, ['@permissions/cancel-button']);
// Wait for popup to close.
await popupClosedPromise;
await page.waitForSelector('text=Permissions not granted');
});

test('popup should be focused when a call is in progress and user triggers new call', async ({
Expand Down

0 comments on commit c853e54

Please sign in to comment.