Skip to content

Commit

Permalink
migrate process-list, process-details (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
AjayJagan authored Aug 8, 2023
1 parent 32293a4 commit a1a5d9c
Show file tree
Hide file tree
Showing 72 changed files with 35,439 additions and 47,985 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() });
52 changes: 52 additions & 0 deletions ui-packages/packages/process-details/jest.config.js
Original file line number Diff line number Diff line change
@@ -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'
}
};
49 changes: 1 addition & 48 deletions ui-packages/packages/process-details/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ export const EmbeddedProcessDetails = React.forwardRef(
container: container(),
bus: {
postMessage(message, targetOrigin, transfer) {
/* istanbul ignore next */
window.postMessage(message, targetOrigin, transfer);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -111,13 +111,10 @@ describe('EmbeddedProcessDetails tests', () => {
pluralProcessLabel: 'Workflows'
};

const wrapper = mount(<EmbeddedProcessDetails {...props} />);
const container = render(<EmbeddedProcessDetails {...props} />).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();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -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');
});
});
Original file line number Diff line number Diff line change
@@ -1,140 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`EmbeddedProcessDetails tests Snapshot 1`] = `
<ForwardRef
driver={
Object {
"cancelJob": [MockFunction],
"getProcessDiagram": [MockFunction],
"getTriggerableNodes": [MockFunction],
"handleNodeInstanceCancel": [MockFunction],
"handleNodeInstanceRetrigger": [MockFunction],
"handleNodeTrigger": [MockFunction],
"handleProcessAbort": [MockFunction],
"handleProcessRetry": [MockFunction],
"handleProcessSkip": [MockFunction],
"handleProcessVariableUpdate": [MockFunction],
"jobsQuery": [MockFunction],
"openProcessInstanceDetails": [MockFunction],
"processDetailsQuery": [MockFunction],
"rescheduleJob": [MockFunction],
}
}
pluralProcessLabel="Workflows"
processInstance={
Object {
"addons": Array [
"process-management",
],
"businessKey": "T1234HotelBooking01",
"childProcessInstances": Array [],
"end": 2019-10-22T05:40:44.089Z,
"endpoint": "http://localhost:4000",
"error": Object {
"__typename": "ProcessInstanceError",
"message": "some thing went wrong",
"nodeDefinitionId": "a1e139d5-4e77-48c9-84ae-34578e904e6b",
},
"id": "a1e139d5-4e77-48c9-84ae-34578e904e5a",
"lastUpdate": 2021-04-22T14:53:04.000Z,
"milestones": Array [
Object {
"__typename": "Milestone",
"id": "27107f38-d888-4edf-9a4f-11b9e6d75i86",
"name": "Manager decision",
"status": "COMPLETED",
},
Object {
"__typename": "Milestone",
"id": "27107f38-d888-4edf-9a4f-11b9e6d75m36",
"name": "Milestone 1: Order placed",
"status": "ACTIVE",
},
Object {
"__typename": "Milestone",
"id": "27107f38-d888-4edf-9a4f-11b9e6d75m66",
"name": "Milestone 2: Order shipped",
"status": "AVAILABLE",
},
],
"nodes": Array [
Object {
"__typename": "NodeInstance",
"definitionId": "EndEvent_1",
"enter": 2019-10-22T03:37:30.798Z,
"exit": 2019-10-22T03:37:30.798Z,
"id": "27107f38-d888-4edf-9a4f-11b9e6d751b6",
"name": "End Event 1",
"nodeId": "1",
"type": "EndNode",
},
Object {
"__typename": "NodeInstance",
"definitionId": "ServiceTask_1",
"enter": 2019-10-22T03:37:30.795Z,
"exit": 2019-10-22T03:37:30.798Z,
"id": "41b3f49e-beb3-4b5f-8130-efd28f82b971",
"name": "Book hotel",
"nodeId": "2",
"type": "WorkItemNode",
},
Object {
"__typename": "NodeInstance",
"definitionId": "StartEvent_1",
"enter": 2019-10-22T03:37:30.793Z,
"exit": 2019-10-22T03:37:30.795Z,
"id": "4165a571-2c79-4fd0-921e-c6d5e7851b67",
"name": "StartProcess",
"nodeId": "2",
"type": "StartNode",
},
],
"parentProcessInstance": null,
"parentProcessInstanceId": "e4448857-fa0c-403b-ad69-f0a353458b9d",
"processId": "hotelBooking",
"processName": "HotelBooking",
"roles": Array [],
"serviceUrl": "http://localhost:4000",
"start": 2019-10-22T03:40:44.089Z,
"state": "COMPLETED",
"variables": "{\\"trip\\":{\\"begin\\":\\"2019-10-22T22:00:00Z[UTC]\\",\\"city\\":\\"Bangalore\\",\\"country\\":\\"India\\",\\"end\\":\\"2019-10-30T22:00:00Z[UTC]\\",\\"visaRequired\\":false},\\"hotel\\":{\\"address\\":{\\"city\\":\\"Bangalore\\",\\"country\\":\\"India\\",\\"street\\":\\"street\\",\\"zipCode\\":\\"12345\\"},\\"bookingNumber\\":\\"XX-012345\\",\\"name\\":\\"Perfect hotel\\",\\"phone\\":\\"09876543\\"},\\"traveller\\":{\\"address\\":{\\"city\\":\\"Bangalore\\",\\"country\\":\\"US\\",\\"street\\":\\"Bangalore\\",\\"zipCode\\":\\"560093\\"},\\"email\\":\\"ajaganat@redhat.com\\",\\"firstName\\":\\"Ajay\\",\\"lastName\\":\\"Jaganathan\\",\\"nationality\\":\\"US\\"}}",
}
}
showSwfDiagram={true}
singularProcessLabel="Workflow"
targetOrigin="origin"
>
<ForwardRef(RefForwardingEmbeddedEnvelope)
apiImpl={
ProcessDetailsChannelApiImpl {
"driver": Object {
"cancelJob": [MockFunction],
"getProcessDiagram": [MockFunction],
"getTriggerableNodes": [MockFunction],
"handleNodeInstanceCancel": [MockFunction],
"handleNodeInstanceRetrigger": [MockFunction],
"handleNodeTrigger": [MockFunction],
"handleProcessAbort": [MockFunction],
"handleProcessRetry": [MockFunction],
"handleProcessSkip": [MockFunction],
"handleProcessVariableUpdate": [MockFunction],
"jobsQuery": [MockFunction],
"openProcessInstanceDetails": [MockFunction],
"processDetailsQuery": [MockFunction],
"rescheduleJob": [MockFunction],
},
}
}
config={
Object {
"containerType": "div",
}
}
origin="origin"
pollInit={[Function]}
refDelegate={[Function]}
>
<div />
</ForwardRef(RefForwardingEmbeddedEnvelope)>
</ForwardRef>
<div>
<div />
</div>
`;
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export class ProcessDetailsEnvelopeApiImpl
association.origin,
association.envelopeServerId
);
/* istanbul ignore if*/
if (this.hasCapturedInitRequestYet()) {
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,16 @@ const JobActionsKebab: React.FC<IOwnProps & OUIAProps> = ({
const dropdownItems = (): JSX.Element[] => {
if (job.endpoint !== null && RescheduleJobs.includes(job.status)) {
return [
<DropdownItem key="details" component="button" onClick={onDetailsClick}>
<DropdownItem
data-testid="job-details"
key="details"
component="button"
onClick={onDetailsClick}
>
Details
</DropdownItem>,
<DropdownItem
data-testid="job-reschedule"
key="reschedule"
component="button"
id="reschedule-option"
Expand All @@ -134,6 +140,7 @@ const JobActionsKebab: React.FC<IOwnProps & OUIAProps> = ({
Reschedule
</DropdownItem>,
<DropdownItem
data-testid="job-cancel"
key="cancel"
component="button"
id="cancel-option"
Expand All @@ -144,7 +151,12 @@ const JobActionsKebab: React.FC<IOwnProps & OUIAProps> = ({
];
} else {
return [
<DropdownItem key="details" component="button" onClick={onDetailsClick}>
<DropdownItem
data-testid="job-details"
key="details"
component="button"
onClick={onDetailsClick}
>
Details
</DropdownItem>
];
Expand Down
Loading

0 comments on commit a1a5d9c

Please sign in to comment.