Skip to content

Commit

Permalink
[Chore] Remove third-party testing internals from test snapshots (#19…
Browse files Browse the repository at this point in the history
…2747)

## Summary

This removes some indavertent testing of third-party
APIs/implementations caused by directly passing the result of a
`render()` call to `toMatchSnapshot()`.

In all cases, this was solved by passing `render().container` (the root
element rendered by the testing library) instead.

These changes remove implementation details of both styled-components
(#192368 being the reason for this commit) and testing-library from the
snapshots.


### Checklist


- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
  • Loading branch information
rylnd authored Sep 13, 2024
1 parent 48de1a5 commit 4efcc28
Show file tree
Hide file tree
Showing 34 changed files with 2,189 additions and 9,364 deletions.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ describe('FieldComponent', () => {
selectedField={getField('machine.os.raw')}
/>
);
expect(wrapper).toMatchSnapshot();
expect(wrapper.container).toMatchSnapshot();
const comboBox = wrapper.getByTestId('fieldAutocompleteComboBox');
const input = within(comboBox).getByRole('combobox');
expect(input).toHaveAttribute('value', 'machine.os.raw');
Expand All @@ -52,7 +52,7 @@ describe('FieldComponent', () => {
selectedField={getField('machine.os.raw')}
/>
);
expect(wrapper).toMatchSnapshot();
expect(wrapper.container).toMatchSnapshot();
expect(wrapper.getByTestId('fieldAutocompleteComboBox').querySelector('input')).toBeDisabled();
});
it('should render the loading spinner if isLoading is true when clicked', () => {
Expand All @@ -72,7 +72,7 @@ describe('FieldComponent', () => {
/>
);
const fieldAutocompleteComboBox = wrapper.getByTestId('fieldAutocompleteComboBox');
expect(wrapper).toMatchSnapshot();
expect(wrapper.container).toMatchSnapshot();
fireEvent.click(fieldAutocompleteComboBox);
expect(wrapper.getByRole('progressbar')).toBeInTheDocument();
});
Expand All @@ -92,7 +92,7 @@ describe('FieldComponent', () => {
selectedField={getField('machine.os.raw')}
/>
);
expect(wrapper).toMatchSnapshot();
expect(wrapper.container).toMatchSnapshot();
expect(wrapper.getByTestId('comboBoxClearButton')).toBeInTheDocument();
});
it('should change the selected value', async () => {
Expand Down
Loading

0 comments on commit 4efcc28

Please sign in to comment.