Skip to content

Commit

Permalink
KOGITO-9474: [SWF Dev UI] Enzyme to RTL migration
Browse files Browse the repository at this point in the history
  • Loading branch information
Sara4994 committed Jul 25, 2023
1 parent 5acc68c commit 1367687
Show file tree
Hide file tree
Showing 21 changed files with 10,985 additions and 4,702 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
const enzyme = require('enzyme');
const Adapter = require('@wojtekmaj/enzyme-adapter-react-17');
const { TextDecoder } = require('util');

global.TextDecoder = TextDecoder;
enzyme.configure({ adapter: new Adapter() });
8 changes: 1 addition & 7 deletions ui-packages/packages/components-common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,14 @@
"@babel/core": "^7.22.8",
"@kogito-apps/ouia-tools": "workspace:*",
"@testing-library/jest-dom": "^5.16.5",
"@types/enzyme": "^3.10.13",
"@testing-library/react": "^11.2.6",
"@types/jest": "^26.0.24",
"@types/json-schema": "7.0.7",
"@types/react": "17.0.5",
"@types/react-dom": "^17.0.20",
"@wojtekmaj/enzyme-adapter-react-17": "^0.8.0",
"babel-jest": "^25.5.1",
"babel-loader": "^8.3.0",
"copyfiles": "^2.4.1",
"enzyme": "^3.11.0",
"enzyme-to-json": "^3.6.2",
"identity-obj-proxy": "^3.0.0",
"jest": "^26.6.3",
"jest-junit": "^14.0.1",
Expand Down Expand Up @@ -90,9 +87,6 @@
}
]
],
"snapshotSerializers": [
"enzyme-to-json/serializer"
],
"transformIgnorePatterns": [],
"transform": {
"^.+\\.jsx?$": "./config/Jest-config/babel-jest-wrapper.js",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
* limitations under the License.
*/
import React from 'react';
import { shallow } from 'enzyme';
import EndpointLink from '../EndpointLink';
import { render, screen } from '@testing-library/react';
import { EndpointLink } from '../EndpointLink';

const props1 = {
serviceUrl: 'http://localhost:4000/',
Expand Down Expand Up @@ -43,19 +43,19 @@ const props4 = {
};
describe('EndpointLink component tests', () => {
it('snapshot testing for link shown', () => {
const wrapper = shallow(<EndpointLink {...props1} />);
expect(wrapper).toMatchSnapshot();
render(<EndpointLink {...props1} />);
expect(screen).toMatchSnapshot();
});
it('snapshot testing for link hidden', () => {
const wrapper = shallow(<EndpointLink {...props2} />);
expect(wrapper).toMatchSnapshot();
render(<EndpointLink {...props2} />);
expect(screen).toMatchSnapshot();
});
it('snapshot testing for link hidden with custom link label', () => {
const wrapper = shallow(<EndpointLink {...props3} />);
expect(wrapper).toMatchSnapshot();
render(<EndpointLink {...props3} />);
expect(screen).toMatchSnapshot();
});
it('snapshot testing no service URL and link hidden', () => {
const wrapper = shallow(<EndpointLink {...props4} />);
expect(wrapper).toMatchSnapshot();
render(<EndpointLink {...props4} />);
expect(screen).toMatchSnapshot();
});
});
Original file line number Diff line number Diff line change
@@ -1,66 +1,221 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`EndpointLink component tests snapshot testing for link hidden 1`] = `
<Button
component="a"
data-ouia-component-id="endpoint-link-2"
data-ouia-component-type="endpoint-link"
data-ouia-safe={true}
href="http://localhost:4000/"
isInline={true}
target="_blank"
variant="link"
>
Endpoint
<ExternalLinkAltIcon
className="pf-u-ml-xs"
color="currentColor"
noVerticalAlign={false}
size="sm"
/>
</Button>
Object {
"debug": [Function],
"findAllByAltText": [Function],
"findAllByDisplayValue": [Function],
"findAllByLabelText": [Function],
"findAllByPlaceholderText": [Function],
"findAllByRole": [Function],
"findAllByTestId": [Function],
"findAllByText": [Function],
"findAllByTitle": [Function],
"findByAltText": [Function],
"findByDisplayValue": [Function],
"findByLabelText": [Function],
"findByPlaceholderText": [Function],
"findByRole": [Function],
"findByTestId": [Function],
"findByText": [Function],
"findByTitle": [Function],
"getAllByAltText": [Function],
"getAllByDisplayValue": [Function],
"getAllByLabelText": [Function],
"getAllByPlaceholderText": [Function],
"getAllByRole": [Function],
"getAllByTestId": [Function],
"getAllByText": [Function],
"getAllByTitle": [Function],
"getByAltText": [Function],
"getByDisplayValue": [Function],
"getByLabelText": [Function],
"getByPlaceholderText": [Function],
"getByRole": [Function],
"getByTestId": [Function],
"getByText": [Function],
"getByTitle": [Function],
"logTestingPlaygroundURL": [Function],
"queryAllByAltText": [Function],
"queryAllByDisplayValue": [Function],
"queryAllByLabelText": [Function],
"queryAllByPlaceholderText": [Function],
"queryAllByRole": [Function],
"queryAllByTestId": [Function],
"queryAllByText": [Function],
"queryAllByTitle": [Function],
"queryByAltText": [Function],
"queryByDisplayValue": [Function],
"queryByLabelText": [Function],
"queryByPlaceholderText": [Function],
"queryByRole": [Function],
"queryByTestId": [Function],
"queryByText": [Function],
"queryByTitle": [Function],
}
`;

exports[`EndpointLink component tests snapshot testing for link hidden with custom link label 1`] = `
<Button
component="a"
data-ouia-component-id="endpoint-link-3"
data-ouia-component-type="endpoint-link"
data-ouia-safe={true}
href="http://localhost:4000/"
isInline={true}
target="_blank"
variant="link"
>
This is a label
<ExternalLinkAltIcon
className="pf-u-ml-xs"
color="currentColor"
noVerticalAlign={false}
size="sm"
/>
</Button>
Object {
"debug": [Function],
"findAllByAltText": [Function],
"findAllByDisplayValue": [Function],
"findAllByLabelText": [Function],
"findAllByPlaceholderText": [Function],
"findAllByRole": [Function],
"findAllByTestId": [Function],
"findAllByText": [Function],
"findAllByTitle": [Function],
"findByAltText": [Function],
"findByDisplayValue": [Function],
"findByLabelText": [Function],
"findByPlaceholderText": [Function],
"findByRole": [Function],
"findByTestId": [Function],
"findByText": [Function],
"findByTitle": [Function],
"getAllByAltText": [Function],
"getAllByDisplayValue": [Function],
"getAllByLabelText": [Function],
"getAllByPlaceholderText": [Function],
"getAllByRole": [Function],
"getAllByTestId": [Function],
"getAllByText": [Function],
"getAllByTitle": [Function],
"getByAltText": [Function],
"getByDisplayValue": [Function],
"getByLabelText": [Function],
"getByPlaceholderText": [Function],
"getByRole": [Function],
"getByTestId": [Function],
"getByText": [Function],
"getByTitle": [Function],
"logTestingPlaygroundURL": [Function],
"queryAllByAltText": [Function],
"queryAllByDisplayValue": [Function],
"queryAllByLabelText": [Function],
"queryAllByPlaceholderText": [Function],
"queryAllByRole": [Function],
"queryAllByTestId": [Function],
"queryAllByText": [Function],
"queryAllByTitle": [Function],
"queryByAltText": [Function],
"queryByDisplayValue": [Function],
"queryByLabelText": [Function],
"queryByPlaceholderText": [Function],
"queryByRole": [Function],
"queryByTestId": [Function],
"queryByText": [Function],
"queryByTitle": [Function],
}
`;

exports[`EndpointLink component tests snapshot testing for link shown 1`] = `
<Button
component="a"
data-ouia-component-id="endpoint-link-1"
data-ouia-component-type="endpoint-link"
data-ouia-safe={true}
href="http://localhost:4000/"
isInline={true}
target="_blank"
variant="link"
>
http://localhost:4000/
<ExternalLinkAltIcon
className="pf-u-ml-xs"
color="currentColor"
noVerticalAlign={false}
size="sm"
/>
</Button>
Object {
"debug": [Function],
"findAllByAltText": [Function],
"findAllByDisplayValue": [Function],
"findAllByLabelText": [Function],
"findAllByPlaceholderText": [Function],
"findAllByRole": [Function],
"findAllByTestId": [Function],
"findAllByText": [Function],
"findAllByTitle": [Function],
"findByAltText": [Function],
"findByDisplayValue": [Function],
"findByLabelText": [Function],
"findByPlaceholderText": [Function],
"findByRole": [Function],
"findByTestId": [Function],
"findByText": [Function],
"findByTitle": [Function],
"getAllByAltText": [Function],
"getAllByDisplayValue": [Function],
"getAllByLabelText": [Function],
"getAllByPlaceholderText": [Function],
"getAllByRole": [Function],
"getAllByTestId": [Function],
"getAllByText": [Function],
"getAllByTitle": [Function],
"getByAltText": [Function],
"getByDisplayValue": [Function],
"getByLabelText": [Function],
"getByPlaceholderText": [Function],
"getByRole": [Function],
"getByTestId": [Function],
"getByText": [Function],
"getByTitle": [Function],
"logTestingPlaygroundURL": [Function],
"queryAllByAltText": [Function],
"queryAllByDisplayValue": [Function],
"queryAllByLabelText": [Function],
"queryAllByPlaceholderText": [Function],
"queryAllByRole": [Function],
"queryAllByTestId": [Function],
"queryAllByText": [Function],
"queryAllByTitle": [Function],
"queryByAltText": [Function],
"queryByDisplayValue": [Function],
"queryByLabelText": [Function],
"queryByPlaceholderText": [Function],
"queryByRole": [Function],
"queryByTestId": [Function],
"queryByText": [Function],
"queryByTitle": [Function],
}
`;

exports[`EndpointLink component tests snapshot testing no service URL and link hidden 1`] = `<Fragment />`;
exports[`EndpointLink component tests snapshot testing no service URL and link hidden 1`] = `
Object {
"debug": [Function],
"findAllByAltText": [Function],
"findAllByDisplayValue": [Function],
"findAllByLabelText": [Function],
"findAllByPlaceholderText": [Function],
"findAllByRole": [Function],
"findAllByTestId": [Function],
"findAllByText": [Function],
"findAllByTitle": [Function],
"findByAltText": [Function],
"findByDisplayValue": [Function],
"findByLabelText": [Function],
"findByPlaceholderText": [Function],
"findByRole": [Function],
"findByTestId": [Function],
"findByText": [Function],
"findByTitle": [Function],
"getAllByAltText": [Function],
"getAllByDisplayValue": [Function],
"getAllByLabelText": [Function],
"getAllByPlaceholderText": [Function],
"getAllByRole": [Function],
"getAllByTestId": [Function],
"getAllByText": [Function],
"getAllByTitle": [Function],
"getByAltText": [Function],
"getByDisplayValue": [Function],
"getByLabelText": [Function],
"getByPlaceholderText": [Function],
"getByRole": [Function],
"getByTestId": [Function],
"getByText": [Function],
"getByTitle": [Function],
"logTestingPlaygroundURL": [Function],
"queryAllByAltText": [Function],
"queryAllByDisplayValue": [Function],
"queryAllByLabelText": [Function],
"queryAllByPlaceholderText": [Function],
"queryAllByRole": [Function],
"queryAllByTestId": [Function],
"queryAllByText": [Function],
"queryAllByTitle": [Function],
"queryByAltText": [Function],
"queryByDisplayValue": [Function],
"queryByLabelText": [Function],
"queryByPlaceholderText": [Function],
"queryByRole": [Function],
"queryByTestId": [Function],
"queryByText": [Function],
"queryByTitle": [Function],
}
`;
Loading

0 comments on commit 1367687

Please sign in to comment.