Skip to content

Commit

Permalink
fix!: generate correct CSS class name for adhoc subprocess (#3058)
Browse files Browse the repository at this point in the history
The CSS class name associated to the adhoc subprocess was incorrect. It
was `bpmn-sub-process-ad_hoc` instead of `bpmn-sub-process-adhoc`.

The tests checking the CSS class names were incorrectly written. Test
inputs used hard coded string instead of the actual value of the various
enum entries. So, they were unable to detect the problem.

BREAKING CHANGES:
- The CSS class name associated to the adhoc subprocess in the DOM have
changed. It was `bpmn-sub-process-ad_hoc` and it is now
`bpmn-sub-process-adhoc`. CSS rules and selectors must be updated
accordingly.
- The value of `ShapeBpmnSubProcessKind.AD_HOC` changed. As it is not
intended to be used directly, no one should be impacted.
  • Loading branch information
tbouffard authored Mar 25, 2024
1 parent 37cff37 commit f608382
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 28 deletions.
2 changes: 1 addition & 1 deletion src/model/bpmn/internal/shape/kinds.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ export enum ShapeBpmnMarkerKind {
* @category BPMN
*/
export enum ShapeBpmnSubProcessKind {
AD_HOC = 'ad_hoc',
AD_HOC = 'adhoc',
EMBEDDED = 'embedded',
EVENT = 'event',
TRANSACTION = 'transaction',
Expand Down
54 changes: 27 additions & 27 deletions test/unit/component/mxgraph/renderer/style-utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ limitations under the License.
*/

import { computeBpmnBaseClassName, computeAllBpmnClassNames } from '@lib/component/mxgraph/renderer/style-utils';
import { FlowKind, ShapeBpmnElementKind } from '@lib/model/bpmn/internal';
import { FlowKind, SequenceFlowKind, ShapeBpmnElementKind, ShapeBpmnEventBasedGatewayKind, ShapeBpmnEventDefinitionKind, ShapeBpmnSubProcessKind } from '@lib/model/bpmn/internal';

describe('compute base css class names of BPMN elements', () => {
it.each`
Expand Down Expand Up @@ -44,32 +44,32 @@ describe('compute base css class names of BPMN elements', () => {

describe('compute all css class names based on style input', () => {
it.each`
style | isLabel | expectedClassNames
${ShapeBpmnElementKind.LANE} | ${true} | ${['bpmn-type-container', 'bpmn-lane', 'bpmn-label']}
${ShapeBpmnElementKind.POOL} | ${false} | ${['bpmn-type-container', 'bpmn-pool']}
${ShapeBpmnElementKind.CALL_ACTIVITY} | ${false} | ${['bpmn-type-activity', 'bpmn-call-activity']}
${'callActivity;bpmn.globalTaskKind=globalTask'} | ${false} | ${['bpmn-type-activity', 'bpmn-call-activity', 'bpmn-global-task']}
${'callActivity;bpmn.globalTaskKind=globalManualTask'} | ${true} | ${['bpmn-type-activity', 'bpmn-call-activity', 'bpmn-global-manual-task', 'bpmn-label']}
${ShapeBpmnElementKind.EVENT_BOUNDARY} | ${true} | ${['bpmn-type-event', 'bpmn-boundary-event', 'bpmn-label']}
${'boundaryEvent;bpmn.eventDefinitionKind=cancel;bpmn.isInterrupting=true'} | ${true} | ${['bpmn-type-event', 'bpmn-boundary-event', 'bpmn-event-def-cancel', 'bpmn-label']}
${ShapeBpmnElementKind.EVENT_INTERMEDIATE_THROW} | ${false} | ${['bpmn-type-event', 'bpmn-intermediate-throw-event']}
${'startEvent;bpmn.eventDefinitionKind=timer;bpmn.isInterrupting=false;fontStyle=2'} | ${false} | ${['bpmn-type-event', 'bpmn-start-event', 'bpmn-event-def-timer']}
${ShapeBpmnElementKind.GATEWAY_EVENT_BASED} | ${true} | ${['bpmn-type-gateway', 'bpmn-event-based-gateway', 'bpmn-label']}
${'eventBasedGateway;bpmn.isInstantiating=true;bpmn.gatewayKind=Parallel'} | ${false} | ${['bpmn-type-gateway', 'bpmn-event-based-gateway', 'bpmn-gateway-kind-parallel']}
${ShapeBpmnElementKind.GATEWAY_EXCLUSIVE} | ${true} | ${['bpmn-type-gateway', 'bpmn-exclusive-gateway', 'bpmn-label']}
${ShapeBpmnElementKind.TASK} | ${true} | ${['bpmn-type-activity', 'bpmn-type-task', 'bpmn-task', 'bpmn-label']}
${ShapeBpmnElementKind.TASK_BUSINESS_RULE} | ${false} | ${['bpmn-type-activity', 'bpmn-type-task', 'bpmn-business-rule-task']}
${ShapeBpmnElementKind.SUB_PROCESS} | ${false} | ${['bpmn-type-activity', 'bpmn-sub-process']}
${'subProcess;bpmn.subProcessKind=adHoc'} | ${true} | ${['bpmn-type-activity', 'bpmn-sub-process', 'bpmn-sub-process-adhoc', 'bpmn-label']}
${'subProcess;bpmn.subProcessKind=embedded'} | ${false} | ${['bpmn-type-activity', 'bpmn-sub-process', 'bpmn-sub-process-embedded']}
${'subProcess;bpmn.subProcessKind=event'} | ${true} | ${['bpmn-type-activity', 'bpmn-sub-process', 'bpmn-sub-process-event', 'bpmn-label']}
${'subProcess;bpmn.subProcessKind=transaction'} | ${true} | ${['bpmn-type-activity', 'bpmn-sub-process', 'bpmn-sub-process-transaction', 'bpmn-label']}
${FlowKind.ASSOCIATION_FLOW} | ${true} | ${['bpmn-type-flow', 'bpmn-association', 'bpmn-label']}
${FlowKind.MESSAGE_FLOW} | ${false} | ${['bpmn-type-flow', 'bpmn-message-flow']}
${'sequenceFlow;default;fontStyle=4'} | ${false} | ${['bpmn-type-flow', 'bpmn-sequence-flow']}
${'shape=bpmn.message-flow-icon'} | ${false} | ${['bpmn-message-flow-icon']}
${'shape=bpmn.message-flow-icon;bpmn.isInitiating=false'} | ${false} | ${['bpmn-message-flow-icon', 'bpmn-icon-non-initiating']}
${'shape=bpmn.message-flow-icon;bpmn.isInitiating=true'} | ${true} | ${['bpmn-message-flow-icon', 'bpmn-icon-initiating', 'bpmn-label']}
style | isLabel | expectedClassNames
${ShapeBpmnElementKind.LANE} | ${true} | ${['bpmn-type-container', 'bpmn-lane', 'bpmn-label']}
${ShapeBpmnElementKind.POOL} | ${false} | ${['bpmn-type-container', 'bpmn-pool']}
${ShapeBpmnElementKind.CALL_ACTIVITY} | ${false} | ${['bpmn-type-activity', 'bpmn-call-activity']}
${`${ShapeBpmnElementKind.CALL_ACTIVITY};bpmn.globalTaskKind=${ShapeBpmnElementKind.GLOBAL_TASK}`} | ${false} | ${['bpmn-type-activity', 'bpmn-call-activity', 'bpmn-global-task']}
${`${ShapeBpmnElementKind.CALL_ACTIVITY};bpmn.globalTaskKind=${ShapeBpmnElementKind.GLOBAL_TASK_MANUAL}`} | ${true} | ${['bpmn-type-activity', 'bpmn-call-activity', 'bpmn-global-manual-task', 'bpmn-label']}
${ShapeBpmnElementKind.EVENT_BOUNDARY} | ${true} | ${['bpmn-type-event', 'bpmn-boundary-event', 'bpmn-label']}
${`${ShapeBpmnElementKind.EVENT_BOUNDARY};bpmn.eventDefinitionKind=${ShapeBpmnEventDefinitionKind.CANCEL};bpmn.isInterrupting=true`} | ${true} | ${['bpmn-type-event', 'bpmn-boundary-event', 'bpmn-event-def-cancel', 'bpmn-label']}
${ShapeBpmnElementKind.EVENT_INTERMEDIATE_THROW} | ${false} | ${['bpmn-type-event', 'bpmn-intermediate-throw-event']}
${`${ShapeBpmnElementKind.EVENT_START};bpmn.eventDefinitionKind=${ShapeBpmnEventDefinitionKind.TIMER};bpmn.isInterrupting=false;fontStyle=2`} | ${false} | ${['bpmn-type-event', 'bpmn-start-event', 'bpmn-event-def-timer']}
${ShapeBpmnElementKind.GATEWAY_EVENT_BASED} | ${true} | ${['bpmn-type-gateway', 'bpmn-event-based-gateway', 'bpmn-label']}
${`${ShapeBpmnElementKind.GATEWAY_EVENT_BASED};bpmn.isInstantiating=true;bpmn.gatewayKind=${ShapeBpmnEventBasedGatewayKind.Parallel}`} | ${false} | ${['bpmn-type-gateway', 'bpmn-event-based-gateway', 'bpmn-gateway-kind-parallel']}
${ShapeBpmnElementKind.GATEWAY_EXCLUSIVE} | ${true} | ${['bpmn-type-gateway', 'bpmn-exclusive-gateway', 'bpmn-label']}
${ShapeBpmnElementKind.TASK} | ${true} | ${['bpmn-type-activity', 'bpmn-type-task', 'bpmn-task', 'bpmn-label']}
${ShapeBpmnElementKind.TASK_BUSINESS_RULE} | ${false} | ${['bpmn-type-activity', 'bpmn-type-task', 'bpmn-business-rule-task']}
${ShapeBpmnElementKind.SUB_PROCESS} | ${false} | ${['bpmn-type-activity', 'bpmn-sub-process']}
${`${ShapeBpmnElementKind.SUB_PROCESS};bpmn.subProcessKind=${ShapeBpmnSubProcessKind.AD_HOC}`} | ${true} | ${['bpmn-type-activity', 'bpmn-sub-process', 'bpmn-sub-process-adhoc', 'bpmn-label']}
${`${ShapeBpmnElementKind.SUB_PROCESS};bpmn.subProcessKind=${ShapeBpmnSubProcessKind.EMBEDDED}`} | ${false} | ${['bpmn-type-activity', 'bpmn-sub-process', 'bpmn-sub-process-embedded']}
${`${ShapeBpmnElementKind.SUB_PROCESS};bpmn.subProcessKind=${ShapeBpmnSubProcessKind.EVENT}`} | ${true} | ${['bpmn-type-activity', 'bpmn-sub-process', 'bpmn-sub-process-event', 'bpmn-label']}
${`${ShapeBpmnElementKind.SUB_PROCESS};bpmn.subProcessKind=${ShapeBpmnSubProcessKind.TRANSACTION}`} | ${true} | ${['bpmn-type-activity', 'bpmn-sub-process', 'bpmn-sub-process-transaction', 'bpmn-label']}
${FlowKind.ASSOCIATION_FLOW} | ${true} | ${['bpmn-type-flow', 'bpmn-association', 'bpmn-label']}
${FlowKind.MESSAGE_FLOW} | ${false} | ${['bpmn-type-flow', 'bpmn-message-flow']}
${`${FlowKind.SEQUENCE_FLOW};${SequenceFlowKind.DEFAULT};fontStyle=4`} | ${false} | ${['bpmn-type-flow', 'bpmn-sequence-flow']}
${'shape=bpmn.message-flow-icon'} | ${false} | ${['bpmn-message-flow-icon']}
${'shape=bpmn.message-flow-icon;bpmn.isInitiating=false'} | ${false} | ${['bpmn-message-flow-icon', 'bpmn-icon-non-initiating']}
${'shape=bpmn.message-flow-icon;bpmn.isInitiating=true'} | ${true} | ${['bpmn-message-flow-icon', 'bpmn-icon-initiating', 'bpmn-label']}
`('style="$style" / isLabel=$isLabel', ({ style, isLabel, expectedClassNames }: { style: string; isLabel: boolean; expectedClassNames: string[] }) => {
expect(computeAllBpmnClassNames(style, isLabel)).toEqual(expectedClassNames);
});
Expand Down

0 comments on commit f608382

Please sign in to comment.