diff --git a/test/e2e/ExpectModelUtils.ts b/test/e2e/ExpectModelUtils.ts index 0a5ae8f36c..32435a1ac0 100644 --- a/test/e2e/ExpectModelUtils.ts +++ b/test/e2e/ExpectModelUtils.ts @@ -18,7 +18,7 @@ import { FlowKind } from '../../src/model/bpmn/internal/edge/FlowKind'; import { MessageVisibleKind } from '../../src/model/bpmn/internal/edge/MessageVisibleKind'; import { SequenceFlowKind } from '../../src/model/bpmn/internal/edge/SequenceFlowKind'; import BpmnVisualization from '../../src/component/BpmnVisualization'; -import { toBeCell, withGeometry, withFont, toBeSequenceFlow, toBeMessageFlow, toBeAssociationFlow, toBeShape } from './matchers'; +import { toBeCell, withGeometry, withFont, toBeSequenceFlow, toBeMessageFlow, toBeAssociationFlow, toBeShape, toBeCallActivity } from './matchers'; declare global { // eslint-disable-next-line @typescript-eslint/no-namespace @@ -31,6 +31,7 @@ declare global { toBeMessageFlow(modelElement: ExpectedEdgeModelElement): R; toBeAssociationFlow(modelElement: ExpectedEdgeModelElement): R; toBeShape(modelElement: ExpectedShapeModelElement): R; + toBeCallActivity(modelElement: ExpectedShapeModelElement): R; } } } @@ -43,6 +44,7 @@ expect.extend({ toBeMessageFlow, toBeAssociationFlow, toBeShape, + toBeCallActivity, }); export interface ExpectedFont { @@ -56,7 +58,7 @@ export interface ExpectedFont { export interface ExpectedShapeModelElement { label?: string; - kind: ShapeBpmnElementKind; + kind?: ShapeBpmnElementKind; font?: ExpectedFont; parentId?: string; /** Only needed when the BPMN shape doesn't exist yet (use an arbitrary shape until the final render is implemented) */ diff --git a/test/e2e/matchers/index.ts b/test/e2e/matchers/index.ts index 4675d79360..4833dcb309 100644 --- a/test/e2e/matchers/index.ts +++ b/test/e2e/matchers/index.ts @@ -14,7 +14,7 @@ * limitations under the License. */ export { toBeSequenceFlow, toBeMessageFlow, toBeAssociationFlow } from './toBeEdge'; -export { toBeShape } from './toBeShape'; +export { toBeShape, toBeCallActivity } from './toBeShape'; export { toBeCell } from './toBeCell'; export { withGeometry } from './withGeometry'; export { withFont } from './withFont'; diff --git a/test/e2e/matchers/toBeCell/index.ts b/test/e2e/matchers/toBeCell/index.ts index 1848321518..de112eba27 100644 --- a/test/e2e/matchers/toBeCell/index.ts +++ b/test/e2e/matchers/toBeCell/index.ts @@ -44,26 +44,23 @@ export function buildCellMatcher( const cell = getCell(received); if (!cell) { - const pass = !matcherContext.isNot; - const message = - utils.matcherHint(matcherName, undefined, undefined, options) + '\n\n' + pass - ? () => `${EXPECTED_LABEL}: ${cellKind} with id '${received}' not to be found` - : () => utils.printDiffOrStringify(expectedCell, undefined, `${EXPECTED_LABEL}: ${cellKind} with id '${expectedCell.id}'`, `${RECEIVED_LABEL}`, expand); - return { message, pass }; + const message = (): string => + utils.matcherHint(matcherName, undefined, undefined, options) + + '\n\n' + + utils.printDiffOrStringify(expectedCell, undefined, `${EXPECTED_LABEL}: ${cellKind} with id '${expectedCell.id}'`, `${RECEIVED_LABEL}`, expand); + return { message, pass: false }; } const receivedCell: ExpectedCell = buildReceivedCell(cell); const pass = matcherContext.equals(receivedCell, expectedCell, [utils.iterableEquality, utils.subsetEquality]); - const message = - utils.matcherHint(matcherName, undefined, undefined, options) + '\n\n' + pass - ? () => `${EXPECTED_LABEL}: ${cellKind} with id '${received}' not to be found with the configuration:\n` + `${utils.printExpected(expectedCell)}` - : () => - utils.printDiffOrStringify( - expectedCell, - receivedCell, - `${EXPECTED_LABEL}: ${cellKind} with id '${expectedCell.id}'`, - `${RECEIVED_LABEL}: ${cellKind} with id '${received}'`, - expand, - ); - return { message, pass }; + const messageEnd = pass + ? `${EXPECTED_LABEL}: ${cellKind} with id '${received}' not to be found with the configuration:\n` + `${utils.printExpected(expectedCell)}` + : utils.printDiffOrStringify( + expectedCell, + receivedCell, + `${EXPECTED_LABEL}: ${cellKind} with id '${expectedCell.id}'`, + `${RECEIVED_LABEL}: ${cellKind} with id '${received}'`, + expand, + ); + return { message: () => utils.matcherHint(matcherName, undefined, undefined, options) + '\n\n' + messageEnd, pass }; } diff --git a/test/e2e/matchers/toBeShape/index.ts b/test/e2e/matchers/toBeShape/index.ts index 016af62353..0d4ff04966 100644 --- a/test/e2e/matchers/toBeShape/index.ts +++ b/test/e2e/matchers/toBeShape/index.ts @@ -18,6 +18,7 @@ import MatcherContext = jest.MatcherContext; import CustomMatcherResult = jest.CustomMatcherResult; import { ExpectedShapeModelElement, getDefaultParentId } from '../../ExpectModelUtils'; import { buildCellMatcher } from '../toBeCell'; +import { ShapeBpmnElementKind } from '../../../../src/model/bpmn/internal/shape'; function buildExpectedStateStyle(expectedModel: ExpectedShapeModelElement): ExpectedStateStyle { const expectedStateStyle = buildCommonExpectedStateStyle(expectedModel); @@ -60,3 +61,7 @@ function buildExpectedCell(id: string, expectedModel: ExpectedShapeModelElement) export function toBeShape(this: MatcherContext, received: string, expected: ExpectedShapeModelElement): CustomMatcherResult { return buildCellMatcher('toBeShape', this, received, expected, 'Shape', buildExpectedCell); } + +export function toBeCallActivity(this: MatcherContext, received: string, expected: ExpectedShapeModelElement): CustomMatcherResult { + return buildCellMatcher('toBeCallActivity', this, received, { ...expected, kind: ShapeBpmnElementKind.CALL_ACTIVITY }, 'Shape', buildExpectedCell); +} diff --git a/test/e2e/mxGraph.model.test.ts b/test/e2e/mxGraph.model.test.ts index a43a212829..a3386e1b86 100644 --- a/test/e2e/mxGraph.model.test.ts +++ b/test/e2e/mxGraph.model.test.ts @@ -682,28 +682,24 @@ describe('mxGraph model', () => { // Call Activity calling process // Expanded - expect('expanded_call_activity_id').toBeShape({ - kind: ShapeBpmnElementKind.CALL_ACTIVITY, + expect('expanded_call_activity_id').toBeCallActivity({ label: 'Expanded Call Activity', parentId: 'participant_1_id', verticalAlign: 'top', }); - expect('expanded_call_activity_with_loop_id').toBeShape({ - kind: ShapeBpmnElementKind.CALL_ACTIVITY, + expect('expanded_call_activity_with_loop_id').toBeCallActivity({ label: 'Expanded Call Activity With Loop', markers: [ShapeBpmnMarkerKind.LOOP], parentId: 'participant_1_id', verticalAlign: 'top', }); - expect('expanded_call_activity_with_sequential_multi_instance_id').toBeShape({ - kind: ShapeBpmnElementKind.CALL_ACTIVITY, + expect('expanded_call_activity_with_sequential_multi_instance_id').toBeCallActivity({ label: 'Expanded Call Activity With Sequential Multi-instance', markers: [ShapeBpmnMarkerKind.MULTI_INSTANCE_SEQUENTIAL], parentId: 'participant_1_id', verticalAlign: 'top', }); - expect('expanded_call_activity_with_parallel_multi_instance_id').toBeShape({ - kind: ShapeBpmnElementKind.CALL_ACTIVITY, + expect('expanded_call_activity_with_parallel_multi_instance_id').toBeCallActivity({ label: 'Expanded Call Activity With Parallel Multi-instance', markers: [ShapeBpmnMarkerKind.MULTI_INSTANCE_PARALLEL], parentId: 'participant_1_id', @@ -711,26 +707,22 @@ describe('mxGraph model', () => { }); // Collapsed - expect('collapsed_call_activity_id').toBeShape({ - kind: ShapeBpmnElementKind.CALL_ACTIVITY, + expect('collapsed_call_activity_id').toBeCallActivity({ label: 'Collapsed Call Activity', parentId: 'participant_1_id', verticalAlign: 'top', }); - expect('collapsed_call_activity_with_loop_id').toBeShape({ - kind: ShapeBpmnElementKind.CALL_ACTIVITY, + expect('collapsed_call_activity_with_loop_id').toBeCallActivity({ label: 'Collapsed Call Activity With Loop', markers: [ShapeBpmnMarkerKind.LOOP, ShapeBpmnMarkerKind.EXPAND], parentId: 'participant_1_id', }); - expect('collapsed_call_activity_with_sequential_multi_instance_id').toBeShape({ - kind: ShapeBpmnElementKind.CALL_ACTIVITY, + expect('collapsed_call_activity_with_sequential_multi_instance_id').toBeCallActivity({ label: 'Collapsed Call Activity With Sequential Multi-instance', markers: [ShapeBpmnMarkerKind.MULTI_INSTANCE_SEQUENTIAL, ShapeBpmnMarkerKind.EXPAND], parentId: 'participant_1_id', }); - expect('collapsed_call_activity_with_parallel_multi_instance_id').toBeShape({ - kind: ShapeBpmnElementKind.CALL_ACTIVITY, + expect('collapsed_call_activity_with_parallel_multi_instance_id').toBeCallActivity({ label: 'Collapsed Call Activity With Parallel Multi-instance', markers: [ShapeBpmnMarkerKind.MULTI_INSTANCE_PARALLEL, ShapeBpmnMarkerKind.EXPAND], parentId: 'participant_1_id',