-
Notifications
You must be signed in to change notification settings - Fork 0
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
193 Mock Test Auth & 2 tests from 192 #197
Conversation
Co-authored-by: Alisha Evans <[email protected]>
…ebstore into 193-mock-auth-tests
cypress/e2e/requests.cy.js
Outdated
cy.log("Successfully logged in and viewing requests page"); | ||
}); | ||
}) | ||
}); |
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.
now that the wcl has been updated to display text when we have no requests, can that test be added too?
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.
i was going to do that in a separate PR because i needed to figure out how and it was going to take a while. Since the e2e tests look at the db itself and use the real backend, and I already have requests, i also will not be able to check if a test like that is working.
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.
nvm, went ahead and included a check for this, but this is just checking that either of these elements exist when the user is signed in vs. saying that it needs to know whether or not a user has requests on their request list or not.
i think if we wanted to do the latter we would need to test the data itself, which isn't done with cypress out of the box but theres an add on called cypress-react-selector
where we could potentially be able to do something like this.
heres an example of how it could be used: https://glebbahmutov.com/blog/react-state-from-e2e-tests/
but this is more in depth and should probably be a separate ticket
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.
is mock data not an option?
the current implementation is ok for now, but it should be expanded in the future. although the tests says it's checking for the existence of requests or a "no requests" message....it isn't. since we don't have a use case where tests exist, the "no requests" route is the only one that will ever return true.
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.
there is a way with cypress fixtures
- if we did that and only wanted to use mock data, we would need to mock every single api call- this is an example of that: https://blog.bitsrc.io/mocking-http-calls-in-cypress-end-to-end-tests-fa2e6b7caaf7
it can be done but it isn't really in the scope of this ticket
cypress/e2e/requests.cy.js
Outdated
cy.log("Successfully logged in and viewing requests page"); | ||
}); | ||
}) | ||
}); |
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.
is mock data not an option?
the current implementation is ok for now, but it should be expanded in the future. although the tests says it's checking for the existence of requests or a "no requests" message....it isn't. since we don't have a use case where tests exist, the "no requests" route is the only one that will ever return true.
const requestListExists = cy.get('article.request-item').should('exist') || | ||
cy.get('p.no-requests').contains('You do not have any requests yet.') |
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.
ref: #197 (comment)
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.
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.
there is a way with cypress fixtures - if we did that and only wanted to use mock data, we would need to mock every single api call- this is an example of that: https://blog.bitsrc.io/mocking-http-calls-in-cypress-end-to-end-tests-fa2e6b7caaf7
it can be done but it isn't really in the scope of this ticket
Co-authored-by: Alisha Evans <[email protected]>
Summary
cypress-dotenv
plugin to be able to use environment variables from env.local fileRelated
Closes #193 e2e testing: setup reusable mock login/session for test environment#193
completes 2/3 tests on #192
Acceptance Criteria
Resources
nextauthjs/next-auth#2053 (comment)