-
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
115 photo input testing #271
base: improv/types
Are you sure you want to change the base?
Conversation
@@ -193,6 +195,7 @@ const PhotoInput: React.FC<PhotoInputProps> = ({ | |||
<Button | |||
variant="danger" | |||
className="photo-delete-button" | |||
data-testid="photo-delete-button" |
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.
Instead of adding the data-testid
prop, could you find this element with a CSS selector, e.g., button.photo-delete-button
?
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.
@markborkum I just pushed a change that accomplishes this. I'm not a pro at Jest, but it seems like using querySelector forces the test to be a little more lengthy. ChatGPT is telling me that error handling is baked into the getByTestId
method. If you like this solution better, I will do this for the tests and remove the data-testid attributes.
@@ -147,6 +148,7 @@ const PhotoInput: React.FC<PhotoInputProps> = ({ | |||
</Collapsible> | |||
<input | |||
ref={ref} | |||
data-testid="photo-input" |
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.
Instead of adding the data-testid
prop, could you find this element with a CSS selector, e.g., button.btn.btn-outline-primary
?
@@ -125,6 +125,7 @@ const PhotoInput: React.FC<PhotoInputProps> = ({ | |||
</Button> | |||
<Button | |||
variant="danger" | |||
data-testid="permanently-delete-button" |
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.
Instead of adding the data-testid
prop, could you find this element with a CSS selector, e.g., button.btn-danger
?
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.
Looks good to me. Thanks, @lindsayJohnstonPnnl.
This is a Jest test for the PhotoInput component