-
Notifications
You must be signed in to change notification settings - Fork 36
fix: correctly ignore activity and task label bounds #3434
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 7 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
b6f4d82
fix: correctly ignore activity and task label bounds
tbouffard d15f92f
Merge branch 'master' into fix/correctly_ignore_activity_label_bounds
tbouffard 76f1225
add comment [skip ci]
tbouffard 9d91b5c
isLabelBoundsIgnored: simplify implementation
tbouffard 98601bd
BpmnRenderer.test.ts: inline constants to simplify
tbouffard 6340d9f
BpmnRenderer.test.ts: fix test name
tbouffard 82edffd
Merge branch 'master' into fix/correctly_ignore_activity_label_bounds
tbouffard ee6b9cf
diagram: prevent wrapping of the edge label to limit discrepancies be…
tbouffard 08ce45c
update thresholds
tbouffard 6257ee9
simplify config and snapshot files reorg
tbouffard b999416
update thresholds based on the result of GH Actions
tbouffard 4e36a89
fix lint errors
tbouffard 171c6b6
Merge branch 'master' into fix/correctly_ignore_activity_label_bounds
tbouffard 51b0dd7
Merge branch 'master' into fix/correctly_ignore_activity_label_bounds
tbouffard 828cc0f
Merge branch 'master' into fix/correctly_ignore_activity_label_bounds
tbouffard File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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
Binary file added
BIN
+27.8 KB
...-rendering-ignore-options/ignored/activities.with.wrongly.positioned.labels.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+14.8 KB
...e_snapshots__/bpmn-rendering-ignore-options/ignored/labels.with.font.styles.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+29.5 KB
...dering-ignore-options/not-ignored/activities.with.wrongly.positioned.labels.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+14.6 KB
...apshots__/bpmn-rendering-ignore-options/not-ignored/labels.with.font.styles.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or 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,138 @@ | ||
| /* | ||
| Copyright 2025 Bonitasoft S.A. | ||
|
|
||
| Licensed under the Apache License, Version 2.0 (the "License"); | ||
| you may not use this file except in compliance with the License. | ||
| You may obtain a copy of the License at | ||
|
|
||
| http://www.apache.org/licenses/LICENSE-2.0 | ||
|
|
||
| Unless required by applicable law or agreed to in writing, software | ||
| distributed under the License is distributed on an "AS IS" BASIS, | ||
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| See the License for the specific language governing permissions and | ||
| limitations under the License. | ||
| */ | ||
|
|
||
| import type { ImageSnapshotThresholdConfig } from './helpers/visu/image-snapshot-config'; | ||
|
|
||
| import { ImageSnapshotConfigurator, MultiBrowserImageSnapshotThresholds } from './helpers/visu/image-snapshot-config'; | ||
|
|
||
| import { AvailableTestPages, PageTester } from '@test/shared/visu/bpmn-page-utils'; | ||
|
|
||
| class ImageSnapshotThresholdsActivityLabelBounds extends MultiBrowserImageSnapshotThresholds { | ||
| constructor() { | ||
| super({ chromium: 0 / 100, firefox: 0 / 100, webkit: 0 / 100 }); | ||
| } | ||
|
|
||
| protected override getChromiumThresholds(): Map<string, ImageSnapshotThresholdConfig> { | ||
| return new Map<string, ImageSnapshotThresholdConfig>(); | ||
| } | ||
|
|
||
| protected override getFirefoxThresholds(): Map<string, ImageSnapshotThresholdConfig> { | ||
| return new Map<string, ImageSnapshotThresholdConfig>(); | ||
| } | ||
|
|
||
| protected override getWebkitThresholds(): Map<string, ImageSnapshotThresholdConfig> { | ||
| return new Map<string, ImageSnapshotThresholdConfig>(); | ||
| } | ||
| } | ||
|
|
||
| class ImageSnapshotThresholdsActivityLabelBoundsIgnored extends MultiBrowserImageSnapshotThresholds { | ||
| constructor() { | ||
| super({ chromium: 0 / 100, firefox: 0 / 100, webkit: 0 / 100 }); | ||
| } | ||
|
|
||
| protected override getChromiumThresholds(): Map<string, ImageSnapshotThresholdConfig> { | ||
| return new Map<string, ImageSnapshotThresholdConfig>(); | ||
| } | ||
|
|
||
| protected override getFirefoxThresholds(): Map<string, ImageSnapshotThresholdConfig> { | ||
| return new Map<string, ImageSnapshotThresholdConfig>(); | ||
| } | ||
|
|
||
| protected override getWebkitThresholds(): Map<string, ImageSnapshotThresholdConfig> { | ||
| return new Map<string, ImageSnapshotThresholdConfig>(); | ||
| } | ||
| } | ||
|
|
||
| class ImageSnapshotThresholdsLabelStyles extends MultiBrowserImageSnapshotThresholds { | ||
| constructor() { | ||
| super({ chromium: 0 / 100, firefox: 0 / 100, webkit: 0 / 100 }); | ||
| } | ||
|
|
||
| protected override getChromiumThresholds(): Map<string, ImageSnapshotThresholdConfig> { | ||
| return new Map<string, ImageSnapshotThresholdConfig>(); | ||
| } | ||
|
|
||
| protected override getFirefoxThresholds(): Map<string, ImageSnapshotThresholdConfig> { | ||
| return new Map<string, ImageSnapshotThresholdConfig>(); | ||
| } | ||
|
|
||
| protected override getWebkitThresholds(): Map<string, ImageSnapshotThresholdConfig> { | ||
| return new Map<string, ImageSnapshotThresholdConfig>(); | ||
| } | ||
| } | ||
|
|
||
| class ImageSnapshotThresholdsLabelStylesIgnored extends MultiBrowserImageSnapshotThresholds { | ||
| constructor() { | ||
| super({ chromium: 0 / 100, firefox: 0 / 100, webkit: 0 / 100 }); | ||
| } | ||
|
|
||
| protected override getChromiumThresholds(): Map<string, ImageSnapshotThresholdConfig> { | ||
| return new Map<string, ImageSnapshotThresholdConfig>(); | ||
| } | ||
|
|
||
| protected override getFirefoxThresholds(): Map<string, ImageSnapshotThresholdConfig> { | ||
| return new Map<string, ImageSnapshotThresholdConfig>(); | ||
| } | ||
|
|
||
| protected override getWebkitThresholds(): Map<string, ImageSnapshotThresholdConfig> { | ||
| return new Map<string, ImageSnapshotThresholdConfig>(); | ||
| } | ||
| } | ||
|
|
||
| describe('BPMN rendering - ignore options', () => { | ||
| const diagramSubfolder = 'bpmn-rendering-ignore-options'; | ||
| const pageTester = new PageTester({ targetedPage: AvailableTestPages.BPMN_RENDERING, diagramSubfolder }, page); | ||
|
|
||
| describe('Ignore activity label bounds', () => { | ||
| const bpmnDiagramName = 'activities.with.wrongly.positioned.labels'; | ||
|
|
||
| describe.each([false, true])('ignoreBpmnActivityLabelBounds: %s', (ignoreBpmnActivityLabelBounds: boolean) => { | ||
| const imageSnapshotConfigurator = ignoreBpmnActivityLabelBounds | ||
| ? new ImageSnapshotConfigurator(new ImageSnapshotThresholdsActivityLabelBoundsIgnored(), 'bpmn-rendering-ignore-options/ignored') | ||
| : new ImageSnapshotConfigurator(new ImageSnapshotThresholdsActivityLabelBounds(), 'bpmn-rendering-ignore-options/not-ignored'); | ||
|
|
||
| it(`${bpmnDiagramName}`, async () => { | ||
| await pageTester.gotoPageAndLoadBpmnDiagram(bpmnDiagramName, { | ||
| rendererIgnoreBpmnActivityLabelBounds: ignoreBpmnActivityLabelBounds, | ||
| }); | ||
|
|
||
| const image = await page.screenshot({ fullPage: true }); | ||
| const config = imageSnapshotConfigurator.getConfig(bpmnDiagramName); | ||
| expect(image).toMatchImageSnapshot(config); | ||
| }); | ||
| }); | ||
| }); | ||
|
|
||
| describe('Ignore label styles', () => { | ||
| const bpmnDiagramName = 'labels.with.font.styles'; | ||
|
|
||
| describe.each([false, true])('ignoreBpmnLabelStyles: %s', (ignoreBpmnLabelStyles: boolean) => { | ||
| const imageSnapshotConfigurator = ignoreBpmnLabelStyles | ||
| ? new ImageSnapshotConfigurator(new ImageSnapshotThresholdsLabelStylesIgnored(), 'bpmn-rendering-ignore-options/ignored') | ||
| : new ImageSnapshotConfigurator(new ImageSnapshotThresholdsLabelStyles(), 'bpmn-rendering-ignore-options/not-ignored'); | ||
|
|
||
| it(`${bpmnDiagramName}`, async () => { | ||
| await pageTester.gotoPageAndLoadBpmnDiagram(bpmnDiagramName, { | ||
| rendererIgnoreBpmnLabelStyles: ignoreBpmnLabelStyles, | ||
| }); | ||
|
|
||
| const image = await page.screenshot({ fullPage: true }); | ||
| const config = imageSnapshotConfigurator.getConfig(bpmnDiagramName); | ||
| expect(image).toMatchImageSnapshot(config); | ||
| }); | ||
| }); | ||
| }); | ||
| }); | ||
49 changes: 49 additions & 0 deletions
49
...ixtures/bpmn/bpmn-rendering-ignore-options/activities.with.wrongly.positioned.labels.bpmn
This file contains hidden or 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,49 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <bpmn:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 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" id="Definitions_wrongly_positioned_labels" targetNamespace="http://example.bpmn.com/schema/bpmn"> | ||
| <bpmn:process id="Process_1" isExecutable="false"> | ||
| <bpmn:task id="Task_1" name="Task with label too high" /> | ||
| <bpmn:userTask id="UserTask_1" name="User Task partly outside" /> | ||
| <bpmn:serviceTask id="ServiceTask_1" name="Service Task label out of bounds" /> | ||
| <bpmn:callActivity id="CallActivity_1" name="Call Activity top right" calledElement="global_task" /> | ||
| <bpmn:subProcess id="SubProcess_1" name="SubProcess bottom left"> | ||
| <bpmn:task id="InnerTask_1" /> | ||
| </bpmn:subProcess> | ||
| </bpmn:process> | ||
| <bpmndi:BPMNDiagram id="BPMNDiagram_1"> | ||
| <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_1"> | ||
| <bpmndi:BPMNShape id="Task_1_di" bpmnElement="Task_1"> | ||
| <dc:Bounds x="160" y="80" width="100" height="80" /> | ||
| <bpmndi:BPMNLabel> | ||
| <dc:Bounds x="160" y="80" width="100" height="30" /> | ||
| </bpmndi:BPMNLabel> | ||
| </bpmndi:BPMNShape> | ||
| <bpmndi:BPMNShape id="UserTask_1_di" bpmnElement="UserTask_1"> | ||
| <dc:Bounds x="320" y="80" width="100" height="80" /> | ||
| <bpmndi:BPMNLabel> | ||
| <dc:Bounds x="320" y="65" width="100" height="40" /> | ||
| </bpmndi:BPMNLabel> | ||
| </bpmndi:BPMNShape> | ||
| <bpmndi:BPMNShape id="ServiceTask_1_di" bpmnElement="ServiceTask_1"> | ||
| <dc:Bounds x="470" y="80" width="100" height="80" /> | ||
| <bpmndi:BPMNLabel> | ||
| <dc:Bounds x="510" y="140" width="100" height="50" /> | ||
| </bpmndi:BPMNLabel> | ||
| </bpmndi:BPMNShape> | ||
| <bpmndi:BPMNShape id="CallActivity_1_di" bpmnElement="CallActivity_1" isExpanded="true"> | ||
| <dc:Bounds x="160" y="220" width="140" height="100" /> | ||
| <bpmndi:BPMNLabel> | ||
| <dc:Bounds x="220" y="225" width="80" height="25" /> | ||
| </bpmndi:BPMNLabel> | ||
| </bpmndi:BPMNShape> | ||
| <bpmndi:BPMNShape id="SubProcess_1_di" bpmnElement="SubProcess_1" isExpanded="true"> | ||
| <dc:Bounds x="360" y="200" width="250" height="150" /> | ||
| <bpmndi:BPMNLabel> | ||
| <dc:Bounds x="365" y="320" width="120" height="25" /> | ||
| </bpmndi:BPMNLabel> | ||
| </bpmndi:BPMNShape> | ||
| <bpmndi:BPMNShape id="InnerTask_1_di" bpmnElement="InnerTask_1"> | ||
| <dc:Bounds x="430" y="250" width="100" height="60" /> | ||
| </bpmndi:BPMNShape> | ||
| </bpmndi:BPMNPlane> | ||
| </bpmndi:BPMNDiagram> | ||
| </bpmn:definitions> |
34 changes: 34 additions & 0 deletions
34
test/fixtures/bpmn/bpmn-rendering-ignore-options/labels.with.font.styles.bpmn
This file contains hidden or 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,34 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <bpmn:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 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:di="http://www.omg.org/spec/DD/20100524/DI" id="Definitions_labels_font_styles" targetNamespace="http://example.bpmn.com/schema/bpmn"> | ||
| <bpmn:process id="Process_1" isExecutable="false"> | ||
| <bpmn:task id="Task_1" name="Source Task"> | ||
| <bpmn:outgoing>Flow_1</bpmn:outgoing> | ||
| </bpmn:task> | ||
| <bpmn:task id="Task_2" name="Target Task"> | ||
| <bpmn:incoming>Flow_1</bpmn:incoming> | ||
| </bpmn:task> | ||
| <bpmn:sequenceFlow id="Flow_1" name="Bold and Underline" sourceRef="Task_1" targetRef="Task_2" /> | ||
| </bpmn:process> | ||
| <bpmndi:BPMNDiagram id="BPMNDiagram_1"> | ||
| <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_1"> | ||
| <bpmndi:BPMNShape id="Task_1_di" bpmnElement="Task_1"> | ||
| <dc:Bounds x="160" y="100" width="100" height="80" /> | ||
| <bpmndi:BPMNLabel labelStyle="BPMNLabelStyle_bold_underline" /> | ||
| </bpmndi:BPMNShape> | ||
| <bpmndi:BPMNShape id="Task_2_di" bpmnElement="Task_2"> | ||
| <dc:Bounds x="400" y="100" width="100" height="80" /> | ||
| <bpmndi:BPMNLabel labelStyle="BPMNLabelStyle_bold_underline" /> | ||
| </bpmndi:BPMNShape> | ||
| <bpmndi:BPMNEdge id="Flow_1_di" bpmnElement="Flow_1"> | ||
| <di:waypoint x="260" y="140" /> | ||
| <di:waypoint x="400" y="140" /> | ||
| <bpmndi:BPMNLabel labelStyle="BPMNLabelStyle_bold_underline"> | ||
| <dc:Bounds x="290" y="115" width="100" height="14" /> | ||
| </bpmndi:BPMNLabel> | ||
| </bpmndi:BPMNEdge> | ||
| </bpmndi:BPMNPlane> | ||
| <bpmndi:BPMNLabelStyle id="BPMNLabelStyle_bold_underline"> | ||
| <dc:Font name="Times,sans-serif" isBold="true" isItalic="false" isUnderline="true" isStrikeThrough="false" /> | ||
|
tbouffard marked this conversation as resolved.
|
||
| </bpmndi:BPMNLabelStyle> | ||
| </bpmndi:BPMNDiagram> | ||
| </bpmn:definitions> | ||
This file contains hidden or 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 hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.