|
| 1 | +import { replayFixture } from './util/replayFixture'; |
| 2 | + |
| 3 | +import serviceTaskSuccess from './fixtures/integration/service-task-success.json'; |
| 4 | +import serviceTaskIncident from './fixtures/integration/service-task-incident.json'; |
| 5 | +import subprocessWithChildren from './fixtures/integration/subprocess-with-children.json'; |
| 6 | +import eventSubprocess from './fixtures/integration/event-subprocess.json'; |
| 7 | +import userTaskWaiting from './fixtures/integration/user-task-waiting.json'; |
| 8 | +import boundaryEventTriggered from './fixtures/integration/boundary-event-triggered.json'; |
| 9 | +import scriptTask from './fixtures/integration/script-task.json'; |
| 10 | + |
| 11 | + |
| 12 | +/** |
| 13 | + * Fixture-based smoke tests — verify that real Camunda API response shapes |
| 14 | + * are compatible with ExecutionLog without throwing. |
| 15 | + * |
| 16 | + * Behavioral assertions (upsert, state transitions, display filtering, child |
| 17 | + * scoping) live in ExecutionLog.spec.js using controlled data. |
| 18 | + */ |
| 19 | +describe('ExecutionLog - integration', function() { |
| 20 | + |
| 21 | + const allFixtures = [ |
| 22 | + { name: 'service-task-success', fixture: serviceTaskSuccess }, |
| 23 | + { name: 'service-task-incident', fixture: serviceTaskIncident }, |
| 24 | + { name: 'subprocess-with-children', fixture: subprocessWithChildren }, |
| 25 | + { name: 'event-subprocess', fixture: eventSubprocess }, |
| 26 | + { name: 'user-task-waiting', fixture: userTaskWaiting }, |
| 27 | + { name: 'boundary-event-triggered', fixture: boundaryEventTriggered }, |
| 28 | + { name: 'script-task', fixture: scriptTask } |
| 29 | + ]; |
| 30 | + |
| 31 | + |
| 32 | + describe('all fixtures', function() { |
| 33 | + |
| 34 | + for (const { name, fixture } of allFixtures) { |
| 35 | + |
| 36 | + it(`should replay ${ name } without throwing`, function() { |
| 37 | + const { log } = replayFixture(fixture); |
| 38 | + |
| 39 | + expect(log.getEntries()).to.be.an('array'); |
| 40 | + expect(log.getDisplayEntries()).to.be.an('array'); |
| 41 | + expect(log.isFinished()).to.be.a('boolean'); |
| 42 | + }); |
| 43 | + } |
| 44 | + }); |
| 45 | + |
| 46 | + |
| 47 | + describe('field shape compatibility', function() { |
| 48 | + |
| 49 | + it('should read job fields from real API response (service-task-success)', function() { |
| 50 | + const { log } = replayFixture(serviceTaskSuccess); |
| 51 | + |
| 52 | + const job = log.getEntries().find(e => e.type === 'job'); |
| 53 | + expect(job).to.exist; |
| 54 | + expect(job.data).to.have.property('jobKey'); |
| 55 | + expect(job.data).to.have.property('type'); |
| 56 | + expect(job.data).to.have.property('processInstanceKey'); |
| 57 | + expect(job.data).to.have.property('elementId'); |
| 58 | + expect(job.data).to.have.property('elementInstanceKey'); |
| 59 | + expect(job.data).to.have.property('state'); |
| 60 | + expect(job.data).to.have.property('retries'); |
| 61 | + expect(job.data).to.have.property('creationTime'); |
| 62 | + expect(job.data).to.have.property('worker'); |
| 63 | + expect(job.data).to.have.property('customHeaders'); |
| 64 | + }); |
| 65 | + |
| 66 | + it('should read error fields from real API response (service-task-incident)', function() { |
| 67 | + const { log } = replayFixture(serviceTaskIncident); |
| 68 | + |
| 69 | + const job = log.getEntries().find(e => e.type === 'job'); |
| 70 | + expect(job).to.exist; |
| 71 | + expect(job.data).to.have.property('errorMessage'); |
| 72 | + expect(job.data).to.have.property('errorCode'); |
| 73 | + expect(job.data.retries).to.equal(0); |
| 74 | + }); |
| 75 | + |
| 76 | + it('should read element instance fields from real API response (subprocess-with-children)', function() { |
| 77 | + const { log } = replayFixture(subprocessWithChildren); |
| 78 | + |
| 79 | + const entry = log.getEntries().find(e => e.type === 'element-instance'); |
| 80 | + expect(entry).to.exist; |
| 81 | + expect(entry.data).to.have.property('elementInstanceKey'); |
| 82 | + expect(entry.data).to.have.property('processInstanceKey'); |
| 83 | + expect(entry.data).to.have.property('elementId'); |
| 84 | + expect(entry.data).to.have.property('type'); |
| 85 | + expect(entry.data).to.have.property('state'); |
| 86 | + expect(entry.data).to.have.property('startDate'); |
| 87 | + }); |
| 88 | + |
| 89 | + it('should read user task fields from real API response (user-task-waiting)', function() { |
| 90 | + const { log } = replayFixture(userTaskWaiting); |
| 91 | + |
| 92 | + const userTask = log.getEntries().find(e => e.type === 'user-task'); |
| 93 | + expect(userTask).to.exist; |
| 94 | + expect(userTask.data).to.have.property('userTaskKey'); |
| 95 | + expect(userTask.data).to.have.property('state'); |
| 96 | + expect(userTask.data).to.have.property('assignee'); |
| 97 | + expect(userTask.data).to.have.property('candidateGroups'); |
| 98 | + expect(userTask.data).to.have.property('candidateUsers'); |
| 99 | + expect(userTask.data).to.have.property('elementId'); |
| 100 | + expect(userTask.data).to.have.property('creationDate'); |
| 101 | + expect(userTask.data).to.have.property('priority'); |
| 102 | + }); |
| 103 | + |
| 104 | + describe('script-task', function() { |
| 105 | + |
| 106 | + it('should be finished', function() { |
| 107 | + const { log } = replayFixture(scriptTask); |
| 108 | + expect(log.isFinished()).to.be.true; |
| 109 | + }); |
| 110 | + |
| 111 | + it('should produce no job entries — script tasks complete without a worker', function() { |
| 112 | + const { log } = replayFixture(scriptTask); |
| 113 | + expect(log.getEntries().filter(e => e.type === 'job')).to.have.length(0); |
| 114 | + }); |
| 115 | + |
| 116 | + it('should read element instance fields from real API response', function() { |
| 117 | + |
| 118 | + // replay without elementId so ScriptTask_1 is NOT filtered out |
| 119 | + const { log } = replayFixture(scriptTask, { elementId: '__none__' }); |
| 120 | + const entry = log.getEntries().find(e => e.type === 'element-instance'); |
| 121 | + expect(entry).to.exist; |
| 122 | + expect(entry.data).to.have.property('elementInstanceKey'); |
| 123 | + expect(entry.data).to.have.property('processInstanceKey'); |
| 124 | + expect(entry.data).to.have.property('elementId'); |
| 125 | + expect(entry.data).to.have.property('type'); |
| 126 | + expect(entry.data).to.have.property('state'); |
| 127 | + expect(entry.data).to.have.property('startDate'); |
| 128 | + expect(entry.data).to.have.property('endDate'); |
| 129 | + expect(entry.data.state).to.equal('COMPLETED'); |
| 130 | + expect(entry.data.type).to.equal('SCRIPT_TASK'); |
| 131 | + }); |
| 132 | + }); |
| 133 | + }); |
| 134 | +}); |
| 135 | + |
0 commit comments