Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flaky Test: "Dapp viewed Event @no-mmi is sent when reconnect to a dapp that has been connected before" #24575

Closed
seaona opened this issue May 17, 2024 · 1 comment · Fixed by #24580
Assignees
Labels
flaky tests INVALID-ISSUE-TEMPLATE Issue's body doesn't match any issue template. release-11.18.0 Issue or pull request that will be included in release 11.18.0 team-extension-platform

Comments

@seaona
Copy link
Contributor

seaona commented May 17, 2024

Context:

https://app.circleci.com/pipelines/github/MetaMask/metamask-extension/80401/workflows/55c49ded-58c2-487a-8ab2-afb21f8f8a2e/jobs/2836310/tests

@seaona seaona self-assigned this May 17, 2024
@metamaskbot metamaskbot added the INVALID-ISSUE-TEMPLATE Issue's body doesn't match any issue template. label May 17, 2024
@seaona
Copy link
Contributor Author

seaona commented May 17, 2024

Investigation

Artifacts and logs from ci.

image

Screenshot from 2024-05-17 11-27-45

[driver] Called 'clickElement' with arguments [{"text":"Got it","tag":"button"}]
[driver] Called 'clickElement' with arguments [{"text":"127.0.0.1:8080","tag":"p"}]
Failure on testcase: 'Dapp viewed Event @no-mmi is sent when reconnect to a dapp that has been connected before', for more information see the artifacts tab in CI
ElementClickInterceptedError: Element <p class="mm-box mm-text mm-text--body-md mm-text--ell

seaona added a commit that referenced this issue May 20, 2024
…d `Connections Page...` due to overlaying popup (#24580)

## **Description**
This is a PR for fixing the flaky tests:
- Dapp viewed Event @no-mmi is sent when reconnect to a dapp that has
been connected before
- Permissions Page should redirect users to connections page when users
click on connected permission
- Connections page should disconnect when click on Disconnect button in
connections page

The problem seems to be that we are trying to click an element, but
there is the previous notifcation element on top and has not disappeared
yet at the moment we want to perform the click operation.

We can see this in the artifacts of the failure, where the blue
notification popup is still there, despite having already clicked 'Got
it'.
This is also confirmed by the error message in the logs:

```
[driver] Called 'clickElement' with arguments [{"text":"Got it","tag":"button"}]
[driver] Called 'clickElement' with arguments [{"text":"127.0.0.1:8080","tag":"p"}]
Failure on testcase: 'Dapp viewed Event @no-mmi is sent when reconnect to a dapp that has been connected before', for more information see the artifacts tab in CI
ElementClickInterceptedError: Element <p class="mm-box mm-text mm-text--body-md mm-text--elllipsis mm-text--text-align-left mm-box--color-text-default">
 is not clickable at point (444,92) because another element <h4 class="mm-box mm-text mm-text--heading-sm mm-text--text-align-center mm-box--width-full mm-box--color-info-inverse"> obscures it
```

The solution here is to wait for the element to disappear. Since this
seems a case that can happen more often, a new driver function has been
introduced, which basically clicks an element and waits until it
disappears. This can be suitable for when accepting notifications/popup
that whenever we accept them, those should disappear before we proceed
with the next action.

```
  async clickElementAndWaitToDisappear(rawLocator) {
    const element = await this.findClickableElement(rawLocator);
    await element.click();
    await element.waitForElementState('hidden');
  }
 ```

## **Related issues**

Fixes: #24575 and #24597

## **Manual testing steps**

1. locally: run the test locally several times ` yarn test:e2e:single test/e2e/tests/metrics/dapp-viewed.spec.js --browser=chrome --leave-running=true`
2. ci: Check ci and see is not failing

## **Screenshots/Recordings**
Artifacts and logs from ci that helped in the investigation:

![image](https://github.com/MetaMask/metamask-extension/assets/54408225/a63bea82-1a8b-49bc-8037-c389a36579fe)

![Screenshot from 2024-05-17 11-27-45](https://github.com/MetaMask/metamask-extension/assets/54408225/5fdef2d3-8049-445b-a795-a1d7a6f16959)


## **Pre-merge author checklist**

- [X] I’ve followed [MetaMask Coding Standards](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/CODING_GUIDELINES.md).
- [X] I've completed the PR template to the best of my ability
- [X] I’ve included tests if applicable
- [ ] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable
- [ ] I’ve applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors.

## **Pre-merge reviewer checklist**

- [ ] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed).
- [ ] I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots.

---------

Co-authored-by: legobeat <109787230+legobeat@users.noreply.github.com>
@metamaskbot metamaskbot added the release-11.18.0 Issue or pull request that will be included in release 11.18.0 label May 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
flaky tests INVALID-ISSUE-TEMPLATE Issue's body doesn't match any issue template. release-11.18.0 Issue or pull request that will be included in release 11.18.0 team-extension-platform
Projects
None yet
2 participants