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

115 photo input testing #271

Open
wants to merge 6 commits into
base: improv/types
Choose a base branch
from

Conversation

lindsayJohnstonPnnl
Copy link
Collaborator

This is a Jest test for the PhotoInput component

@lindsayJohnstonPnnl lindsayJohnstonPnnl changed the base branch from main to improv/types February 27, 2025 20:31
@@ -193,6 +195,7 @@ const PhotoInput: React.FC<PhotoInputProps> = ({
<Button
variant="danger"
className="photo-delete-button"
data-testid="photo-delete-button"
Copy link
Collaborator

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?

Copy link
Collaborator Author

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"
Copy link
Collaborator

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"
Copy link
Collaborator

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?

@lindsayJohnstonPnnl lindsayJohnstonPnnl linked an issue Mar 6, 2025 that may be closed by this pull request
Copy link
Collaborator

@markborkum markborkum left a 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.

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.

Component testing
2 participants