Skip to content

Conversation

@jpuzz0
Copy link
Contributor

@jpuzz0 jpuzz0 commented Mar 11, 2022

What: Closes #7045

@jpuzz0 jpuzz0 force-pushed the chore/rtl-migrate-bundle-5 branch from 6e2245c to ded9924 Compare March 11, 2022 18:47
@patternfly-build
Copy link
Collaborator

patternfly-build commented Mar 11, 2022

@jpuzz0 jpuzz0 force-pushed the chore/rtl-migrate-bundle-5 branch 2 times, most recently from 38e9f91 to 7730ad0 Compare March 30, 2022 17:31
@thatblindgeye thatblindgeye self-requested a review April 6, 2022 18:30
@jpuzz0 jpuzz0 force-pushed the chore/rtl-migrate-bundle-5 branch from 7730ad0 to 528aaca Compare April 8, 2022 19:12
@wise-king-sullyman wise-king-sullyman self-requested a review April 11, 2022 14:07
Copy link
Contributor

@thatblindgeye thatblindgeye left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There were some tests that looked like they could be place into their own test file (the SimpleListGroup and SimpleListItem tests at the end of the SimpleList test file, most of the tests in the ToggleGroup test file). I didn't comment on them specifically since those are things that I figured would be part of the next phase.

Below are mainly nitpicks or asking for clarification.

<Pagination
itemCount={40}
toggleTemplate={'${firstIndex} - ${lastIndex} - ${itemCount} - ${itemsTitle}'}
data-testid="test-id"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a blocker for me, but I'm curious why you added this test id here as it doesn't look like it's getting used?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just leftover from when I wasn't using asFragment.

render(<Radio id="check" {...props} aria-label="check" name="check" />);

userEvent.click(screen.getByRole('radio'));
expect(props.onChange).toHaveBeenCalled();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is no longer testing the same thing as it previously did, I understand that we're no longer simulating a change event in the same way, but it should still be getting called with the same arguments right?

describe('Switch', () => {
test('switch label for attribute equals input id attribute', () => {
render(<Switch id="foo" aria-label="Switch label" />);
expect(screen.getByLabelText('Switch label')).toHaveAttribute('id', 'foo');
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is quite testing the same thing anymore, since based on the test name I believe that the purpose of this test was ensuring that the htmlFor prop was correctly applied.

render(<TextAreaBase {...props} aria-label="test textarea" />);

userEvent.type(screen.getByLabelText('test textarea'), 'new test textarea');
expect(props.onChange).toHaveBeenCalled();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As in Radio I don't think this is testing the same thing as it previously did, as it's no longer asserting anything about the arguments being passed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated this and the other tests mentioned to better reflect what was previously tested.

expect(view.container).toMatchSnapshot();
});
userEvent.type(screen.getByLabelText('test input'), 'new test input');
expect(props.onChange).toHaveBeenCalled();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Per previous comments I don't think this is still testing the same thing.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, it won't test the same thing regardless because of the difference in changing the inputs between the 2 tests. The onChange for instance is called for every character. I will update to something more inline with the original though.

);

userEvent.click(screen.getByRole('button'));
expect(props.onChange).toHaveBeenCalled();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test is no longer testing arguments being passed here as well.

Copy link
Collaborator

@wise-king-sullyman wise-king-sullyman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🥳

@wise-king-sullyman wise-king-sullyman merged commit 425f3e0 into patternfly:main Apr 13, 2022
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.

Migrate tests to RTL (5)

5 participants