Skip to content

Commit

Permalink
Fixed the engine tests and added some tests for the new script file h…
Browse files Browse the repository at this point in the history
…andling
  • Loading branch information
jjoderis committed Nov 24, 2024
1 parent dc19c16 commit 0e0efc1
Show file tree
Hide file tree
Showing 3 changed files with 181 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ beforeEach(() => {
mockEngine = {
_management: { createInstance: jest.fn() },
_bpmn: 'Bpmn Definitions',
processID: 'mockProcessId',
definitionId: 'mockProcessId',
_log: {
info: jest.fn().mockImplementation(),
},
Expand Down Expand Up @@ -99,6 +99,45 @@ describe('Tests for the function that is supposed to decide if a flow node shoul
});
});

describe('new script task referencing a file encountered', () => {
let mockTask;
let hookReturnValue;

beforeEach(() => {
db.getScript.mockClear();
db.getScript.mockResolvedValueOnce('console.log("Hello Test");');

mockTask = {
id: 'mockTaskId',
$type: 'bpmn:ScriptTask',
name: 'mockTaskName',
$attrs: {
'proceed:fileName': 'scriptFileName',
},
};

hookReturnValue = hook('mockProcess', 'mockInstance', 'mockTokenId', mockTask, {
mockStateEntry: 'mockStateValue',
});
});

it('logs that a new script task was encountered', async () => {
expect(mockEngine._log.info).toHaveBeenCalledTimes(1);
});

it('should inject the script into the script task', () => {
expect(mockTask).toStrictEqual({
...mockTask,
script: 'console.log("Hello Test");',
scriptFormat: 'application/javascript',
});
expect(db.getScript).toHaveBeenCalledWith(
mockEngine.definitionId,
mockTask.$attrs['proceed:fileName'],
);
});
});

describe('new call activity encountered', () => {
let mockRoot;
let mockTask;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:proceed="https://docs.proceed-labs.org/BPMN" id="_a04f4854-6e50-408f-8ec5-18f4541c32e9" name="OneProcess" targetNamespace="https://docs.proceed-labs.org/_a04f4854-6e50-408f-8ec5-18f4541c32e9" expressionLanguage="http://www.ecma-international.org/ecma-262/#sec-relational-operators" typeLanguage="https://www.ecma-international.org/publications/files/ECMA-ST/ECMA-404.pdf" exporter="PROCEED Management System" exporterVersion="0.0.1" proceed:creatorEnvironmentId="" proceed:creatorEnvironmentName="" proceed:version="123" xsi:schemaLocation="https://docs.proceed-labs.org/BPMN https://docs.proceed-labs.org/xsd/XSD-PROCEED.xsd http://www.omg.org/spec/BPMN/20100524/MODEL https://www.omg.org/spec/BPMN/20100501/BPMN20.xsd">
<Process id="_958fd9c3-b99d-4e8e-95a1-a0a618eaa9d3" name="PROCEED Main Process" processType="Private" isExecutable="true" proceed:deploymentMethod="dynamic">
<startEvent id="StartEvent_1">
<outgoing>Flow_0qukoq2</outgoing>
</startEvent>
<scriptTask id="Activity_1y9gs4q" proceed:fileName="Script_Task_1">
<incoming>Flow_0qukoq2</incoming>
<outgoing>Flow_15zy8v0</outgoing>
</scriptTask>
<sequenceFlow id="Flow_0qukoq2" sourceRef="StartEvent_1" targetRef="Activity_1y9gs4q" />
<endEvent id="Event_03n1qw2">
<incoming>Flow_15zy8v0</incoming>
</endEvent>
<sequenceFlow id="Flow_15zy8v0" sourceRef="Activity_1y9gs4q" targetRef="Event_03n1qw2" />
</Process>
</definitions>
Loading

0 comments on commit 0e0efc1

Please sign in to comment.