-
Notifications
You must be signed in to change notification settings - Fork 489
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a354d21
commit cbc64dc
Showing
38 changed files
with
2,551 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,184 @@ | ||
/** | ||
* Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH | ||
* under one or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information regarding copyright | ||
* ownership. | ||
* | ||
* Camunda licenses this file to you under the MIT; you may not use this file | ||
* except in compliance with the MIT License. | ||
*/ | ||
|
||
const path = require('path'); | ||
|
||
const FileContext = require('../file-context'); | ||
|
||
const { toFileUrl } = require('../util'); | ||
|
||
describe('FileContext', function() { | ||
|
||
let fileContext, waitFor; | ||
|
||
beforeEach(function() { | ||
fileContext = new FileContext(console); | ||
|
||
waitFor = createWaitFor(fileContext); | ||
}); | ||
|
||
afterEach(function() { | ||
return fileContext.close(); | ||
}); | ||
|
||
|
||
it('should watch by default', function() { | ||
|
||
// then | ||
expect(fileContext._watcher).to.exist; | ||
}); | ||
|
||
|
||
it('adding file', async function() { | ||
|
||
// given | ||
const filePath = path.resolve(__dirname, './fixtures/foo-process-application/foo.bpmn'); | ||
|
||
// when | ||
await waitFor(() => { | ||
fileContext.addFile(filePath); | ||
}); | ||
|
||
// then | ||
expectItems(fileContext, [ | ||
{ | ||
uri: toFileUrl(path.resolve(__dirname, './fixtures/foo-process-application/foo.bpmn')), | ||
localValue: undefined | ||
} | ||
]); | ||
}); | ||
|
||
|
||
it('adding file with local value', async function() { | ||
|
||
// given | ||
const filePath = path.resolve(__dirname, './fixtures/foo-process-application/foo.bpmn'); | ||
|
||
// when | ||
await waitFor(() => { | ||
fileContext.addFile(filePath, 'foo'); | ||
}); | ||
|
||
// then | ||
expectItems(fileContext, [ | ||
{ | ||
uri: toFileUrl(path.resolve(__dirname, './fixtures/foo-process-application/foo.bpmn')), | ||
localValue: 'foo' | ||
} | ||
]); | ||
}); | ||
|
||
|
||
it('removing file', async function() { | ||
|
||
// given | ||
const filePath = path.resolve(__dirname, './fixtures/foo-process-application/foo.bpmn'); | ||
|
||
// when | ||
await waitFor(() => { | ||
fileContext.addFile(filePath); | ||
}); | ||
|
||
// then | ||
expectItems(fileContext, [ | ||
{ | ||
uri: toFileUrl(path.resolve(__dirname, './fixtures/foo-process-application/foo.bpmn')), | ||
localValue: undefined | ||
} | ||
]); | ||
|
||
// when | ||
fileContext.removeFile(filePath); | ||
|
||
// then | ||
expectItems(fileContext, []); | ||
}); | ||
|
||
|
||
it('adding root', async function() { | ||
|
||
// given | ||
const directoryPath = path.resolve(__dirname, './fixtures/foo-process-application'); | ||
|
||
// when | ||
await waitFor(() => { | ||
fileContext.addRoot(directoryPath); | ||
}, 'watcher:ready'); | ||
|
||
// then | ||
expect(fileContext._indexer.getRoots()).to.have.length(1); | ||
|
||
expectItems(fileContext, [ | ||
{ | ||
uri: toFileUrl(path.resolve(__dirname, './fixtures/foo-process-application/.process-application')) | ||
}, | ||
{ | ||
uri: toFileUrl(path.resolve(__dirname, './fixtures/foo-process-application/foo.bpmn')) | ||
}, | ||
{ | ||
uri: toFileUrl(path.resolve(__dirname, './fixtures/foo-process-application/bar/bar.bpmn')) | ||
}, | ||
{ | ||
uri: toFileUrl(path.resolve(__dirname, './fixtures/foo-process-application/bar/baz/baz.dmn')) | ||
}, | ||
{ | ||
uri: toFileUrl(path.resolve(__dirname, './fixtures/foo-process-application/bar/baz/baz.form')) | ||
} | ||
]); | ||
}); | ||
|
||
|
||
it('removing root', async function() { | ||
|
||
// given | ||
const directoryPath = path.resolve(__dirname, './fixtures/foo-process-application'); | ||
|
||
// when | ||
await waitFor(() => { | ||
fileContext.addRoot(directoryPath); | ||
}, 'watcher:ready'); | ||
|
||
// then | ||
expect(fileContext._indexer.getRoots()).to.have.length(1); | ||
expect(fileContext._indexer.getItems()).to.have.length(5); | ||
|
||
// when | ||
fileContext.removeRoot(directoryPath); | ||
|
||
// then | ||
expect(fileContext._indexer.getRoots()).to.have.length(0); | ||
expect(fileContext._indexer.getItems()).to.have.length(5); | ||
}); | ||
|
||
}); | ||
|
||
function createWaitFor(fileContext) { | ||
return function waitFor(fn, event = 'workqueue:empty') { | ||
return new Promise((resolve) => { | ||
fileContext.on(event, resolve); | ||
|
||
fn(); | ||
}); | ||
}; | ||
} | ||
|
||
function expectItems(fileContext, expected) { | ||
const items = fileContext._indexer.getItems(); | ||
|
||
console.log('items', items.map(({ uri }) => uri)); | ||
|
||
expect(items).to.have.length(expected.length); | ||
|
||
expected.forEach((expectedItem, index) => { | ||
const item = items[ index ]; | ||
|
||
expect(item).to.include(expectedItem); | ||
}); | ||
} |
5 changes: 5 additions & 0 deletions
5
app/lib/file-context/__tests__/fixtures/foo-process-application/.process-application
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"name": "Foo process application", | ||
"executionPlatform": "camunda-cloud", | ||
"executionPlatformVersion": "8.2.0" | ||
} |
74 changes: 74 additions & 0 deletions
74
app/lib/file-context/__tests__/fixtures/foo-process-application/bar/bar.bpmn
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:zeebe="http://camunda.org/schema/zeebe/1.0" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:modeler="http://camunda.org/schema/modeler/1.0" id="Definitions_02yb3uy" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="5.29.0" modeler:executionPlatform="Camunda Cloud" modeler:executionPlatformVersion="8.6.0"> | ||
<bpmn:process id="BarProcess" isExecutable="true"> | ||
<bpmn:startEvent id="StartEvent_1"> | ||
<bpmn:outgoing>SequenceFlow_1</bpmn:outgoing> | ||
</bpmn:startEvent> | ||
<bpmn:callActivity id="CallActivity_1" name="⛓️💥 BazProcess"> | ||
<bpmn:extensionElements> | ||
<zeebe:calledElement processId="foobarProcess" propagateAllChildVariables="false" /> | ||
</bpmn:extensionElements> | ||
<bpmn:incoming>SequenceFlow_1</bpmn:incoming> | ||
<bpmn:outgoing>SequenceFlow_2</bpmn:outgoing> | ||
</bpmn:callActivity> | ||
<bpmn:sequenceFlow id="SequenceFlow_1" sourceRef="StartEvent_1" targetRef="CallActivity_1" /> | ||
<bpmn:businessRuleTask id="BusinessRuleTask_1" name="🔗 BazDecision"> | ||
<bpmn:extensionElements> | ||
<zeebe:calledDecision decisionId="BazDecision" /> | ||
</bpmn:extensionElements> | ||
<bpmn:incoming>SequenceFlow_2</bpmn:incoming> | ||
<bpmn:outgoing>SequenceFlow_3</bpmn:outgoing> | ||
</bpmn:businessRuleTask> | ||
<bpmn:sequenceFlow id="SequenceFlow_2" sourceRef="CallActivity_1" targetRef="BusinessRuleTask_1" /> | ||
<bpmn:userTask id="UserTask_1" name="🔗 BazForm"> | ||
<bpmn:extensionElements> | ||
<zeebe:formDefinition formId="BazForm" /> | ||
</bpmn:extensionElements> | ||
<bpmn:incoming>SequenceFlow_3</bpmn:incoming> | ||
<bpmn:outgoing>SequenceFlow_4</bpmn:outgoing> | ||
</bpmn:userTask> | ||
<bpmn:sequenceFlow id="SequenceFlow_3" sourceRef="BusinessRuleTask_1" targetRef="UserTask_1" /> | ||
<bpmn:endEvent id="EndEvent_1"> | ||
<bpmn:incoming>SequenceFlow_4</bpmn:incoming> | ||
</bpmn:endEvent> | ||
<bpmn:sequenceFlow id="SequenceFlow_4" sourceRef="UserTask_1" targetRef="EndEvent_1" /> | ||
</bpmn:process> | ||
<bpmndi:BPMNDiagram id="BPMNDiagram_1"> | ||
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="BarProcess"> | ||
<bpmndi:BPMNShape id="StartEvent_1_di" bpmnElement="StartEvent_1"> | ||
<dc:Bounds x="182" y="102" width="36" height="36" /> | ||
</bpmndi:BPMNShape> | ||
<bpmndi:BPMNShape id="Activity_1mxe379_di" bpmnElement="CallActivity_1"> | ||
<dc:Bounds x="270" y="80" width="100" height="80" /> | ||
<bpmndi:BPMNLabel /> | ||
</bpmndi:BPMNShape> | ||
<bpmndi:BPMNShape id="Activity_0eww9ui_di" bpmnElement="BusinessRuleTask_1"> | ||
<dc:Bounds x="430" y="80" width="100" height="80" /> | ||
<bpmndi:BPMNLabel /> | ||
</bpmndi:BPMNShape> | ||
<bpmndi:BPMNShape id="Activity_0j8c113_di" bpmnElement="UserTask_1"> | ||
<dc:Bounds x="590" y="80" width="100" height="80" /> | ||
<bpmndi:BPMNLabel /> | ||
</bpmndi:BPMNShape> | ||
<bpmndi:BPMNShape id="Event_0su2pxh_di" bpmnElement="EndEvent_1"> | ||
<dc:Bounds x="752" y="102" width="36" height="36" /> | ||
</bpmndi:BPMNShape> | ||
<bpmndi:BPMNEdge id="Flow_09jbfzj_di" bpmnElement="SequenceFlow_1"> | ||
<di:waypoint x="218" y="120" /> | ||
<di:waypoint x="270" y="120" /> | ||
</bpmndi:BPMNEdge> | ||
<bpmndi:BPMNEdge id="Flow_17tcdik_di" bpmnElement="SequenceFlow_2"> | ||
<di:waypoint x="370" y="120" /> | ||
<di:waypoint x="430" y="120" /> | ||
</bpmndi:BPMNEdge> | ||
<bpmndi:BPMNEdge id="Flow_1cc3bdo_di" bpmnElement="SequenceFlow_3"> | ||
<di:waypoint x="530" y="120" /> | ||
<di:waypoint x="590" y="120" /> | ||
</bpmndi:BPMNEdge> | ||
<bpmndi:BPMNEdge id="Flow_0nulbx3_di" bpmnElement="SequenceFlow_4"> | ||
<di:waypoint x="690" y="120" /> | ||
<di:waypoint x="752" y="120" /> | ||
</bpmndi:BPMNEdge> | ||
</bpmndi:BPMNPlane> | ||
</bpmndi:BPMNDiagram> | ||
</bpmn:definitions> |
Empty file.
36 changes: 36 additions & 0 deletions
36
app/lib/file-context/__tests__/fixtures/foo-process-application/bar/baz/baz.dmn
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<definitions xmlns="https://www.omg.org/spec/DMN/20191111/MODEL/" xmlns:dmndi="https://www.omg.org/spec/DMN/20191111/DMNDI/" xmlns:dc="http://www.omg.org/spec/DMN/20180521/DC/" xmlns:modeler="http://camunda.org/schema/modeler/1.0" xmlns:di="http://www.omg.org/spec/DMN/20180521/DI/" id="Definitions_1" name="DRD" namespace="http://camunda.org/schema/1.0/dmn" exporter="Camunda Modeler" exporterVersion="5.29.0" modeler:executionPlatform="Camunda Cloud" modeler:executionPlatformVersion="8.6.0"> | ||
<decision id="BarDecision" name="BarDecision" /> | ||
<decision id="BazDecision" name="BazDecision" /> | ||
<decision id="FooDecision" name="FooDecision"> | ||
<informationRequirement id="InformationRequirement_1"> | ||
<requiredDecision href="#BarDecision" /> | ||
</informationRequirement> | ||
<informationRequirement id="InformationRequirement_2"> | ||
<requiredDecision href="#BazDecision" /> | ||
</informationRequirement> | ||
</decision> | ||
<dmndi:DMNDI> | ||
<dmndi:DMNDiagram> | ||
<dmndi:DMNShape id="DMNShape_0qlx3z0" dmnElementRef="BarDecision"> | ||
<dc:Bounds height="80" width="180" x="160" y="320" /> | ||
</dmndi:DMNShape> | ||
<dmndi:DMNEdge id="DMNEdge_1dt83fp" dmnElementRef="InformationRequirement_1"> | ||
<di:waypoint x="250" y="320" /> | ||
<di:waypoint x="220" y="200" /> | ||
<di:waypoint x="220" y="180" /> | ||
</dmndi:DMNEdge> | ||
<dmndi:DMNShape id="DMNShape_006ex9i" dmnElementRef="BazDecision"> | ||
<dc:Bounds height="80" width="180" x="400" y="320" /> | ||
</dmndi:DMNShape> | ||
<dmndi:DMNEdge id="DMNEdge_17q9z9t" dmnElementRef="InformationRequirement_2"> | ||
<di:waypoint x="490" y="320" /> | ||
<di:waypoint x="280" y="200" /> | ||
<di:waypoint x="280" y="180" /> | ||
</dmndi:DMNEdge> | ||
<dmndi:DMNShape id="DMNShape_12apazx" dmnElementRef="FooDecision"> | ||
<dc:Bounds height="80" width="180" x="160" y="100" /> | ||
</dmndi:DMNShape> | ||
</dmndi:DMNDiagram> | ||
</dmndi:DMNDI> | ||
</definitions> |
52 changes: 52 additions & 0 deletions
52
app/lib/file-context/__tests__/fixtures/foo-process-application/bar/baz/baz.form
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
{ | ||
"components": [ | ||
{ | ||
"text": "# BazForm", | ||
"type": "text", | ||
"layout": { | ||
"row": "Row_1l1cdcl", | ||
"columns": null | ||
}, | ||
"id": "Field_05plz1j" | ||
}, | ||
{ | ||
"label": "Text field", | ||
"type": "textfield", | ||
"layout": { | ||
"row": "Row_1m6rjof", | ||
"columns": null | ||
}, | ||
"id": "Field_1spc3pd", | ||
"key": "textfield_obha1" | ||
}, | ||
{ | ||
"label": "Text area", | ||
"type": "textarea", | ||
"layout": { | ||
"row": "Row_0sblw61", | ||
"columns": null | ||
}, | ||
"id": "Field_0swxobm", | ||
"key": "textarea_g3hy67" | ||
}, | ||
{ | ||
"label": "Number", | ||
"type": "number", | ||
"layout": { | ||
"row": "Row_0y94u98", | ||
"columns": null | ||
}, | ||
"id": "Field_0fk8rvs", | ||
"key": "number_k6z07b" | ||
} | ||
], | ||
"type": "default", | ||
"id": "BazForm", | ||
"executionPlatform": "Camunda Cloud", | ||
"executionPlatformVersion": "8.6.0", | ||
"exporter": { | ||
"name": "Camunda Modeler", | ||
"version": "5.29.0" | ||
}, | ||
"schemaVersion": 17 | ||
} |
Oops, something went wrong.