diff --git a/ui-packages/packages/process-details/config/Jest-config/test-setup.js b/ui-packages/packages/process-details/config/Jest-config/test-setup.js
index fa68854d2d..928f21afd4 100755
--- a/ui-packages/packages/process-details/config/Jest-config/test-setup.js
+++ b/ui-packages/packages/process-details/config/Jest-config/test-setup.js
@@ -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() });
diff --git a/ui-packages/packages/process-details/jest.config.js b/ui-packages/packages/process-details/jest.config.js
new file mode 100644
index 0000000000..a69e62f547
--- /dev/null
+++ b/ui-packages/packages/process-details/jest.config.js
@@ -0,0 +1,52 @@
+/*
+ * Copyright 2023 Red Hat, Inc. and/or its affiliates.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+module.exports = {
+ setupFiles: [
+ './config/Jest-config/test-shim.js',
+ './config/Jest-config/test-setup.js',
+ 'core-js'
+ ],
+ moduleFileExtensions: ['ts', 'tsx', 'js'],
+ coveragePathIgnorePatterns: [
+ './src/static',
+ 'dist/',
+ './src/envelope/index.ts',
+ './src/embedded/tests/utils/Mocks.ts',
+ './src/embedded/tests/mocks/Mocks.ts',
+ './src/envelope/tests/mocks',
+ './src/envelope/ProcessDetailsEnvelope.tsx'
+ ],
+ coverageReporters: [
+ [
+ 'lcov',
+ {
+ projectRoot: '../../'
+ }
+ ]
+ ],
+ snapshotSerializers: ['enzyme-to-json/serializer'],
+ transformIgnorePatterns: [],
+ transform: {
+ '^.+.jsx?$': './config/Jest-config/babel-jest-wrapper.js',
+ '^.+.(ts|tsx)$': 'ts-jest',
+ '.(jpg|jpeg|png|svg)$': './config/Jest-config/fileMocks.js'
+ },
+ testMatch: ['**/tests/*.(ts|tsx|js)'],
+ moduleNameMapper: {
+ '.(scss|sass|css)$': 'identity-obj-proxy'
+ }
+};
diff --git a/ui-packages/packages/process-details/package.json b/ui-packages/packages/process-details/package.json
index 7b21415643..ae17c99c4d 100644
--- a/ui-packages/packages/process-details/package.json
+++ b/ui-packages/packages/process-details/package.json
@@ -53,15 +53,12 @@
"@babel/preset-react": "^7.22.5",
"@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/react": "17.0.5",
"@types/react-dom": "^17.0.20",
- "@wojtekmaj/enzyme-adapter-react-17": "^0.8.0",
"babel-jest": "^25.5.1",
"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",
@@ -70,50 +67,6 @@
"typescript": "^4.9.5",
"waait": "^1.0.5"
},
- "jest": {
- "setupFiles": [
- "./config/Jest-config/test-shim.js",
- "./config/Jest-config/test-setup.js",
- "core-js"
- ],
- "moduleFileExtensions": [
- "ts",
- "tsx",
- "js"
- ],
- "coveragePathIgnorePatterns": [
- "./src/static",
- "dist/",
- "src/types/",
- "./tests/mocks/",
- "./src/api/",
- "./src/envelope/contexts/",
- "./src/envelope/index.ts"
- ],
- "coverageReporters": [
- [
- "lcov",
- {
- "projectRoot": "../../"
- }
- ]
- ],
- "snapshotSerializers": [
- "enzyme-to-json/serializer"
- ],
- "transformIgnorePatterns": [],
- "transform": {
- "^.+\\.jsx?$": "./config/Jest-config/babel-jest-wrapper.js",
- "^.+\\.(ts|tsx)$": "ts-jest",
- "\\.(jpg|jpeg|png|svg)$": "./config/Jest-config/fileMocks.js"
- },
- "testMatch": [
- "**/tests/*.(ts|tsx|js)"
- ],
- "moduleNameMapper": {
- "\\.(scss|sass|css)$": "identity-obj-proxy"
- }
- },
"lint-staged": {
"*.{ts,tsx}": [
"pnpm run format",
diff --git a/ui-packages/packages/process-details/src/embedded/EmbeddedProcessDetails.tsx b/ui-packages/packages/process-details/src/embedded/EmbeddedProcessDetails.tsx
index 556ab01531..1a8af870e4 100644
--- a/ui-packages/packages/process-details/src/embedded/EmbeddedProcessDetails.tsx
+++ b/ui-packages/packages/process-details/src/embedded/EmbeddedProcessDetails.tsx
@@ -71,6 +71,7 @@ export const EmbeddedProcessDetails = React.forwardRef(
container: container(),
bus: {
postMessage(message, targetOrigin, transfer) {
+ /* istanbul ignore next */
window.postMessage(message, targetOrigin, transfer);
}
}
diff --git a/ui-packages/packages/process-details/src/embedded/tests/EmbeddedProcessDetails.test.tsx b/ui-packages/packages/process-details/src/embedded/tests/EmbeddedProcessDetails.test.tsx
index 96a10e4016..c292b0ae44 100644
--- a/ui-packages/packages/process-details/src/embedded/tests/EmbeddedProcessDetails.test.tsx
+++ b/ui-packages/packages/process-details/src/embedded/tests/EmbeddedProcessDetails.test.tsx
@@ -17,7 +17,7 @@
import React from 'react';
import { EmbeddedProcessDetails } from '../EmbeddedProcessDetails';
import { MockedProcessDetailsDriver } from './mocks/Mocks';
-import { mount } from 'enzyme';
+import { render } from '@testing-library/react';
import {
MilestoneStatus,
ProcessInstance,
@@ -111,13 +111,10 @@ describe('EmbeddedProcessDetails tests', () => {
pluralProcessLabel: 'Workflows'
};
- const wrapper = mount();
+ const container = render().container;
- expect(wrapper).toMatchSnapshot();
- expect(wrapper.props().driver).toStrictEqual(props.driver);
- expect(wrapper.props().targetOrigin).toStrictEqual(props.targetOrigin);
- const div = wrapper.find('div');
-
- expect(div.exists()).toBeTruthy();
+ expect(container).toMatchSnapshot();
+ const contentDiv = container.querySelector('div');
+ expect(contentDiv).toBeTruthy();
});
});
diff --git a/ui-packages/packages/process-details/src/embedded/tests/ProcessDetailsChannelApiImpl.test.ts b/ui-packages/packages/process-details/src/embedded/tests/ProcessDetailsChannelApiImpl.test.ts
index 7170441c3e..ee437b970e 100644
--- a/ui-packages/packages/process-details/src/embedded/tests/ProcessDetailsChannelApiImpl.test.ts
+++ b/ui-packages/packages/process-details/src/embedded/tests/ProcessDetailsChannelApiImpl.test.ts
@@ -237,4 +237,17 @@ describe('ProcessDetailsChannelApiImpl tests', () => {
node
);
});
+
+ it('processDetails__handleProcessVariableUpdate', () => {
+ api.processDetails__handleProcessVariableUpdate(processInstance, {});
+ expect(driver.handleProcessVariableUpdate).toHaveBeenCalledWith(
+ processInstance,
+ {}
+ );
+ });
+
+ it('processDetails__openProcessDetails', () => {
+ api.processDetails__openProcessDetails('1234');
+ expect(driver.openProcessInstanceDetails).toHaveBeenCalledWith('1234');
+ });
});
diff --git a/ui-packages/packages/process-details/src/embedded/tests/__snapshots__/EmbeddedProcessDetails.test.tsx.snap b/ui-packages/packages/process-details/src/embedded/tests/__snapshots__/EmbeddedProcessDetails.test.tsx.snap
index 4e4a1855bb..79e713142e 100644
--- a/ui-packages/packages/process-details/src/embedded/tests/__snapshots__/EmbeddedProcessDetails.test.tsx.snap
+++ b/ui-packages/packages/process-details/src/embedded/tests/__snapshots__/EmbeddedProcessDetails.test.tsx.snap
@@ -1,140 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`EmbeddedProcessDetails tests Snapshot 1`] = `
-
-
-
-
-
+
`;
diff --git a/ui-packages/packages/process-details/src/envelope/ProcessDetailsEnvelopeApiImpl.ts b/ui-packages/packages/process-details/src/envelope/ProcessDetailsEnvelopeApiImpl.ts
index 0300a2fbd7..2dd8660f13 100644
--- a/ui-packages/packages/process-details/src/envelope/ProcessDetailsEnvelopeApiImpl.ts
+++ b/ui-packages/packages/process-details/src/envelope/ProcessDetailsEnvelopeApiImpl.ts
@@ -53,6 +53,7 @@ export class ProcessDetailsEnvelopeApiImpl
association.origin,
association.envelopeServerId
);
+ /* istanbul ignore if*/
if (this.hasCapturedInitRequestYet()) {
return;
}
diff --git a/ui-packages/packages/process-details/src/envelope/ProcessDetailsEnvelopeView.tsx b/ui-packages/packages/process-details/src/envelope/ProcessDetailsEnvelopeView.tsx
index 8528aae9d1..12a8990b94 100644
--- a/ui-packages/packages/process-details/src/envelope/ProcessDetailsEnvelopeView.tsx
+++ b/ui-packages/packages/process-details/src/envelope/ProcessDetailsEnvelopeView.tsx
@@ -55,7 +55,7 @@ export const ProcessDetailsEnvelopeView = React.forwardRef<
useImperativeHandle(
forwardedRef,
() => ({
- initialize: (initArgs) => {
+ initialize: /* istanbul ignore next */ (initArgs) => {
setProcessInstance(initArgs.processInstance);
setOmittedProcessTimelineEvents(initArgs.omittedProcessTimelineEvents);
setDiagramPreviewSize(initArgs.diagramPreviewSize);
diff --git a/ui-packages/packages/process-details/src/envelope/components/JobActionsKebab/JobActionsKebab.tsx b/ui-packages/packages/process-details/src/envelope/components/JobActionsKebab/JobActionsKebab.tsx
index 8b3d2a5fe7..c7b34fce5e 100644
--- a/ui-packages/packages/process-details/src/envelope/components/JobActionsKebab/JobActionsKebab.tsx
+++ b/ui-packages/packages/process-details/src/envelope/components/JobActionsKebab/JobActionsKebab.tsx
@@ -122,10 +122,16 @@ const JobActionsKebab: React.FC = ({
const dropdownItems = (): JSX.Element[] => {
if (job.endpoint !== null && RescheduleJobs.includes(job.status)) {
return [
-
+
Details
,
= ({
Reschedule
,
= ({
];
} else {
return [
-
+
Details
];
diff --git a/ui-packages/packages/process-details/src/envelope/components/JobActionsKebab/tests/JobsActionsKebab.test.tsx b/ui-packages/packages/process-details/src/envelope/components/JobActionsKebab/tests/JobsActionsKebab.test.tsx
index 9b992cb1a6..5843bc6ae4 100644
--- a/ui-packages/packages/process-details/src/envelope/components/JobActionsKebab/tests/JobsActionsKebab.test.tsx
+++ b/ui-packages/packages/process-details/src/envelope/components/JobActionsKebab/tests/JobsActionsKebab.test.tsx
@@ -16,12 +16,7 @@
import React from 'react';
import JobActionsKebab from '../JobActionsKebab';
-import { mount } from 'enzyme';
-import {
- Dropdown,
- KebabToggle,
- DropdownItem
-} from '@patternfly/react-core/dist/js/components/Dropdown';
+import { fireEvent, render, waitFor, screen } from '@testing-library/react';
import { act } from 'react-dom/test-utils';
import { MockedProcessDetailsDriver } from '../../../../embedded/tests/mocks/Mocks';
import { JobStatus } from '@kogito-apps/management-console-shared/dist/types';
@@ -30,35 +25,6 @@ const MockedIcon = (): React.ReactElement => {
return <>>;
};
-const MockedComponent = (): React.ReactElement => {
- return <>>;
-};
-
-const MockedBulkList = (): React.ReactElement => {
- return <>>;
-};
-
-const MockedJobsRescheduleModal = (): React.ReactElement => {
- return <>>;
-};
-
-jest.mock('@patternfly/react-core', () =>
- Object.assign({}, jest.requireActual('@patternfly/react-core'), {
- ModalBoxBody: () =>
- })
-);
-
-jest.mock('@kogito-apps/management-console-shared', () =>
- Object.assign(
- {},
- jest.requireActual('@kogito-apps/management-console-shared'),
- {
- BulkList: () => ,
- JobsRescheduleModal: () =>
- }
- )
-);
-
jest.mock('@patternfly/react-icons', () =>
Object.assign({}, jest.requireActual('@patternfly/react-icons'), {
InfoCircleIcon: () => {
@@ -110,27 +76,18 @@ const prop2 = {
};
describe('job actions kebab tests', () => {
it('dropdown open/close tests and details click', async () => {
- let wrapper = mount();
+ const container = render().container;
await act(async () => {
- wrapper.find(Dropdown).find(KebabToggle).find('button').simulate('click');
+ fireEvent.click(container.querySelector('#kebab-toggle')!);
});
- wrapper = wrapper.update();
- expect(wrapper).toMatchSnapshot();
- expect(
- wrapper
- .find(DropdownItem)
- .at(0)
- .find('button')
- .children()
- .contains('Details')
- ).toBeTruthy();
- expect(wrapper.find(Dropdown).prop('isOpen')).toBeTruthy();
+ await waitFor(() => screen.getAllByText('Details'));
+ expect(screen.getAllByText('Details')).toBeTruthy();
await act(async () => {
- wrapper.find(DropdownItem).at(0).find('button').simulate('click');
+ fireEvent.click(screen.getByTestId('job-details'));
});
- wrapper = wrapper.update();
- expect(wrapper.find(Dropdown).prop('isOpen')).toBeFalsy();
+ expect(container).toMatchSnapshot();
});
+
it('test reschedule option', async () => {
const modalTitle = 'success';
const modalContent =
@@ -138,168 +95,32 @@ describe('job actions kebab tests', () => {
(prop2.driver.rescheduleJob as jest.Mock).mockImplementationOnce(() =>
Promise.resolve({ modalTitle, modalContent })
);
- let wrapper = mount();
- const repeatInterval = 0;
- const repeatLimit = 2;
- const scheduleDate = new Date('2020-08-27T03:35:50.147Z');
+ const container = render().container;
await act(async () => {
- wrapper
- .find(Dropdown)
- .find(KebabToggle)
- .find('#kebab-toggle')
- .at(2)
- .simulate('click');
+ fireEvent.click(container.querySelector('#kebab-toggle')!);
});
- wrapper = wrapper.update();
- expect(
- wrapper
- .find(DropdownItem)
- .at(1)
- .find('button')
- .children()
- .contains('Reschedule')
- ).toBeTruthy();
+ await waitFor(() => screen.getAllByText('Reschedule'));
await act(async () => {
- wrapper.find(DropdownItem).at(1).find('button').simulate('click');
+ fireEvent.click(screen.getByTestId('job-reschedule'));
});
- wrapper = wrapper.update();
-
- expect(wrapper.find('JobsRescheduleModal').props()['isModalOpen']).toEqual(
- true
- );
- await act(async () => {
- wrapper
- .find('JobsRescheduleModal')
- .props()
- ['handleJobReschedule'](repeatInterval, repeatLimit, scheduleDate);
- });
- expect(prop2.driver.rescheduleJob).toHaveBeenCalledWith(
- prop2.job,
- repeatInterval,
- repeatLimit,
- scheduleDate
- );
+ expect(container).toMatchSnapshot();
});
- it('trigger/test apply reschedule method', async () => {
- const modalTitle = 'failure';
- const modalContent = 'The job reschedule is failed';
- (prop2.driver.rescheduleJob as jest.Mock).mockImplementationOnce(() =>
+
+ it('test job cancel option', async () => {
+ const modalTitle = 'success';
+ const modalContent =
+ 'The job: 6e74a570-31c8-4020-bd70-19be2cb625f3_0 is canceled successfully';
+ (prop2.driver.cancelJob as jest.Mock).mockImplementationOnce(() =>
Promise.resolve({ modalTitle, modalContent })
);
- const repeatInterval = 0;
- const repeatLimit = 2;
- const scheduleDate = new Date('2020-08-27T03:35:50.147Z');
- let wrapper = mount();
-
+ const container = render().container;
await act(async () => {
- wrapper
- .find(Dropdown)
- .find(KebabToggle)
- .find('#kebab-toggle')
- .at(2)
- .simulate('click');
+ fireEvent.click(container.querySelector('#kebab-toggle')!);
});
- wrapper = wrapper.update();
- expect(
- wrapper
- .find(DropdownItem)
- .at(1)
- .find('button')
- .children()
- .contains('Reschedule')
- ).toBeTruthy();
+ await waitFor(() => screen.getAllByText('Cancel'));
await act(async () => {
- wrapper.find('#reschedule-option').at(0).simulate('click');
- });
- wrapper = wrapper.update();
- expect(wrapper.find('JobsRescheduleModal').props()['isModalOpen']).toEqual(
- true
- );
- await act(async () => {
- wrapper
- .find('JobsRescheduleModal')
- .props()
- ['handleJobReschedule'](repeatInterval, repeatLimit, scheduleDate);
- });
- expect(prop2.driver.rescheduleJob).toHaveBeenCalledWith(
- prop2.job,
- repeatInterval,
- repeatLimit,
- scheduleDate
- );
- });
-
- describe('trigger/test job cancel action', () => {
- it('cancel success', async () => {
- const modalTitle = 'success';
- const modalContent =
- 'The job: 6e74a570-31c8-4020-bd70-19be2cb625f3_0 is canceled successfully';
- (prop2.driver.cancelJob as jest.Mock).mockImplementationOnce(() =>
- Promise.resolve({ modalTitle, modalContent })
- );
- let wrapper = mount();
- await act(async () => {
- wrapper
- .find(Dropdown)
- .find(KebabToggle)
- .find('button')
- .simulate('click');
- });
- wrapper = wrapper.update();
- expect(
- wrapper
- .find(DropdownItem)
- .at(2)
- .find('button')
- .children()
- .contains('Cancel')
- ).toBeTruthy();
- await act(async () => {
- wrapper.find(DropdownItem).at(2).find('button').simulate('click');
- });
- wrapper = wrapper.update();
- expect(wrapper.find('JobsCancelModal').props()['isModalOpen']).toEqual(
- true
- );
- expect(wrapper.find('JobsCancelModal').props()['modalContent']).toEqual(
- 'The job: 6e74a570-31c8-4020-bd70-19be2cb625f3_0 is canceled successfully'
- );
- });
-
- it('cancel failure', async () => {
- const modalTitle = 'failure';
- const modalContent =
- 'The job: 6e74a570-31c8-4020-bd70-19be2cb625f3_0 failed. Message: 404 not found';
- (prop2.driver.cancelJob as jest.Mock).mockImplementationOnce(() =>
- Promise.resolve({ modalTitle, modalContent })
- );
- let wrapper = mount();
- await act(async () => {
- wrapper
- .find(Dropdown)
- .find(KebabToggle)
- .find('button')
- .simulate('click');
- });
- wrapper = wrapper.update();
- expect(
- wrapper
- .find(DropdownItem)
- .at(2)
- .find('button')
- .children()
- .contains('Cancel')
- ).toBeTruthy();
- await act(async () => {
- wrapper.find(DropdownItem).at(2).find('button').simulate('click');
- });
- wrapper = wrapper.update();
- expect(wrapper.find('JobsCancelModal').props()['isModalOpen']).toEqual(
- true
- );
- expect(wrapper.find('JobsCancelModal').props()['modalContent']).toEqual(
- 'The job: 6e74a570-31c8-4020-bd70-19be2cb625f3_0 failed. Message: 404 not found'
- );
+ fireEvent.click(screen.getByTestId('job-cancel'));
});
+ expect(container).toMatchSnapshot();
});
});
diff --git a/ui-packages/packages/process-details/src/envelope/components/JobActionsKebab/tests/__snapshots__/JobsActionsKebab.test.tsx.snap b/ui-packages/packages/process-details/src/envelope/components/JobActionsKebab/tests/__snapshots__/JobsActionsKebab.test.tsx.snap
index 82f444e62e..4c273b3556 100644
--- a/ui-packages/packages/process-details/src/envelope/components/JobActionsKebab/tests/__snapshots__/JobsActionsKebab.test.tsx.snap
+++ b/ui-packages/packages/process-details/src/envelope/components/JobActionsKebab/tests/__snapshots__/JobsActionsKebab.test.tsx.snap
@@ -1,832 +1,111 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`job actions kebab tests dropdown open/close tests and details click 1`] = `
-
-
- OK
- ,
- ]
- }
- modalTitle={
-
-
-
- Job Details
-
-
- }
- >
-
- OK
- ,
- ]
- }
- appendTo={[Function]}
- aria-describedby=""
- aria-label="Job Detailsmodal"
- aria-labelledby="Job Detailsmodal"
- className=""
- data-ouia-component-type="job-details-modal"
- data-ouia-safe={true}
- hasNoBodyWrapper={false}
- header={
-
-
-
- Job Details
-
-
- }
- isOpen={false}
- onClose={[Function]}
- ouiaSafe={true}
- showClose={true}
- title=""
- titleIconVariant={null}
- titleLabel=""
- variant="large"
- >
- }
- >
-
- OK
- ,
- ]
- }
- aria-describedby=""
- aria-label="Job Detailsmodal"
- aria-labelledby="Job Detailsmodal"
- boxId="pf-modal-part-0"
- className=""
- data-ouia-component-type="job-details-modal"
- data-ouia-safe={true}
- descriptorId="pf-modal-part-2"
- hasNoBodyWrapper={false}
- header={
-
-
-
- Job Details
-
-
- }
- isOpen={false}
- labelId="pf-modal-part-1"
- onClose={[Function]}
- ouiaId="OUIA-Generated-Modal-large-1"
- ouiaSafe={true}
- showClose={true}
- title=""
- titleIconVariant={null}
- titleLabel=""
- variant="large"
- />
-
-
-
-
- Cancel
- ,
- ]
- }
- rescheduleError=""
- setRescheduleError={[Function]}
+
+
-
- Apply
- ,
- ,
- ]
- }
- appendTo={[Function]}
- aria-describedby=""
- aria-label="Job Reschedule modal"
- aria-labelledby="actionType modal"
- className=""
- data-ouia-component-type="job-reschedule-modal"
- data-ouia-safe={true}
- hasNoBodyWrapper={false}
- header={
-
-
-
- Job Reschedule
-
-
- }
- isOpen={false}
- onClose={[Function]}
- ouiaSafe={true}
- showClose={true}
- title=""
- titleIconVariant={null}
- titleLabel=""
- variant="small"
+ ,
- ,
- ]
- }
- aria-describedby=""
- aria-label="Job Reschedule modal"
- aria-labelledby="actionType modal"
- boxId="pf-modal-part-1"
- className=""
- data-ouia-component-type="job-reschedule-modal"
- data-ouia-safe={true}
- descriptorId="pf-modal-part-3"
- hasNoBodyWrapper={false}
- header={
-
-
-
- Job Reschedule
-
-
- }
- isOpen={false}
- labelId="pf-modal-part-2"
- onClose={[Function]}
- ouiaId="OUIA-Generated-Modal-small-1"
- ouiaSafe={true}
- showClose={true}
- title=""
- titleIconVariant={null}
- titleLabel=""
- variant="small"
+
-
-
-
- OK
- ,
- ]
- }
- appendTo={[Function]}
- aria-describedby=""
- aria-label="Reschedule error modal"
- aria-labelledby="Reschedule error modal"
- className=""
- data-ouia-component-type="job-reschedule-error-modal"
- data-ouia-safe={true}
- hasNoBodyWrapper={false}
- header={
-
-
-
- Job Reschedule
-
-
- }
- isOpen={false}
- onClose={[Function]}
- ouiaSafe={true}
- showClose={true}
- title=""
- titleIconVariant={null}
- titleLabel=""
- variant="small"
- >
- }
- >
-
- OK
- ,
- ]
- }
- aria-describedby=""
- aria-label="Reschedule error modal"
- aria-labelledby="Reschedule error modal"
- boxId="pf-modal-part-2"
- className=""
- data-ouia-component-type="job-reschedule-error-modal"
- data-ouia-safe={true}
- descriptorId="pf-modal-part-4"
- hasNoBodyWrapper={false}
- header={
-
-
-
- Job Reschedule
-
-
- }
- isOpen={false}
- labelId="pf-modal-part-3"
- onClose={[Function]}
- ouiaId="OUIA-Generated-Modal-small-2"
- ouiaSafe={true}
- showClose={true}
- title=""
- titleIconVariant={null}
- titleLabel=""
- variant="small"
- />
-
-
-
-
+
+
+
+`;
+
+exports[`job actions kebab tests test job cancel option 1`] = `
+
+
-
- OK
- ,
- ]
- }
- appendTo={[Function]}
- aria-describedby=""
- aria-label="Job Cancel Modal"
- aria-labelledby="Job Cancel Modal"
- className=""
- data-ouia-component-type="jobs-cancel-modal"
- data-ouia-safe={true}
- hasNoBodyWrapper={false}
- header={null}
- isOpen={false}
- onClose={[Function]}
- ouiaSafe={true}
- showClose={true}
- title=""
- titleIconVariant={null}
- titleLabel=""
- variant="small"
+ ,
- ]
- }
- aria-describedby=""
- aria-label="Job Cancel Modal"
- aria-labelledby="Job Cancel Modal"
- boxId="pf-modal-part-3"
- className=""
- data-ouia-component-type="jobs-cancel-modal"
- data-ouia-safe={true}
- descriptorId="pf-modal-part-5"
- hasNoBodyWrapper={false}
- header={null}
- isOpen={false}
- labelId="pf-modal-part-4"
- onClose={[Function]}
- ouiaId="OUIA-Generated-Modal-small-3"
- ouiaSafe={true}
- showClose={true}
- title=""
- titleIconVariant={null}
- titleLabel=""
- variant="small"
+
-
-
-
-
+
+
+
+`;
+
+exports[`job actions kebab tests test reschedule option 1`] = `
+
+
- Details
- ,
- ]
- }
- isOpen={true}
- isPlain={true}
- onSelect={[Function]}
- position="right"
- toggle={
-
- }
+ class="pf-c-dropdown pf-m-align-right"
+ data-ouia-component-id="OUIA-Generated-Dropdown-2"
+ data-ouia-component-type="PF4/Dropdown"
+ data-ouia-safe="true"
>
-
- Details
- ,
- ]
- }
- isFlipEnabled={true}
- isGrouped={false}
- isOpen={true}
- isPlain={true}
- isText={false}
- menuAppendTo="inline"
- onSelect={[Function]}
- position="right"
- removeFindDomNode={false}
- toggle={
-
- }
- zIndex={9999}
+ ,
- }
- }
- >
-
-
-
-
-
-
-
-
-
-
-
- -
-
- Details
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
`;
diff --git a/ui-packages/packages/process-details/src/envelope/components/JobsPanel/tests/JobsPanel.test.tsx b/ui-packages/packages/process-details/src/envelope/components/JobsPanel/tests/JobsPanel.test.tsx
index 58201bafff..7224a9d8f9 100644
--- a/ui-packages/packages/process-details/src/envelope/components/JobsPanel/tests/JobsPanel.test.tsx
+++ b/ui-packages/packages/process-details/src/envelope/components/JobsPanel/tests/JobsPanel.test.tsx
@@ -16,12 +16,10 @@
import React from 'react';
import JobsPanel from '../JobsPanel';
-import { mount } from 'enzyme';
+import { render } from '@testing-library/react';
import { MockedProcessDetailsDriver } from '../../../../embedded/tests/mocks/Mocks';
import { JobStatus } from '@kogito-apps/management-console-shared/dist/types';
-import wait from 'waait';
import { act } from 'react-dom/test-utils';
-jest.mock('../../JobActionsKebab/JobActionsKebab');
const MockedComponent = (): React.ReactElement => {
return <>>;
@@ -123,30 +121,25 @@ const props3 = {
Date.now = jest.fn(() => 1592000000000); // UTC Fri Jun 12 2020 22:13:20
describe('Processdetails jobs pannel component tests', () => {
it('Snapshot testing', async () => {
- let wrapper;
+ let container;
await act(async () => {
- wrapper = mount();
- await wait(0);
- wrapper = wrapper.update().find('JobsPanel');
+ container = render().container;
});
- expect(wrapper).toMatchSnapshot();
+ expect(container).toMatchSnapshot();
});
it('test expiration time', async () => {
- let wrapper;
+ let container;
await act(async () => {
- wrapper = mount();
- await wait(0);
- wrapper = wrapper.update().find('JobsPanel');
+ container = render().container;
});
- expect(wrapper).toMatchSnapshot();
+ expect(container).toMatchSnapshot();
});
+
it('Jobs empty response', async () => {
- let wrapper;
+ let container;
await act(async () => {
- wrapper = mount();
- await wait(0);
- wrapper = wrapper.update().find('JobsPanel');
+ container = render().container;
});
- expect(wrapper).toMatchSnapshot();
+ expect(container).toMatchSnapshot();
});
});
diff --git a/ui-packages/packages/process-details/src/envelope/components/JobsPanel/tests/__snapshots__/JobsPanel.test.tsx.snap b/ui-packages/packages/process-details/src/envelope/components/JobsPanel/tests/__snapshots__/JobsPanel.test.tsx.snap
index 2cefd1d639..678369b1e5 100644
--- a/ui-packages/packages/process-details/src/envelope/components/JobsPanel/tests/__snapshots__/JobsPanel.test.tsx.snap
+++ b/ui-packages/packages/process-details/src/envelope/components/JobsPanel/tests/__snapshots__/JobsPanel.test.tsx.snap
@@ -1,7056 +1,318 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
-exports[`Processdetails jobs pannel component tests Jobs empty response 1`] = `
-
-`;
+exports[`Processdetails jobs pannel component tests Jobs empty response 1`] = ``;
exports[`Processdetails jobs pannel component tests Snapshot testing 1`] = `
-
-
+
-
+
+
-
-
-
-
-
-
- }
- processName="HotelBooking"
- >
-
- OK
- ,
- ]
- }
- appendTo={[Function]}
- aria-describedby=""
- aria-label="process list modal"
- aria-labelledby="process list modal"
- className=""
- data-ouia-component-type="process-list-modal"
- data-ouia-safe={true}
- hasNoBodyWrapper={false}
- header={
-
-
-
-
-
- }
- isOpen={false}
- onClose={[Function]}
- ouiaSafe={true}
- showClose={true}
- title=""
- titleIconVariant={null}
- titleLabel=""
- variant="small"
- >
- }
- >
-
- OK
- ,
- ]
- }
- aria-describedby=""
- aria-label="process list modal"
- aria-labelledby="process list modal"
- boxId="pf-modal-part-0"
- className=""
- data-ouia-component-type="process-list-modal"
- data-ouia-safe={true}
- descriptorId="pf-modal-part-2"
- hasNoBodyWrapper={false}
- header={
-
-
-
-
-
- }
- isOpen={false}
- labelId="pf-modal-part-1"
- onClose={[Function]}
- ouiaId="OUIA-Generated-Modal-small-1"
- ouiaSafe={true}
- showClose={true}
- title=""
- titleIconVariant={null}
- titleLabel=""
- variant="small"
- />
-
-
-
-
+
+
`;
diff --git a/ui-packages/packages/process-details/src/envelope/components/ProcessDetailsErrorModal/tests/ProcessDetailsErrorModal.test.tsx b/ui-packages/packages/process-details/src/envelope/components/ProcessDetailsErrorModal/tests/ProcessDetailsErrorModal.test.tsx
index 32306e8859..e58857c448 100644
--- a/ui-packages/packages/process-details/src/envelope/components/ProcessDetailsErrorModal/tests/ProcessDetailsErrorModal.test.tsx
+++ b/ui-packages/packages/process-details/src/envelope/components/ProcessDetailsErrorModal/tests/ProcessDetailsErrorModal.test.tsx
@@ -18,7 +18,7 @@ import React from 'react';
import ProcessDetailsErrorModal from '../ProcessDetailsErrorModal';
import { Button } from '@patternfly/react-core/dist/js/components/Button';
import { setTitle } from '@kogito-apps/management-console-shared/dist/utils/Utils';
-import { mount } from 'enzyme';
+import { render } from '@testing-library/react';
const MockedIcon = (): React.ReactElement => {
return <>>;
@@ -36,6 +36,7 @@ const errorModalAction: JSX.Element[] = [
OK
];
+
describe('Process details error modal tests', () => {
const props = {
errorString: '404-not found',
@@ -47,10 +48,7 @@ describe('Process details error modal tests', () => {
};
it('Snapshot test with default props', () => {
- const wrapper = mount().find(
- 'ProcessDetailsErrorModal'
- );
- expect(wrapper).toMatchSnapshot();
- expect(wrapper.find('Text').children().text()).toEqual('404-not found');
+ const container = render().container;
+ expect(container).toMatchSnapshot();
});
});
diff --git a/ui-packages/packages/process-details/src/envelope/components/ProcessDetailsErrorModal/tests/__snapshots__/ProcessDetailsErrorModal.test.tsx.snap b/ui-packages/packages/process-details/src/envelope/components/ProcessDetailsErrorModal/tests/__snapshots__/ProcessDetailsErrorModal.test.tsx.snap
index b20e705381..23753a1c93 100644
--- a/ui-packages/packages/process-details/src/envelope/components/ProcessDetailsErrorModal/tests/__snapshots__/ProcessDetailsErrorModal.test.tsx.snap
+++ b/ui-packages/packages/process-details/src/envelope/components/ProcessDetailsErrorModal/tests/__snapshots__/ProcessDetailsErrorModal.test.tsx.snap
@@ -1,443 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`Process details error modal tests Snapshot test with default props 1`] = `
-
- OK
- ,
- ]
- }
- errorModalOpen={true}
- errorString="404-not found"
- handleErrorModal={[MockFunction]}
- label="Error modal"
- title={
-
-
-
- Process Visualization
-
-
- }
->
-
- OK
- ,
- ]
- }
- appendTo={[Function]}
- aria-describedby=""
- aria-label="Error modal"
- aria-labelledby="Error modal"
- className=""
- data-ouia-component-type="process-details-error-modal"
- data-ouia-safe={true}
- hasNoBodyWrapper={false}
- header={
-
-
-
- Process Visualization
-
-
- }
- isOpen={true}
- onClose={[MockFunction]}
- ouiaSafe={true}
- showClose={true}
- title=""
- titleIconVariant={null}
- titleLabel=""
- variant="small"
- >
-
-
-
- }
- >
-
- OK
- ,
- ]
- }
- aria-describedby=""
- aria-label="Error modal"
- aria-labelledby="Error modal"
- boxId="pf-modal-part-0"
- className=""
- data-ouia-component-type="process-details-error-modal"
- data-ouia-safe={true}
- descriptorId="pf-modal-part-2"
- hasNoBodyWrapper={false}
- header={
-
-
-
- Process Visualization
-
-
- }
- isOpen={true}
- labelId="pf-modal-part-1"
- onClose={[MockFunction]}
- ouiaId="OUIA-Generated-Modal-small-1"
- ouiaSafe={true}
- showClose={true}
- title=""
- titleIconVariant={null}
- titleLabel=""
- variant="small"
- >
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Process Visualization
-
-
-
-
-
-
-
-
-
-
-
-
-
- 404-not found
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
`;
diff --git a/ui-packages/packages/process-details/src/envelope/components/ProcessDetailsMilestonesPanel/tests/ProcessDetailsMilestonesPanel.test.tsx b/ui-packages/packages/process-details/src/envelope/components/ProcessDetailsMilestonesPanel/tests/ProcessDetailsMilestonesPanel.test.tsx
index ab22116f00..a9b997a5fc 100644
--- a/ui-packages/packages/process-details/src/envelope/components/ProcessDetailsMilestonesPanel/tests/ProcessDetailsMilestonesPanel.test.tsx
+++ b/ui-packages/packages/process-details/src/envelope/components/ProcessDetailsMilestonesPanel/tests/ProcessDetailsMilestonesPanel.test.tsx
@@ -16,9 +16,8 @@
import React from 'react';
import ProcessDetailsMilestonesPanel from '../ProcessDetailsMilestonesPanel';
-import { mount } from 'enzyme';
+import { render } from '@testing-library/react';
import { MilestoneStatus } from '@kogito-apps/management-console-shared/dist/types';
-// tslint:disable: no-string-literal
const MockedComponent = (): React.ReactElement => {
return <>>;
@@ -39,6 +38,7 @@ jest.mock('@patternfly/react-core/dist/js/components/Tooltip', () =>
}
})
);
+
describe('Process details page milestones panel', () => {
const props = {
milestones: [
@@ -109,14 +109,11 @@ describe('Process details page milestones panel', () => {
]
};
it('Snapshot test with default props', () => {
- const wrapper = mount();
- expect(wrapper).toMatchSnapshot();
+ const container = render();
+ expect(container).toMatchSnapshot();
});
it('test assertions', () => {
- const wrapper = mount();
- expect(wrapper).toMatchSnapshot();
- expect(wrapper.find('p').at(2).text()).toEqual(
- 'Milestone 3: Order delivered Available'
- );
+ const container = render();
+ expect(container).toMatchSnapshot();
});
});
diff --git a/ui-packages/packages/process-details/src/envelope/components/ProcessDetailsMilestonesPanel/tests/__snapshots__/ProcessDetailsMilestonesPanel.test.tsx.snap b/ui-packages/packages/process-details/src/envelope/components/ProcessDetailsMilestonesPanel/tests/__snapshots__/ProcessDetailsMilestonesPanel.test.tsx.snap
index 0c20128070..41db4f59f4 100644
--- a/ui-packages/packages/process-details/src/envelope/components/ProcessDetailsMilestonesPanel/tests/__snapshots__/ProcessDetailsMilestonesPanel.test.tsx.snap
+++ b/ui-packages/packages/process-details/src/envelope/components/ProcessDetailsMilestonesPanel/tests/__snapshots__/ProcessDetailsMilestonesPanel.test.tsx.snap
@@ -1,525 +1,675 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`Process details page milestones panel Snapshot test with default props 1`] = `
-
-
-
-
+Object {
+ "asFragment": [Function],
+ "baseElement":
+
+
-
-
-
-
-
-
- Milestone 1: Order placed
-
- }
- >
-
-
-
-
-
-
-
- Active
-
-
-
-
-
-
+ Active
+
+
+
+
+ Milestone 2: Order shipped
+
+
-
- Milestone 2: Order shipped
-
- }
- >
-
-
-
-
-
-
-
- Available
-
-
-
-
-
-
+ Available
+
+
+
+
+
+ Milestone 3: Order delivered and closed with customer sign off
+
+
+
-
-
-
- Milestone 3: Order delivered and closed with customer sign off
-
-
- }
- >
-
-
-
-
-
-
-
- Available
-
-
-
-
-
-
-
-
+ Available
+
+
+
+
+
+ Manager decision
+
+
-
- Manager decision
-
- }
- >
-
-
-
-
-
-
-
- Completed
-
-
-
-
-
-
-
+
+ Completed
+
+
+
+
-
-
-
-
-`;
-
-exports[`Process details page milestones panel test assertions 1`] = `
-
-
+
+
+ ,
+ "container":
-
+
+
-
-
- Milestones
-
-
+
+
+ Active
+
+
+
+
+ Milestone 2: Order shipped
+
+
+
+
+ Available
+
+
+
+
+
+ Milestone 3: Order delivered and closed with customer sign off
+
+
+
+
+
+ Available
+
+
+
+
+
+ Manager decision
+
+
+
+
+ Completed
+
+
+
+
+
+
+
,
+ "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],
+ "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],
+ "rerender": [Function],
+ "unmount": [Function],
+}
+`;
+
+exports[`Process details page milestones panel test assertions 1`] = `
+Object {
+ "asFragment": [Function],
+ "baseElement":
+
+
+
-
-
-
-
-
-
- Milestone 1: Order placed
-
- }
- >
-
-
-
-
-
-
-
- Active
-
-
-
-
-
-
+ Active
+
+
+
+
+ Milestone 2: Order shipped
+
+
-
- Milestone 2: Order shipped
-
- }
- >
-
-
-
-
-
-
-
- Available
-
-
-
-
-
-
+ Available
+
+
+
+
+ Milestone 3: Order delivered
+
+
-
- Milestone 3: Order delivered
-
- }
- >
-
-
-
-
-
-
-
- Available
-
-
-
-
-
-
+ Available
+
+
+
+
+ Milestone 2: Order shipped
+
+
-
- Milestone 2: Order shipped
-
- }
- >
-
-
-
-
-
-
-
- Available
-
-
-
-
-
-
+ Available
+
+
+
+
+
-
-
-
- Milestone 3: Order delivered and closed with customer sign off
-
-
- }
- >
-
-
-
-
-
-
-
- Completed
-
-
-
-
-
-
-
-
+
+
-
- Milestone 2: Order shipped
-
-
-
-
-
+
+ Completed
+
+
+
+
+
+ Milestone 2: Order shipped
+
+
+
+
+
+
+ ,
+ "container":
+
+
+
+
+
+ Milestone 1: Order placed
+
+
+
+
+ Active
+
+
+
+
+ Milestone 2: Order shipped
+
+
+
+
+ Available
+
+
+
+
+ Milestone 3: Order delivered
+
+
+
+
+ Available
+
+
+
+
+ Milestone 2: Order shipped
+
+
+
+
+ Available
+
+
+
+
+
+ Milestone 3: Order delivered and closed with customer sign off
+
+
+
+
+
+ Completed
+
+
+
+
+
+ Milestone 2: Order shipped
+
+
-
+
-
-
+
,
+ "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],
+ "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],
+ "rerender": [Function],
+ "unmount": [Function],
+}
`;
diff --git a/ui-packages/packages/process-details/src/envelope/components/ProcessDetailsNodeTrigger/ProcessDetailsNodeTrigger.tsx b/ui-packages/packages/process-details/src/envelope/components/ProcessDetailsNodeTrigger/ProcessDetailsNodeTrigger.tsx
index a977e15538..f69e5b31b5 100644
--- a/ui-packages/packages/process-details/src/envelope/components/ProcessDetailsNodeTrigger/ProcessDetailsNodeTrigger.tsx
+++ b/ui-packages/packages/process-details/src/envelope/components/ProcessDetailsNodeTrigger/ProcessDetailsNodeTrigger.tsx
@@ -182,6 +182,7 @@ const ProcessDetailsNodeTrigger: React.FC<
toggle={
@@ -256,6 +257,7 @@ const ProcessDetailsNodeTrigger: React.FC<
variant="secondary"
onClick={onTriggerClick}
id="trigger"
+ data-testid="trigger"
isDisabled={!selectedNode}
>
Trigger
diff --git a/ui-packages/packages/process-details/src/envelope/components/ProcessDetailsNodeTrigger/tests/ProcessDetailsNodeTrigger.test.tsx b/ui-packages/packages/process-details/src/envelope/components/ProcessDetailsNodeTrigger/tests/ProcessDetailsNodeTrigger.test.tsx
index 06a47ed611..5f91f4f5ce 100644
--- a/ui-packages/packages/process-details/src/envelope/components/ProcessDetailsNodeTrigger/tests/ProcessDetailsNodeTrigger.test.tsx
+++ b/ui-packages/packages/process-details/src/envelope/components/ProcessDetailsNodeTrigger/tests/ProcessDetailsNodeTrigger.test.tsx
@@ -16,21 +16,15 @@
import React from 'react';
import ProcessDetailsNodeTrigger from '../ProcessDetailsNodeTrigger';
-import {
- DropdownToggle,
- DropdownItem
-} from '@patternfly/react-core/dist/js/components/Dropdown';
-import { FlexItem } from '@patternfly/react-core/dist/js/layouts/Flex';
import { act } from 'react-dom/test-utils';
-import { mount } from 'enzyme';
+import { render, screen, waitFor, fireEvent } from '@testing-library/react';
import {
ProcessInstance,
ProcessInstanceState
} from '@kogito-apps/management-console-shared/dist/types';
import TestProcessDetailsDriver from '../../../tests/mocks/TestProcessDetailsDriver';
-import wait from 'waait';
jest.mock('../../ProcessDetailsErrorModal/ProcessDetailsErrorModal');
-
+Date.now = jest.fn(() => 1592000000000); // UTC Fri Jun 12 2020 22:13:20
const processInstanceData: ProcessInstance = {
id: 'e4448857-fa0c-403b-ad69-f0a353458b9d',
processId: 'travels',
@@ -77,158 +71,47 @@ const processInstanceData: ProcessInstance = {
childProcessInstances: []
};
-const mockTriggerableNodes = [
- {
- nodeDefinitionId: '_BDA56801-1155-4AF2-94D4-7DAADED2E3C0',
- name: 'Send visa application',
- id: 1,
- type: 'ActionNode',
- uniqueId: '1'
- },
- {
- nodeDefinitionId: '_175DC79D-C2F1-4B28-BE2D-B583DFABF70D',
- name: 'Book',
- id: 2,
- type: 'Split',
- uniqueId: '2'
- },
- {
- nodeDefinitionId: '_E611283E-30B0-46B9-8305-768A002C7518',
- name: 'visasrejected',
- id: 3,
- type: 'EventNode',
- uniqueId: '3'
- }
-];
-
-const getNodeTriggerWrapper = async () => {
- let wrapper;
- await act(async () => {
- wrapper = mount(
-
- );
- await wait(0);
- wrapper = wrapper.update().find('ProcessDetailsNodeTrigger');
- });
- return wrapper;
-};
-
describe('Process details node trigger component tests', () => {
- it('snapshot testing with none selected', async () => {
- const wrapper = await getNodeTriggerWrapper();
- expect(wrapper).toMatchSnapshot();
+ afterEach(() => {
+ jest.clearAllMocks();
});
-
- it('select a node test ', async () => {
- let wrapper = await getNodeTriggerWrapper();
- await act(async () => {
- wrapper.find(DropdownToggle).find('button').simulate('click');
- });
- wrapper = wrapper.update();
-
+ it('snapshot testing with none selected', async () => {
+ let container;
await act(async () => {
- wrapper.find(DropdownItem).at(1).simulate('click');
+ container = render(
+
+ );
});
- wrapper = wrapper.update();
- // snapshot with data displayed
- expect(wrapper).toMatchSnapshot();
- expect(wrapper.find(FlexItem).length).toEqual(3);
- // Node name displayed
- expect(
- wrapper
- .find(FlexItem)
- .find('h6')
- .at(0)
- .children()
- .contains('Node name : ')
- ).toBeTruthy();
- // Node type displayed
- expect(
- wrapper
- .find(FlexItem)
- .find('h6')
- .at(1)
- .children()
- .contains('Node type : ')
- ).toBeTruthy();
- // Node id displayed
- expect(
- wrapper.find(FlexItem).find('h6').at(2).children().contains('Node id : ')
- ).toBeTruthy();
+ expect(container).toMatchSnapshot();
});
- it('Node trigger success tests', async () => {
- const driver = new TestProcessDetailsDriver('123');
- const driverMockNodeTriggerSuccess = jest.spyOn(
- driver,
- 'handleNodeTrigger'
- );
- const driverMockGetTriggerableNode = jest.spyOn(
- driver,
- 'getTriggerableNodes'
- );
- driverMockGetTriggerableNode.mockResolvedValue(mockTriggerableNodes);
- driverMockNodeTriggerSuccess.mockResolvedValue();
- let wrapper;
+ it('select a node and trigger ', async () => {
+ let container;
await act(async () => {
- wrapper = mount(
+ container = render(
);
- await wait(0);
- wrapper = wrapper.update().find('ProcessDetailsNodeTrigger');
- });
-
- await act(async () => {
- wrapper.find(DropdownToggle).find('button').simulate('click');
});
- wrapper = wrapper.update();
-
await act(async () => {
- wrapper.find(DropdownItem).at(1).simulate('click');
+ fireEvent.click(screen.getByTestId('toggle-id'));
});
- wrapper = wrapper.update();
+ await waitFor(() => screen.getAllByText('Book'));
await act(async () => {
- wrapper.find('#trigger').find('button').simulate('click');
+ fireEvent.click(screen.getAllByText('Book')[0]);
});
- wrapper = wrapper.update();
- wrapper = wrapper.find('MockedProcessDetailsErrorModal');
- // takes snapshot of the success modal
- expect(wrapper).toMatchSnapshot();
- // check the modal content
- expect(
- wrapper.find('MockedProcessDetailsErrorModal').props()['errorString']
- ).toEqual('The node Book was triggered successfully');
- });
-
- it('failed to retrieve nodes', async () => {
- const driver = new TestProcessDetailsDriver('123');
- const driverMockGetTriggerableNode = jest.spyOn(
- driver,
- 'getTriggerableNodes'
- );
- driverMockGetTriggerableNode.mockRejectedValue({ message: '404 error' });
- let wrapper = null;
await act(async () => {
- wrapper = mount(
-
- ).find('ProcessDetailsNodeTrigger');
+ fireEvent.click(screen.getByTestId('trigger'));
});
- wrapper = wrapper.update().find('MockedProcessDetailsErrorModal');
- expect(wrapper).toMatchSnapshot();
- expect(
- wrapper.find('MockedProcessDetailsErrorModal').exists()
- ).toBeTruthy();
- expect(
- wrapper.find('MockedProcessDetailsErrorModal').props()['errorString']
- ).toEqual('Retrieval of nodes failed with error: 404 error');
+ await new Promise((r) => setTimeout(r, 1000));
+ await waitFor(() => screen.getAllByText('Node id :'));
+ expect(screen.getAllByText('Node id :')[0]).toBeTruthy();
+ expect(screen.getAllByText('Node name :')[0]).toBeTruthy();
+ expect(screen.getAllByText('Node type :')[0]).toBeTruthy();
});
});
diff --git a/ui-packages/packages/process-details/src/envelope/components/ProcessDetailsNodeTrigger/tests/__snapshots__/ProcessDetailsNodeTrigger.test.tsx.snap b/ui-packages/packages/process-details/src/envelope/components/ProcessDetailsNodeTrigger/tests/__snapshots__/ProcessDetailsNodeTrigger.test.tsx.snap
index 2b9eb90749..d5ac58c64b 100644
--- a/ui-packages/packages/process-details/src/envelope/components/ProcessDetailsNodeTrigger/tests/__snapshots__/ProcessDetailsNodeTrigger.test.tsx.snap
+++ b/ui-packages/packages/process-details/src/envelope/components/ProcessDetailsNodeTrigger/tests/__snapshots__/ProcessDetailsNodeTrigger.test.tsx.snap
@@ -1,1105 +1,246 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
-exports[`Process details node trigger component tests Node trigger success tests 1`] = `
-
- OK
- ,
- ]
- }
- errorModalOpen={true}
- errorString="The node Book was triggered successfully"
- handleErrorModal={[Function]}
- label="Node Trigger Error"
- title={
-
-
-
- Node trigger process
-
-
- }
-/>
-`;
-
-exports[`Process details node trigger component tests failed to retrieve nodes 1`] = `
-
- OK
- ,
- ]
- }
- errorModalOpen={true}
- errorString="Retrieval of nodes failed with error: 404 error"
- handleErrorModal={[Function]}
- label="Node Trigger Error"
- title={
-
-
-
- Node trigger Error
-
-
- }
-/>
-`;
-
-exports[`Process details node trigger component tests select a node test 1`] = `
-
-
- OK
- ,
- ]
- }
- errorModalOpen={false}
- errorString=""
- handleErrorModal={[Function]}
- label="Node Trigger Error"
- title={
-
+
+
-
-
-
-
- }
- />
-
-
-
-
-
-
-
-
- Send visa application
- ,
-
- Book
- ,
-
- visasrejected
- ,
- ]
- }
- isOpen={false}
- onSelect={[Function]}
- toggle={
-
- Book
-
- }
+
-
- Send visa application
- ,
-
- Book
- ,
-
- visasrejected
- ,
- ]
- }
- isFlipEnabled={true}
- isGrouped={false}
- isOpen={false}
- isPlain={false}
- isText={false}
- menuAppendTo="inline"
- onSelect={[Function]}
- position="left"
- removeFindDomNode={false}
- toggle={
-
- Book
-
- }
- zIndex={9999}
+
-
-
-
-
- Book
-
-
-
-
-
- ,
- }
- }
- toggleIndicator={[Function]}
- >
-
-
-
- Book
-
-
-
-
-
- ,
- }
- }
- toggleVariant="default"
- >
-
-
- Book
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Node name :
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Node type :
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
-
-
-
+
+
+
+
+
-
-
-
- Trigger
-
-
-
+ Trigger
+
-
-
-
-
-`;
-
-exports[`Process details node trigger component tests snapshot testing with none selected 1`] = `
-
-
- OK
- ,
- ]
- }
- errorModalOpen={false}
- errorString=""
- handleErrorModal={[Function]}
- label="Node Trigger Error"
- title={
-
-
-
-
-
- }
- />
-
+
+
+