Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
AjayJagan committed Sep 4, 2023
1 parent f2cd73e commit 99bc0d7
Show file tree
Hide file tree
Showing 8 changed files with 51 additions and 753 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,12 @@ describe('ProcessDetailsChannelApiImpl tests', () => {

it('processDetails__handleNodeTrigger', () => {
const node = {
metadata: {
UniqueId: '1',
state: 'Send visa application',
branch: '',
action: ''
},
nodeDefinitionId: '_BDA56801-1155-4AF2-94D4-7DAADED2E3C0',
name: 'Send visa application',
id: 1,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,7 @@ const ProcessDetailsTimelinePanel: React.FC<IOwnProps & OUIAProps> = ({
...omittedProcessTimelineEvents,
...getOmmitedNodesForTimeline(
data.nodes,
data.source,
data.nodeDefinitions.map((nd) => nd.metadata)
(data.nodeDefinitions || []).map((nd) => nd.metadata)
)
];
}, [data]);
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -216,9 +216,8 @@ const SwfCombinedEditor: React.FC<ISwfCombinedEditorProps & OUIAProps> = ({
const successNodes = getSuccessNodes(
nodes,
nodeNames,
source,
errorNode,
nodeDefinitions.map((nd) => nd.metadata)
(nodeDefinitions || []).map((nd) => nd.metadata)
);
if (successNodes.length > 0) {
combinedEditorEnvelopeApi.notifications.kogitoSwfCombinedEditor_colorNodes.send(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,12 @@ describe('ProcessDetailsEnvelopeViewDriver tests', () => {

it('get triggerable nodes', () => {
const node = {
metadata: {
UniqueId: '1',
state: 'Send visa application',
branch: '',
action: ''
},
nodeDefinitionId: '_BDA56801-1155-4AF2-94D4-7DAADED2E3C0',
name: 'Send visa application',
id: 1,
Expand Down
5 changes: 1 addition & 4 deletions ui-packages/packages/process-details/src/utils/Utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -174,10 +174,9 @@ export const handleJobRescheduleUtil = async (

export const getOmmitedNodesForTimeline = (
nodes: NodeInstance[],
source: string | null,
metaDataArray: NodeMetaData[]
): string[] => {
if (source && nodes.length > 0 && metaDataArray.length > 0) {
if (nodes.length > 0 && metaDataArray.length > 0) {
const availableNodes = metaDataArray
.map((metaData) => metaData.state)
.concat(['Start', 'End'])
Expand All @@ -192,7 +191,6 @@ export const getOmmitedNodesForTimeline = (
export const getSuccessNodes = (
nodeInstances: NodeInstance[],
nodeNames: string[],
source: string,
errorNode: NodeInstance,
metaDataArray: NodeMetaData[]
): string[] => {
Expand All @@ -204,7 +202,6 @@ export const getSuccessNodes = (
);
const ommitedNodesNames = getOmmitedNodesForTimeline(
filteredSuccessNodeInstances,
source,
metaDataArray
);
return successNodes.filter((name) => !ommitedNodesNames.includes(name));
Expand Down
44 changes: 26 additions & 18 deletions ui-packages/packages/process-details/src/utils/tests/utils.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -360,28 +360,36 @@ describe('test utils of jobs', () => {
expect(setRescheduleError).toHaveBeenCalledWith(failedContent);
});

it('test getOmmitedNodesForTimeline with json values', () => {
const source =
'{"id":"hello","version":"1.0","specVersion":"0.8.0","name":"HelloWorld","start":"HelloWorld","states":[{"name":"HelloWorld","type":"inject","data":{"message":"HelloWorld"},"end":true}]}';
const ommittedNodes = getOmmitedNodesForTimeline(nodeInstances, source);
it('test getOmmitedNodesForTimeline', () => {
const metaDataArray = [
{
UniqueId: '1',
state: 'HelloWorld',
branch: '',
action: ''
}
];
const ommittedNodes = getOmmitedNodesForTimeline(
nodeInstances,
metaDataArray
);
expect(ommittedNodes).toEqual(['branch-18', 'EmbeddedStart']);
}),
it('test getOmmitedNodesForTimeline with yaml values', () => {
const source =
"id: hello\nversion: '1.0'\nspecVersion: 0.8.0\nname: Hello World\nstart: HelloWorld\nstates:\n- name: HelloWorld\n type: inject\n data:\n message: Hello World\n end: true\n";
const ommittedNodes = getOmmitedNodesForTimeline(nodeInstances, source);
expect(ommittedNodes).toEqual(['branch-18', 'EmbeddedStart']);
it('test getOmmitedNodesForTimeline with null values', () => {
const ommittedNodes = getOmmitedNodesForTimeline([], []);
expect(ommittedNodes).toEqual([]);
});

it('test getOmmitedNodesForTimeline with null values', () => {
const ommittedNodes = getOmmitedNodesForTimeline([], null);
expect(ommittedNodes).toEqual([]);
});

it('test getSuccessNodes with error node', () => {
const source =
'{"id":"hello","version":"1.0","specVersion":"0.8.0","name":"HelloWorld","start":"HelloWorld","states":[{"name":"HelloWorld","type":"inject","data":{"message":"HelloWorld"},"end":true}]}';
const nodeNames = ['Start', 'HelloWorld', 'End'];
const metaDataArray = [
{
UniqueId: '1',
state: 'HelloWorld',
branch: '',
action: ''
}
];
const errorNode = {
definitionId: '_jbpm-unique-6',
enter: new Date('2023-07-19T09:22:43.372Z'),
Expand All @@ -394,8 +402,8 @@ describe('test utils of jobs', () => {
const successNodes = getSuccessNodes(
nodeInstances,
nodeNames,
source,
errorNode
errorNode,
metaDataArray
);
expect(successNodes.length).not.toEqual(0);
expect(successNodes).toEqual(['Start', 'HelloWorld', 'End']);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -733,6 +733,12 @@ describe('handle node trigger click tests', () => {
});
const node = {
nodeDefinitionId: '_BDA56801-1155-4AF2-94D4-7DAADED2E3C0',
metadata: {
UniqueId: '1',
state: 'Send visa application',
branch: '',
action: ''
},
name: 'Send visa application',
id: 1,
type: 'ActionNode',
Expand Down

0 comments on commit 99bc0d7

Please sign in to comment.