Skip to content

Commit f645c38

Browse files
barmacclaude
andcommitted
test: address review feedback on drag-and-drop regression tests
- DropZoneSpec: spy on the real Event.prototype.stopPropagation instead of relying only on document-level bubbling, since MockDragEvent's own stopPropagation is never actually invoked by fireEvent (it only reads known DragEvent init properties) - DmnEditorPage#dragRule: wait for the handle/row and fail with a clear error instead of crashing on a null boundingBox() - dmn-modeling.spec: assert both rule ids are present in the saved XML before comparing their positions, so a missing rule can't produce a false pass Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
1 parent 21f1707 commit f645c38

3 files changed

Lines changed: 26 additions & 1 deletion

File tree

client/src/app/drop-zone/__tests__/DropZoneSpec.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,11 +165,18 @@ describe('<DropZone>', function() {
165165
// `document`; this drop zone wraps that tree and must let such events
166166
// bubble on past it rather than swallowing them
167167
// (https://github.com/camunda/camunda-modeler/issues/6166)
168+
//
169+
// `fireEvent.drop` builds a real native DragEvent from `MockDragEvent`
170+
// (used only as a property bag — its own no-op `stopPropagation` is
171+
// never actually invoked), so this spies on the real `Event.prototype`
172+
// method rather than on the mock, and independently confirms the event
173+
// still reaches a `document`-level listener, i.e. it truly bubbles
168174

169175
// given — a listener above the zone's own React root, mirroring where
170176
// dmn-js's own drag-and-drop handling lives in the real app
171177
const { dropzone } = renderDropZone();
172178

179+
const stopPropagationSpy = sinon.spy(window.Event.prototype, 'stopPropagation');
173180
const outerDropSpy = sinon.spy();
174181

175182
document.addEventListener('drop', outerDropSpy);
@@ -180,9 +187,11 @@ describe('<DropZone>', function() {
180187
fireEvent.drop(dropzone, new MockDragEvent());
181188

182189
// then
190+
expect(stopPropagationSpy).to.have.not.been.called;
183191
expect(outerDropSpy).to.have.been.calledOnce;
184192
} finally {
185193
document.removeEventListener('drop', outerDropSpy);
194+
stopPropagationSpy.restore();
186195
}
187196

188197
});

test/e2e/pages/DmnEditorPage.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,9 +130,20 @@ class DmnEditorPage extends DiagramEditorPage {
130130
const handle = this.page.locator(`[data-row-id="${ ruleId }"] .dmn-icon-drag.vertical`);
131131
const targetRow = this.page.locator(`[data-row-id="${ targetRuleId }"]`).first();
132132

133+
await handle.waitFor();
134+
await targetRow.waitFor();
135+
133136
const handleBox = await handle.boundingBox();
134137
const targetBox = await targetRow.boundingBox();
135138

139+
if (!handleBox) {
140+
throw new Error(`could not determine the drag handle position for rule "${ ruleId }"`);
141+
}
142+
143+
if (!targetBox) {
144+
throw new Error(`could not determine the row position for rule "${ targetRuleId }"`);
145+
}
146+
136147
const startX = handleBox.x + handleBox.width / 2;
137148
const startY = handleBox.y + handleBox.height / 2;
138149

test/e2e/specs/dmn-modeling.spec.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,12 @@ test.describe('DMN modeling', function() {
360360

361361
const xml = await readFile(output);
362362

363-
expect(xml.indexOf('id="Rule_2"')).toBeLessThan(xml.indexOf('id="Rule_1"'));
363+
const rule1Index = xml.indexOf('id="Rule_1"');
364+
const rule2Index = xml.indexOf('id="Rule_2"');
365+
366+
expect(rule1Index).toBeGreaterThan(-1);
367+
expect(rule2Index).toBeGreaterThan(-1);
368+
expect(rule2Index).toBeLessThan(rule1Index);
364369
});
365370
});
366371

0 commit comments

Comments
 (0)