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

fix: non deterministic unit test failure #11785

Closed
1 of 9 tasks
NicolasMassart opened this issue Oct 14, 2024 · 0 comments · Fixed by #11787
Closed
1 of 9 tasks

fix: non deterministic unit test failure #11785

NicolasMassart opened this issue Oct 14, 2024 · 0 comments · Fixed by #11787
Assignees
Labels
release-7.34.0 release-blocker This bug is blocking the next release Sev3-low A possible confusion or deception that is only hypothetical & has no known instances in the wild team-mobile-platform

Comments

@NicolasMassart
Copy link
Contributor

What is this about?

app/components/UI/Notification/NotificationMenuItem/Content.test.tsx is non deterministic as the render displays since how long the notification has been sent and the test has a fixed date. So duration changes on every test run.

Scenario

No response

Design

No response

Technical Details

fix test to have the notification age always the same. Use now().

Threat Modeling Framework

No response

Acceptance Criteria

No response

Stakeholder review needed before the work gets merged

  • Engineering (needed in most cases)
  • Design
  • Product
  • QA (automation tests are required to pass before merging PRs but not all changes are covered by automation tests - please review if QA is needed beyond automation tests)
  • Security
  • Legal
  • Marketing
  • Management (please specify)
  • Other (please specify)

References

FAIL app/components/UI/Notification/NotificationMenuItem/Content.test.tsx
  ● NotificationContent › renders correctly

    expect(received).toMatchSnapshot()

    Snapshot name: `NotificationContent renders correctly 1`

    - Snapshot  - 1
    + Received  + 1

    @@ -42,11 +42,11 @@
                "letterSpacing": 0,
                "lineHeight": 20,
              }
            }
          >
    -       5 months ago
    +       6 months ago
          </Text>
        </View>
        <View
          style={
            {

      21 |       />,
      22 |     );
    > 23 |     expect(toJSON()).toMatchSnapshot();
         |                      ^
      24 |   });
      25 |
      26 |   it('renders title and 1 part of description', () => {

      at Object.toMatchSnapshot (app/components/UI/Notification/NotificationMenuItem/Content.test.tsx:23:22)

 › 1 snapshot failed.
@NicolasMassart NicolasMassart added team-mobile-platform release-blocker This bug is blocking the next release Sev3-low A possible confusion or deception that is only hypothetical & has no known instances in the wild labels Oct 14, 2024
@NicolasMassart NicolasMassart self-assigned this Oct 14, 2024
github-merge-queue bot pushed a commit that referenced this issue Oct 14, 2024
## **Description**

Fixes date that was generating an ever changing duration in the
snapshot.
- replace it with a relative date to the moment the test is running to
make the duration always one day: the notification renders as if it was
sent yesterday, always.
- fix duration to one day (yesterday) as we have to fix one and it's not
a worse value than any other.
- rename test case to match guideline while I was on it...

<!--
Write a short description of the changes included in this pull request,
also include relevant motivation and context. Have in mind the following
questions:
1. What is the reason for the change?
2. What is the improvement/solution?
-->

## **Related issues**

Fixes #11785

## **Manual testing steps**

N/A

## **Screenshots/Recordings**

N/A

### **Before**

N/A

### **After**

N/A

## **Pre-merge author checklist**

- [x] I’ve followed [MetaMask Contributor
Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Mobile
Coding
Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.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
- [x] I’ve documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [x] I’ve applied the right labels on the PR (see [labeling
guidelines](https://github.com/MetaMask/metamask-mobile/blob/main/.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: sethkfman <[email protected]>
runway-github bot added a commit that referenced this issue Oct 14, 2024
## **Description**

Fixes date that was generating an ever changing duration in the
snapshot.
- replace it with a relative date to the moment the test is running to
make the duration always one day: the notification renders as if it was
sent yesterday, always.
- fix duration to one day (yesterday) as we have to fix one and it's not
a worse value than any other.
- rename test case to match guideline while I was on it...

<!--
Write a short description of the changes included in this pull request,
also include relevant motivation and context. Have in mind the following
questions:
1. What is the reason for the change?
2. What is the improvement/solution?
-->

## **Related issues**

Fixes #11785

## **Manual testing steps**

N/A

## **Screenshots/Recordings**

N/A

### **Before**

N/A

### **After**

N/A

## **Pre-merge author checklist**

- [x] I’ve followed [MetaMask Contributor
Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Mobile
Coding
Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.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
- [x] I’ve documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [x] I’ve applied the right labels on the PR (see [labeling
guidelines](https://github.com/MetaMask/metamask-mobile/blob/main/.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: sethkfman <[email protected]>
runway-github bot added a commit that referenced this issue Oct 14, 2024
## **Description**

Fixes date that was generating an ever changing duration in the
snapshot.
- replace it with a relative date to the moment the test is running to
make the duration always one day: the notification renders as if it was
sent yesterday, always.
- fix duration to one day (yesterday) as we have to fix one and it's not
a worse value than any other.
- rename test case to match guideline while I was on it...

<!--
Write a short description of the changes included in this pull request,
also include relevant motivation and context. Have in mind the following
questions:
1. What is the reason for the change?
2. What is the improvement/solution?
-->

## **Related issues**

Fixes #11785

## **Manual testing steps**

N/A

## **Screenshots/Recordings**

N/A

### **Before**

N/A

### **After**

N/A

## **Pre-merge author checklist**

- [x] I’ve followed [MetaMask Contributor
Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Mobile
Coding
Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.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
- [x] I’ve documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [x] I’ve applied the right labels on the PR (see [labeling
guidelines](https://github.com/MetaMask/metamask-mobile/blob/main/.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: sethkfman <[email protected]>
runway-github bot added a commit that referenced this issue Oct 14, 2024
## **Description**

Fixes date that was generating an ever changing duration in the
snapshot.
- replace it with a relative date to the moment the test is running to
make the duration always one day: the notification renders as if it was
sent yesterday, always.
- fix duration to one day (yesterday) as we have to fix one and it's not
a worse value than any other.
- rename test case to match guideline while I was on it...

<!--
Write a short description of the changes included in this pull request,
also include relevant motivation and context. Have in mind the following
questions:
1. What is the reason for the change?
2. What is the improvement/solution?
-->

## **Related issues**

Fixes #11785

## **Manual testing steps**

N/A

## **Screenshots/Recordings**

N/A

### **Before**

N/A

### **After**

N/A

## **Pre-merge author checklist**

- [x] I’ve followed [MetaMask Contributor
Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Mobile
Coding
Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.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
- [x] I’ve documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [x] I’ve applied the right labels on the PR (see [labeling
guidelines](https://github.com/MetaMask/metamask-mobile/blob/main/.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: sethkfman <[email protected]>
runway-github bot added a commit that referenced this issue Oct 14, 2024
## **Description**

Fixes date that was generating an ever changing duration in the
snapshot.
- replace it with a relative date to the moment the test is running to
make the duration always one day: the notification renders as if it was
sent yesterday, always.
- fix duration to one day (yesterday) as we have to fix one and it's not
a worse value than any other.
- rename test case to match guideline while I was on it...

<!--
Write a short description of the changes included in this pull request,
also include relevant motivation and context. Have in mind the following
questions:
1. What is the reason for the change?
2. What is the improvement/solution?
-->

## **Related issues**

Fixes #11785

## **Manual testing steps**

N/A

## **Screenshots/Recordings**

N/A

### **Before**

N/A

### **After**

N/A

## **Pre-merge author checklist**

- [x] I’ve followed [MetaMask Contributor
Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Mobile
Coding
Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.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
- [x] I’ve documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [x] I’ve applied the right labels on the PR (see [labeling
guidelines](https://github.com/MetaMask/metamask-mobile/blob/main/.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: sethkfman <[email protected]>
runway-github bot added a commit that referenced this issue Oct 14, 2024
## **Description**

Fixes date that was generating an ever changing duration in the
snapshot.
- replace it with a relative date to the moment the test is running to
make the duration always one day: the notification renders as if it was
sent yesterday, always.
- fix duration to one day (yesterday) as we have to fix one and it's not
a worse value than any other.
- rename test case to match guideline while I was on it...

<!--
Write a short description of the changes included in this pull request,
also include relevant motivation and context. Have in mind the following
questions:
1. What is the reason for the change?
2. What is the improvement/solution?
-->

## **Related issues**

Fixes #11785

## **Manual testing steps**

N/A

## **Screenshots/Recordings**

N/A

### **Before**

N/A

### **After**

N/A

## **Pre-merge author checklist**

- [x] I’ve followed [MetaMask Contributor
Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Mobile
Coding
Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.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
- [x] I’ve documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [x] I’ve applied the right labels on the PR (see [labeling
guidelines](https://github.com/MetaMask/metamask-mobile/blob/main/.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: sethkfman <[email protected]>
sethkfman added a commit that referenced this issue Oct 14, 2024
## **Description**

Cherry pick for #11785 

## **Related issues**

Fixes:

## **Manual testing steps**

1. Go to this page...
2.
3.

## **Screenshots/Recordings**

<!-- If applicable, add screenshots and/or recordings to visualize the
before and after of your change. -->

### **Before**

<!-- [screenshots/recordings] -->

### **After**

<!-- [screenshots/recordings] -->

## **Pre-merge author checklist**

- [ ] I’ve followed [MetaMask Contributor
Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Mobile
Coding
Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/CODING_GUIDELINES.md).
- [ ] I've completed the PR template to the best of my ability
- [ ] 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-mobile/blob/main/.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: Nico MASSART <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release-7.34.0 release-blocker This bug is blocking the next release Sev3-low A possible confusion or deception that is only hypothetical & has no known instances in the wild team-mobile-platform
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants