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

updated tests and added coverage for edit feature #608

Merged
merged 5 commits into from
Mar 4, 2024

Conversation

Carla-Moz
Copy link
Contributor

@Carla-Moz Carla-Moz commented Feb 24, 2024

Copy link

netlify bot commented Feb 24, 2024

Deploy Preview for mozilla-perfcompare ready!

Name Link
🔨 Latest commit cdde0d1
🔍 Latest deploy log https://app.netlify.com/sites/mozilla-perfcompare/deploys/65e6202072a31a00081fa263
😎 Deploy Preview https://deploy-preview-608--mozilla-perfcompare.netlify.app/
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@Carla-Moz Carla-Moz added the 🚧 WIP 🚧 Work in progress: do not merge label Feb 24, 2024
Copy link

codecov bot commented Feb 24, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 97.87%. Comparing base (8cabf8c) to head (cdde0d1).

Additional details and impacted files
@@            Coverage Diff             @@
##             beta     #608      +/-   ##
==========================================
+ Coverage   93.67%   97.87%   +4.20%     
==========================================
  Files          64       64              
  Lines        1422     1410      -12     
  Branches      223      219       -4     
==========================================
+ Hits         1332     1380      +48     
+ Misses         88       28      -60     
  Partials        2        2              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Carla-Moz Carla-Moz added Ready For Review and removed 🚧 WIP 🚧 Work in progress: do not merge labels Feb 28, 2024
Copy link
Contributor

@julienw julienw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this work!

As far as I understand the PR contains 3 different topics:

  • The edit mode tests
  • the result of npm audit fix
  • the change of style of ExpandableRow
  • (and also some change I don't understand in CompareWithBase, so I'm not sure where this goes)

Therefore before moving further, it would be good to make this PR only about the edit mode tests, so that we're not confused about all the other changes. I haven't reviewed the other topics anyway, so please remove them away from this PR and create separate PR for these. I'll gladly review them separately.

Now let's go for the meat of this issue!
I think the tests work well and bring some more coverage, especially around clicking inside the dropdown, so that's great.
I left a few easy comments that go basically into 3 buckets:

  • make the file easier to work with (about setting the fetch mocks especially, or not doing twice the same tests)
  • have fetch mocks for everything (see warnings in the console)
  • bring some more coverage to our code (uncheck the elements in the dropdown instead of using the cross)

Happy to discuss :)

@@ -272,6 +254,7 @@ function CompareWithBase({
action='/compare-results'
className='form-wrapper'
onSubmit={possiblyPreventFormSubmission}
role='form'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is not needed, a <form> already has the implicit role form

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, true. But the test kept outputting an error, saying it can't findByRole('form'). That's why I added it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, indeed I found this old issue with some more explanations: testing-library/dom-testing-library#1021
In short a <form> is not exposed with the role form implicitely if it doesn't have an accessible name. But this seems to have changed since then, so I filed this new one: testing-library/dom-testing-library#1293

Hopefully this issue will be fixed in the future then. In the mean time I think your change is valid.

Now I wonder if we could add an aria-label instead of a role. Surely this makes some sense, especially when we'll have both "Compare with base" and "Compare over time" in the future. Labeling the form could help a screen reader user to know which form they're focusing in, and I also believe the screen readers have functionality to list all forms and focus them.

Therefore I would suggest to add a aria-label (maybe aria-label="Compare with base" is good enough) instead of a role. What do you think?

src/styles/ExpandableRow.ts Outdated Show resolved Hide resolved
src/components/Search/CompareWithBase.tsx Show resolved Hide resolved
src/__tests__/Search/CompareWithBase.test.tsx Outdated Show resolved Hide resolved
src/__tests__/Search/CompareWithBase.test.tsx Outdated Show resolved Hide resolved
src/__tests__/Search/CompareWithBase.test.tsx Outdated Show resolved Hide resolved
src/__tests__/Search/CompareWithBase.test.tsx Show resolved Hide resolved
src/__tests__/Search/CompareWithBase.test.tsx Show resolved Hide resolved
src/__tests__/Search/CompareWithBase.test.tsx Outdated Show resolved Hide resolved
src/__tests__/Search/CompareWithBase.test.tsx Outdated Show resolved Hide resolved
Copy link
Contributor

@julienw julienw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, looks good to me, good work!

I'd like just 2 small last changes before merging :-) Then with these changes you can merge directly without an extra review.

@@ -272,6 +254,7 @@ function CompareWithBase({
action='/compare-results'
className='form-wrapper'
onSubmit={possiblyPreventFormSubmission}
role='form'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, indeed I found this old issue with some more explanations: testing-library/dom-testing-library#1021
In short a <form> is not exposed with the role form implicitely if it doesn't have an accessible name. But this seems to have changed since then, so I filed this new one: testing-library/dom-testing-library#1293

Hopefully this issue will be fixed in the future then. In the mean time I think your change is valid.

Now I wonder if we could add an aria-label instead of a role. Surely this makes some sense, especially when we'll have both "Compare with base" and "Compare over time" in the future. Labeling the form could help a screen reader user to know which form they're focusing in, and I also believe the screen readers have functionality to list all forms and focus them.

Therefore I would suggest to add a aria-label (maybe aria-label="Compare with base" is good enough) instead of a role. What do you think?

Comment on lines 26 to 24
(window.fetch as FetchMockSandbox)
.get('begin:https://treeherder.mozilla.org/api/perfcompare/results/', [])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick: you can chain with the previous definitions:

global.fetch.get(
  ...
)
.get(
 ...
)
.get( 
  ...
);

@Carla-Moz
Copy link
Contributor Author

Therefore I would suggest to add a aria-label (maybe aria-label="Compare with base" is good enough) instead of a role. What do you think?

@julienw This seems like a good solution to me, esp since I'm working on the Compare over time component. It makes sense to differentiate between the two.

@Carla-Moz Carla-Moz merged commit 239d0b1 into mozilla:beta Mar 4, 2024
10 checks passed
@Carla-Moz Carla-Moz deleted the edit-feature-tests branch March 4, 2024 19:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants