ChainSafe / dappeteer

[DEPRECATED]🏌🏼‍E2E testing for dApps using Puppeteer + MetaMask
Other
491 stars 152 forks source link

Flaky test results with accept and reject dialog (flask 10.22.2) #207

Closed irubido closed 1 year ago

irubido commented 1 year ago

Tests are failing and passing randomly when accepting/rejecting .invokeSnap is called for snap_confirm rpc method While writing test-snap integration tests I realized that tests can't find button, depenedent on how button loads. Hacky fix, i added waitForTimeout(1000) to ensure button loads and can be confirmed with accept/reject

To Reproduce Steps to reproduce the behavior:

  1. Go to https://github.com/ChainSafe/test-snaps/pull/2
  2. Set flask version in node modules @chainsafe/dappeteer/dist/index.js exports.RECOMMENDED_METAMASK_VERSION = "v10.22.2";
  3. Try running tests mulitiple times with and without timeout localy

Logs

confirm snap › snap invoke confirm accept

    TimeoutError: page.waitForSelector: Timeout 100ms exceeded.
    =========================== logs ===========================
    waiting for locator('xpath=//button[contains(text(), \'Approve\')]') to be visible
    ============================================================page.waitForSelector: Timeout 100ms exceeded.
    =========================== logs ===========================
    waiting for locator('xpath=//button[contains(text(), \'Approve\')]') to be visible
    ============================================================

      37 |       ['Test-prompt', 'Test-description', 'Test-textAreaContent'],
      38 |     );
    > 39 |     await dappeteer.snaps.acceptDialog();
         |     ^
      40 |     const result = await resultPromise;
      41 |
      42 |     expect(result).toBe(true);

Expected behavior Accept and reject should work

Screenshots

Screenshot 2022-12-06 at 13 39 58

System:

Additional context Add any other context about the problem here.

Lykhoyda commented 1 year ago

@irubido we could close this bug as we increased the timeout for the method to 1000ms

await clickOnButton(page, "Approve", { timeout: 1000 });

https://github.com/ChainSafe/dappeteer/commit/cb6abfc4bf751addd2e3f1746db3c4183f495c10