-
Notifications
You must be signed in to change notification settings - Fork 8
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
Cypress Tests events API for get-experience page #329
Cypress Tests events API for get-experience page #329
Conversation
@@ -65,6 +65,45 @@ describe( 'Start Setup WP Experience Page', function () { | |||
} ); | |||
} ); | |||
|
|||
const EventsAPI = ( experience_val ) => { | |||
cy.intercept('http://localhost:8882/index.php?rest_route=%2Fnewfold-onboarding%2Fv1%2Fevents%2Fbatch&flow=wp-setup&_locale=user').as('events'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we move this URL into a common constant? Additionally, could we consider using a regex that matches events/batch
instead of the entire URL? https://docs.cypress.io/api/commands/intercept#Icon-nameangle-right--url-String-Glob-RegExp
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, for now I have moved all the API in a single file. I'll do the regex that matches the URL also.
tests/cypress/integration/2-general-onboarding-flow/get-started-experience.cy.js
Outdated
Show resolved
Hide resolved
const responseData1 = responseBody[0].data; | ||
const responseData2 = responseBody[1].data; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the difference between responseData1
and responseData2
? Do we require both of them?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is needed for the edge case, sometimes the experience _level comes into the second data and sometimes in the first. I've refined it more now so that, it doesn't fail. 90% of the time it'll come in the resposeData1.
const className = '.components-radio-control__option'; | ||
const arr = cy.get( className ); | ||
arr.each( () => { | ||
cy.reload(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to reload
the page every time we click a radio button? That's not in line with how the user will be clicking the buttons.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this'll be needed to clear the older network logs as every time when a radio button is clicked, the API call is overlapped on the earlier one (happening only on cypress). So, to eliminate this, we have to use reload before every radio button click.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed reload.
Added Cypress Tests for events API on get-started-experience step for different API calls being made at the time of different options selected based on experience level.