-
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
239 requests page tests #241
Conversation
cypress/e2e/requests.cy.js
Outdated
if ((requestList === undefined) && (loading === true)) { | ||
// reply with an empty response: both data and error will be undefined. | ||
req.reply() | ||
} else if ((requestList === undefined) && (loading === undefined) && (error === 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.
why does loading equal undefined instead of false?
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.
all these variables are doing are switching between the different intercept cases, so it could be either undefined or false, it wouldn't really matter as long as its not true. But, it does make it easier to read to be false so i just changed it
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.
ok.
yes, the test passes either way but I was thinking from the POV of someone who is unfamiliar with this code. just like we check the api specs to see how things work, someone may check these specs. so it's better, imo, to keep the tests in line with what the actual pages are demonstrating.
utils/api/configurations.js
Outdated
@@ -69,7 +69,7 @@ export const configureRequests = ({ data, path }) => { | |||
export const configureErrors = (errors) => { | |||
const env = process.env.NODE_ENV | |||
const remainingErrors = errors | |||
.filter(error => Object.keys(error).length) | |||
.filter(error => error && Object.keys(error).length) |
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.
.filter(error => error && Object.keys(error).length) | |
.filter(error => Object.keys(error).length) |
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.
we don't have to explicitly check for the truthiness of an error here because Object.keys
is handling it.
[{}, false, { a: 'a' }].filter(error => Object.keys(error).length)
=> Array [ { a: "a" } ]
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.
but what if the array ends up with an item that is undefined? like
[{}, false, { a: 'a' }, undefined]
That is what I was running into in the test that prompted me to change this. idk if its possible for this array of errors to contain one that is undefined, but it was happening in the test. so I figured adding a check there to make sure the error was not undefined was basically some TDD.
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.
when an error was undefined, Object.keys(error) was v angry
Co-authored-by: Alisha Evans <alisha@scientist.com>
Story
Checks that loading & error components render correctly on the requests page
Intercepts the make-a-request-ware request and checks that linkedbutton renders
Closes #239
Related:
Component Lib PR: https://github.com/scientist-softserv/webstore-component-library/pull/171/files
Expected Behavior Before Changes
Expected Behavior After Changes
Screenshots / Video