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

Bump @testing-library #128659

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -512,11 +512,11 @@
"@storybook/react": "^6.3.12",
"@storybook/testing-react": "^0.0.22",
"@storybook/theming": "^6.3.12",
"@testing-library/dom": "^7.30.3",
"@testing-library/jest-dom": "^5.11.10",
"@testing-library/react": "^11.2.6",
"@testing-library/react-hooks": "^5.1.1",
"@testing-library/user-event": "^13.1.1",
"@testing-library/dom": "^8.12.0",
"@testing-library/jest-dom": "^5.16.3",
"@testing-library/react": "^12.1.4",
"@testing-library/react-hooks": "^7.0.2",
"@testing-library/user-event": "^13.5.0",
"@types/apidoc": "^0.22.3",
"@types/archiver": "^5.1.0",
"@types/babel__core": "^7.1.19",
Expand Down Expand Up @@ -714,8 +714,7 @@
"@types/tar": "^4.0.5",
"@types/tar-fs": "^1.16.1",
"@types/tempy": "^0.2.0",
"@types/testing-library__jest-dom": "^5.9.5",
"@types/testing-library__react-hooks": "^4.0.0",
"@types/testing-library__jest-dom": "^5.14.3",
"@types/tinycolor2": "^1.4.1",
"@types/tough-cookie": "^4.0.1",
"@types/type-detect": "^4.0.1",
Expand Down Expand Up @@ -874,6 +873,7 @@
"postcss-loader": "^3.0.0",
"postcss-prefix-selector": "^1.7.2",
"prettier": "^2.6.1",
"pretty-format": "^27.5.1",
jbudz marked this conversation as resolved.
Show resolved Hide resolved
"q": "^1.5.1",
"react-test-renderer": "^16.12.0",
"read-pkg": "^5.2.0",
Expand Down
30 changes: 12 additions & 18 deletions packages/kbn-i18n-react/src/provider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
* Side Public License, v 1.
*/

import * as PropTypes from 'prop-types';
import * as React from 'react';
import React from 'react';

// eslint-disable-next-line @kbn/eslint/module_migration
import { IntlProvider } from 'react-intl';
Expand All @@ -20,20 +19,15 @@ import { PseudoLocaleWrapper } from './pseudo_locale_wrapper';
* of components. This component is used to setup the i18n context for a tree.
* IntlProvider should wrap react app's root component (inside each react render method).
*/
export class I18nProvider extends React.PureComponent {
public static propTypes = { children: PropTypes.element.isRequired };

public render() {
return (
<IntlProvider
locale={i18n.getLocale()}
messages={i18n.getTranslation().messages}
defaultLocale={i18n.getDefaultLocale()}
formats={i18n.getFormats()}
textComponent={React.Fragment}
>
<PseudoLocaleWrapper>{this.props.children}</PseudoLocaleWrapper>
</IntlProvider>
);
}
}
export const I18nProvider: React.FC = ({ children }) => (
<IntlProvider
locale={i18n.getLocale()}
messages={i18n.getTranslation().messages}
defaultLocale={i18n.getDefaultLocale()}
formats={i18n.getFormats()}
textComponent={React.Fragment}
>
<PseudoLocaleWrapper>{children}</PseudoLocaleWrapper>
</IntlProvider>
);
1 change: 0 additions & 1 deletion packages/kbn-securitysolution-list-hooks/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ TYPES_DEPS = [
"@npm//@types/jest",
"@npm//@types/node",
"@npm//@types/react",
"@npm//@types/testing-library__react-hooks",
"@npm//fp-ts",
"@npm//tslib",
]
Expand Down
15 changes: 15 additions & 0 deletions renovate.json
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,21 @@
"matchBaseBranches": ["main"],
"labels": ["Team:Operations", "release_note:skip"],
"enabled": true
},
{
"groupName": "@testing-library",
"packageNames": [
"@testing-library/dom",
"@testing-library/jest-dom",
"@testing-library/react",
"@testing-library/react-hooks",
"@testing-library/user-event",
"@types/testing-library__jest-dom"
],
"reviewers": ["team:kibana-operations"],
"matchBaseBranches": ["main"],
"labels": ["Team:Operations", "release_note:skip"],
"enabled": true
}
]
}
2 changes: 1 addition & 1 deletion x-pack/plugins/cases/public/common/mock/test_providers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export const createAppMockRenderer = ({
AppWrapper.displayName = 'AppWrapper';
const render: UiRender = (ui, options) => {
return reactRender(ui, {
wrapper: AppWrapper as React.ComponentType,
wrapper: AppWrapper,
...options,
});
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import { stringify } from 'query-string';
import {
render as reactTestLibRender,
RenderOptions,
Nullish,
MatcherFunction,
} from '@testing-library/react';
import { Route, Router } from 'react-router-dom';
Expand Down Expand Up @@ -167,7 +166,7 @@ export function MockKibanaProvider<ExtraCore extends Partial<CoreStart>>({
);
}

export function MockRouter<ExtraCore>({
export function MockRouter<ExtraCore extends Partial<CoreStart>>({
children,
core,
history = createMemoryHistory(),
Expand Down Expand Up @@ -385,7 +384,7 @@ export const mockDataView = createStubDataView({
export const forNearestButton =
(getByText: (f: MatcherFunction) => HTMLElement | null) =>
(text: string): HTMLElement | null =>
getByText((_content: string, node: Nullish<Element>) => {
getByText((_content: string, node: Element | null) => {
if (!node) return false;
const noOtherButtonHasText = Array.from(node.children).every(
(child) => child && (child.textContent !== text || child.tagName.toLowerCase() !== 'button')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,6 @@ describe('DraggableWrapper', () => {

await waitFor(() => {
wrapper.find('[data-test-subj="withHoverActionsButton"]').simulate('mouseenter');
wrapper.update();
jest.runAllTimers();
wrapper.update();
expect(wrapper.find('[data-test-subj="hover-actions-copy-button"]').exists()).toBe(true);
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ export const createAppRootMockRenderer = (): AppContextTestRender => {

const render: UiRender = (ui, options) => {
return reactRender(ui, {
wrapper: AppWrapper as React.ComponentType,
wrapper: AppWrapper,
...options,
});
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import React from 'react';
import { mount } from 'enzyme';
import { waitFor } from '@testing-library/react';

import { AddToFavoritesButton, NewTimeline, NewTimelineProps } from './helpers';
import { useCreateTimelineButton } from './use_create_timeline';
Expand Down Expand Up @@ -124,9 +125,10 @@ describe('Favorite Button', () => {
</TestProviders>
);

wrapper.simulate('click');

expect(spy).toHaveBeenCalled();
waitFor(() => {
wrapper.simulate('click');
expect(spy).toHaveBeenCalled();
Copy link
Contributor

Choose a reason for hiding this comment

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

shouldn't the expect be outside of waitFor() ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

});
});

test('should disable favorite button with filled star', () => {
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/session_view/public/test/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ export const createAppRootMockRenderer = (): AppContextTestRender => {

const render: UiRender = (ui, options = {}) => {
return reactRender(ui, {
wrapper: AppWrapper as React.ComponentType,
wrapper: AppWrapper,
...options,
});
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,8 @@ describe('MonitorTags component', () => {

it('expand tag show tags on click', () => {
summaryPing.state.summaryPings[0].tags = ['red', 'green', 'blue', 'black', 'purple', 'yellow'];
render(<MonitorTags ping={summaryPing.state.summaryPings[0]} />, { wrapper: MemoryRouter });
const Wrapper: React.FC = ({ children }) => <MemoryRouter>{children}</MemoryRouter>;
render(<MonitorTags ping={summaryPing.state.summaryPings[0]} />, { wrapper: Wrapper });

fireEvent.click(screen.getByText('+1'));

Expand Down
5 changes: 2 additions & 3 deletions x-pack/plugins/uptime/public/lib/helper/rtl_helpers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import {
render as reactTestLibRender,
MatcherFunction,
RenderOptions,
Nullish,
} from '@testing-library/react';
import { Router, Route } from 'react-router-dom';
import { merge } from 'lodash';
Expand Down Expand Up @@ -289,7 +288,7 @@ const forNearestTag =
(tag: string) =>
(getByText: (f: MatcherFunction) => HTMLElement | null) =>
(text: string): HTMLElement | null =>
getByText((_content: string, node: Nullish<Element>) => {
getByText((_content: string, node: Element | null) => {
if (!node) return false;
const noOtherButtonHasText = Array.from(node.children).every(
(child) => child && (child.textContent !== text || child.tagName.toLowerCase() !== tag)
Expand Down Expand Up @@ -345,7 +344,7 @@ const finderWithClassWrapper =
customAttribute?: keyof Element | keyof HTMLElement
) =>
(text: string): HTMLElement | null =>
getterFn((_content: string, node: Nullish<Element>) => {
getterFn((_content: string, node: Element | null) => {
if (!node) return false;
// There are actually properties that are not in Element but which
// appear on the `node`, so we must cast the customAttribute as a keyof Element
Expand Down
Loading