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

EDSC-4151: Convert /path/search/granules.cy.js to Playwright #1773

Merged
merged 46 commits into from
Aug 8, 2024
Merged

Conversation

dpesall
Copy link
Member

@dpesall dpesall commented Jul 26, 2024

Overview

What is the feature?

Converting Granules cypress tests to playwright

What is the Solution?

Rewrite relevant cypress tests in playwright.

What areas of the application does this impact?

e2e testing

Testing

Reproduction steps

  1. Run playwright tests in the following path: paths/search/granules/granules.spec.js
  2. Verify that all tests pass

Checklist

  • I have added automated tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings

Sorry, something went wrong.

Copy link

codecov bot commented Jul 29, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 83.22%. Comparing base (ff0ab6c) to head (fc99ba0).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1773      +/-   ##
==========================================
+ Coverage   82.40%   83.22%   +0.82%     
==========================================
  Files         700      700              
  Lines       17503    17503              
  Branches     4565     4595      +30     
==========================================
+ Hits        14423    14567     +144     
+ Misses       3027     2790     -237     
- Partials       53      146      +93     

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

@dpesall dpesall marked this pull request as ready for review August 1, 2024 18:15
await route.fulfill({
body: JSON.stringify(projectGranuleProjectGranuleBody),
headers: {
...commonGranulesHeaders,
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
...commonGranulesHeaders,
...commonGranulesHeaders,
'access-control-expose-headers': 'cmr-hits',

I'm surprised we didn't need this here I think we should just add 'access-control-expose-headers': 'cmr-hits',
to the commonGranulesHeaders file then you don't have ot append it each call

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm not sure either come to think of it, because this part of the conditional is definitely getting called. It may have been unnecessary in some of the tests but I just went through and added it to all of them (though I seemingly missed this one)

}

route.fulfill({
body: JSON.stringify(temporalTimelineBody),
Copy link
Contributor

Choose a reason for hiding this comment

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

Just in general the reason you have to use Stringify alot here can be worked around by doing a

Suggested change
body: JSON.stringify(temporalTimelineBody),
json: temporalTimelineBody

Copy link
Contributor

@eudoroolivares2016 eudoroolivares2016 left a comment

Choose a reason for hiding this comment

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

Went through all the tests looks like it was covering the same stuff minor fixes I think will reduce some unnecessary calls

Copy link
Collaborator

@trevorlang trevorlang left a comment

Choose a reason for hiding this comment

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

I found a good bit of formatting inconsistencies that we should clean up but nothing major. I am a little confused how we ended up with 100k+ mocks in this PR if all we were doing is converting an already existing test. Maybe we can sync up tomorrow and you can fill me in on that.

Copy link
Collaborator

Choose a reason for hiding this comment

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

All files should end with a new line. It might be worth spending a few minutes exploring if we could enforce this with an eslint config or another linting tool.

Copy link
Collaborator

Choose a reason for hiding this comment

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

File should end with a new line

Copy link
Collaborator

Choose a reason for hiding this comment

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

File should end with a newline

Copy link
Collaborator

Choose a reason for hiding this comment

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

File should end in a new line

Copy link
Collaborator

Choose a reason for hiding this comment

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

File should end in a new line

Copy link
Collaborator

Choose a reason for hiding this comment

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

Looks like tabs not spaces

Copy link
Collaborator

Choose a reason for hiding this comment

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

Using tabs instead of spaces

Copy link
Collaborator

Choose a reason for hiding this comment

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

New line at end

await page.route('**/search/granules/timeline', (route) => {
const request = route.request()
const body = request.postData()
if (body) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

It seems kind of odd to have an if block in a test. I see this in a few spots. Why would body not exist when running this test?

Copy link
Member Author

@dpesall dpesall Aug 5, 2024

Choose a reason for hiding this comment

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

I wondered the same thing, but this was the functionality in the previous test file I converted it from. I did console log both parts of the conditional in a few of these tests to see if they were both getting hit.

await page.route('**/search/granules.json', (route) => {
const request = route.request()
const body = request.postData()
expect(body).toBe('browse_only=true&echo_collection_id=C1214470488-ASF&page_num=1&page_size=20')
Copy link
Collaborator

Choose a reason for hiding this comment

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

We generally have new lines to separate blocks of variables, expect blocks, and function calls. There are lots of occurrences of this in this file. Make sure all the spacing is consistent please :)

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed

@dpesall
Copy link
Member Author

dpesall commented Aug 5, 2024

I found a good bit of formatting inconsistencies that we should clean up but nothing major. I am a little confused how we ended up with 100k+ mocks in this PR if all we were doing is converting an already existing test. Maybe we can sync up tomorrow and you can fill me in on that.

Happy to tag up tomorrow on this. I didn't create any new mocks for this test rewrite, I only reused the ones being utilized by the cypress test file. I'll definite work out all the spacing inconsistencies in the json files. Unless they somehow got changed by moving directories, they've been like that the whole time, so I'll go through and make sure they are all conforming.

@dpesall
Copy link
Member Author

dpesall commented Aug 6, 2024

Added newlines to the end of all the files, and changed the spacing to be consistent across all files.

@dpesall dpesall requested a review from trevorlang August 6, 2024 23:03
@dpesall dpesall merged commit 7d01ab5 into main Aug 8, 2024
12 checks passed
@dpesall dpesall deleted the EDSC-4151 branch August 8, 2024 14:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants