Skip to content

Commit

Permalink
Add snapshot test vor all new bpmn components
Browse files Browse the repository at this point in the history
  • Loading branch information
matthiaslehnertum committed Oct 7, 2023
1 parent 7864c42 commit e7f187a
Show file tree
Hide file tree
Showing 33 changed files with 782 additions and 32 deletions.
2 changes: 1 addition & 1 deletion src/main/packages/bpmn/bpmn-end-event/bpmn-end-event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { IBoundary } from '../../../utils/geometry/boundary';
import { UMLElementType } from '../../uml-element-type';

export class BPMNEndEvent extends UMLElement {
static supportedRelationships = [BPMNRelationshipType.BPMNSequenceFlow];
static supportedRelationships = [BPMNRelationshipType.BPMNFlow];
static features: UMLElementFeatures = { ...UMLElement.features, resizable: false };

type: UMLElementType = BPMNElementType.BPMNEndEvent;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import React, { FunctionComponent } from 'react';
import { Point } from '../../../utils/geometry/point';
import { BPMNSequenceFlow } from './bpmn-sequence-flow';
import { BPMNFlow } from './bpmn-flow';
import { ThemedCircle, ThemedPath, ThemedPolyline } from '../../../components/theme/themedComponents';

export const BPMNSequenceFlowComponent: FunctionComponent<Props> = ({ element }) => {
export const BPMNFlowComponent: FunctionComponent<Props> = ({ element }) => {
let position = { x: 0, y: 0 };
let direction: 'vertical' | 'horizontal' = 'vertical';
const path = element.path.map((point) => new Point(point.x, point.y));
Expand Down Expand Up @@ -86,5 +86,5 @@ export const BPMNSequenceFlowComponent: FunctionComponent<Props> = ({ element })
};

interface Props {
element: BPMNSequenceFlow;
element: BPMNFlow;
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,14 @@ import { styled } from '../../../components/theme/styles';
import { UMLElementRepository } from '../../../services/uml-element/uml-element-repository';
import { ExchangeIcon } from '../../../components/controls/icon/exchange';
import { UMLRelationshipRepository } from '../../../services/uml-relationship/uml-relationship-repository';
import { BPMNFlowType, BPMNSequenceFlow } from './bpmn-sequence-flow';
import { BPMNFlowType, BPMNFlow } from './bpmn-flow';
import { ColorButton } from '../../../components/controls/color-button/color-button';
import { StylePane } from '../../../components/style-pane/style-pane';
import { Dropdown } from '../../../components/controls/dropdown/dropdown';
import { BPMNFlow } from '../../../typings';
import { Divider } from '../../../components/controls/divider/divider';

interface OwnProps {
element: BPMNSequenceFlow;
element: BPMNFlow;
}

type StateProps = {};
Expand Down Expand Up @@ -49,7 +48,7 @@ const Flex = styled.div`

type State = { colorOpen: boolean };

class BPMNSequenceFlowUpdateComponent extends Component<Props, State> {
class BPMNFlowUpdateComponent extends Component<Props, State> {
state = { colorOpen: false };

private toggleColor = () => {
Expand Down Expand Up @@ -113,4 +112,4 @@ class BPMNSequenceFlowUpdateComponent extends Component<Props, State> {
};
}

export const BPMNSequenceFlowUpdate = enhance(BPMNSequenceFlowUpdateComponent);
export const BPMNFlowUpdate = enhance(BPMNFlowUpdateComponent);
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,22 @@ import { DeepPartial } from 'redux';
import { UMLRelationshipCenteredDescription } from '../../../services/uml-relationship/uml-relationship-centered-description';
import { UMLElement } from '../../../services/uml-element/uml-element';
import * as Apollon from '../../../typings';
import { BPMNFlow } from '../../../typings';

export type BPMNFlowType = 'sequence' | 'message' | 'association';

export class BPMNSequenceFlow extends UMLRelationshipCenteredDescription {
export class BPMNFlow extends UMLRelationshipCenteredDescription {
static features = { ...UMLRelationship.features };
static defaultFlowType: BPMNFlowType = 'sequence';

type = BPMNRelationshipType.BPMNSequenceFlow;
type = BPMNRelationshipType.BPMNFlow;
name = '';

flowType: BPMNFlowType;

constructor(values?: DeepPartial<BPMNFlow>) {
constructor(values?: DeepPartial<Apollon.BPMNFlow>) {
super(values);
this.name = values?.name || this.name;
this.flowType = values?.flowType || BPMNSequenceFlow.defaultFlowType;
this.flowType = values?.flowType || BPMNFlow.defaultFlowType;
}

serialize(children?: UMLElement[]): Apollon.BPMNFlow {
Expand All @@ -36,6 +35,6 @@ export class BPMNSequenceFlow extends UMLRelationshipCenteredDescription {
children?: Apollon.UMLModelElement[],
) {
super.deserialize(values, children);
this.flowType = values.flowType || BPMNSequenceFlow.defaultFlowType;
this.flowType = values.flowType || BPMNFlow.defaultFlowType;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { IBoundary } from '../../../utils/geometry/boundary';
import { UMLElementType } from '../../uml-element-type';

export class BPMNIntermediateEvent extends UMLElement {
static supportedRelationships = [BPMNRelationshipType.BPMNSequenceFlow];
static supportedRelationships = [BPMNRelationshipType.BPMNFlow];
static features: UMLElementFeatures = { ...UMLElement.features, resizable: false };

type: UMLElementType = BPMNElementType.BPMNIntermediateEvent;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { IBoundary } from '../../../utils/geometry/boundary';
import { UMLElementType } from '../../uml-element-type';

export class BPMNStartEvent extends UMLElement {
static supportedRelationships = [BPMNRelationshipType.BPMNSequenceFlow];
static supportedRelationships = [BPMNRelationshipType.BPMNFlow];
static features: UMLElementFeatures = { ...UMLElement.features, resizable: false };

type: UMLElementType = BPMNElementType.BPMNStartEvent;
Expand Down
4 changes: 2 additions & 2 deletions src/main/packages/bpmn/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { BPMNSequenceFlow } from './bpmn-squence-flow/bpmn-sequence-flow';
import { BPMNFlow } from './bpmn-flow/bpmn-flow';

export const BPMNElementType = {
BPMNTask: 'BPMNTask',
Expand All @@ -14,5 +14,5 @@ export const BPMNElementType = {
} as const;

export const BPMNRelationshipType = {
BPMNSequenceFlow: 'BPMNSequenceFlow',
BPMNFlow: 'BPMNFlow',
} as const;
12 changes: 6 additions & 6 deletions src/main/packages/components.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,17 @@ import { FlowchartDecisionComponent } from './flowchart/flowchart-decision/flowc
import { FlowchartFunctionCallComponent } from './flowchart/flowchart-function-call/flowchart-function-call-component';
import { FlowchartInputOutputComponent } from './flowchart/flowchart-input-output/flowchart-input-output-component';
import { ColorLegendComponent } from './common/color-legend/color-legend-component';
import { BPMNSequenceFlowComponent } from './bpmn/bpmn-squence-flow/bpmn-sequence-flow-component';
import { BPMNFlowComponent } from './bpmn/bpmn-flow/bpmn-flow-component';
import { BPMNTaskComponent } from './bpmn/bpmn-task/bpmn-task-component';
import { BPMNSubprocessComponent } from './bpmn/bpmn-subprocess/bpmn-subprocess-component';
import { BPMNStartEventComponent } from './bpmn/bpmn-start-event/bpmn-start-event-component';
import { BPMNIntermediateEventComponent } from './bpmn/bpmn-intermediate-event/bpmn-intermediate-event-component';
import { BPMNEndEventComponent } from './bpmn/bpmn-end-event/bpmn-end-event-component';
import { BPMNGatewayComponent } from './bpmn/bpmn-gateway/bpmn-gateway-component';
import {BPMNTransactionComponent} from './bpmn/bpmn-transaction/bpmn-transaction-component';
import {BPMNCallActivityComponent} from './bpmn/bpmn-call-activity/bpmn-call-activity-component';
import {BPMNAnnotationComponent} from './bpmn/bpmn-annotation/bpmn-annotation-component';
import {BPMNConversationComponent} from './bpmn/bpmn-conversation/bpmn-conversation-component';
import { BPMNTransactionComponent } from './bpmn/bpmn-transaction/bpmn-transaction-component';
import { BPMNCallActivityComponent } from './bpmn/bpmn-call-activity/bpmn-call-activity-component';
import { BPMNAnnotationComponent } from './bpmn/bpmn-annotation/bpmn-annotation-component';
import { BPMNConversationComponent } from './bpmn/bpmn-conversation/bpmn-conversation-component';

export const Components: {
[key in UMLElementType | UMLRelationshipType]:
Expand Down Expand Up @@ -138,5 +138,5 @@ export const Components: {
[UMLRelationshipType.ReachabilityGraphArc]: UMLReachabilityGraphArcComponent,
[UMLRelationshipType.SyntaxTreeLink]: SyntaxTreeLinkComponent,
[UMLRelationshipType.FlowchartFlowline]: FlowchartFlowlineComponent,
[UMLRelationshipType.BPMNSequenceFlow]: BPMNSequenceFlowComponent,
[UMLRelationshipType.BPMNFlow]: BPMNFlowComponent,
};
8 changes: 4 additions & 4 deletions src/main/packages/popups.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ import { FlowchartFunctionCallUpdate } from './flowchart/flowchart-function-call
import { FlowchartInputOutputUpdate } from './flowchart/flowchart-input-output/flowchart-input-output-update';
import { FlowchartFlowlineUpdate } from './flowchart/flowchart-flowline/flowchart-flowline-update';
import { ColorLegendUpdate } from './common/color-legend/color-legend-update';
import { BPMNSequenceFlowUpdate } from './bpmn/bpmn-squence-flow/bpmn-sequence-flow-update';
import {BPMNGatewayUpdate} from './bpmn/bpmn-gateway/bpmn-gateway-update';
import {BPMNConversationUpdate} from './bpmn/bpmn-conversation/bpmn-conversation-update';
import { BPMNFlowUpdate } from './bpmn/bpmn-flow/bpmn-flow-update';
import { BPMNGatewayUpdate } from './bpmn/bpmn-gateway/bpmn-gateway-update';
import { BPMNConversationUpdate } from './bpmn/bpmn-conversation/bpmn-conversation-update';

export type Popups = { [key in UMLElementType | UMLRelationshipType]: ComponentType<{ element: any }> | null };
export const Popups: { [key in UMLElementType | UMLRelationshipType]: ComponentType<{ element: any }> | null } = {
Expand Down Expand Up @@ -108,5 +108,5 @@ export const Popups: { [key in UMLElementType | UMLRelationshipType]: ComponentT
[UMLRelationshipType.ReachabilityGraphArc]: UMLReachabilityGraphArcUpdate,
[UMLRelationshipType.SyntaxTreeLink]: DefaultRelationshipPopup,
[UMLRelationshipType.FlowchartFlowline]: FlowchartFlowlineUpdate,
[UMLRelationshipType.BPMNSequenceFlow]: BPMNSequenceFlowUpdate,
[UMLRelationshipType.BPMNFlow]: BPMNFlowUpdate,
};
2 changes: 1 addition & 1 deletion src/main/packages/uml-relationship-type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,5 @@ export const DefaultUMLRelationshipType: { [key in UMLDiagramType]: UMLRelations
[UMLDiagramType.ReachabilityGraph]: ReachabilityGraphRelationshipType.ReachabilityGraphArc,
[UMLDiagramType.SyntaxTree]: SyntaxTreeRelationshipType.SyntaxTreeLink,
[UMLDiagramType.Flowchart]: FlowchartRelationshipType.FlowchartFlowline,
[UMLDiagramType.BPMN]: BPMNRelationshipType.BPMNSequenceFlow,
[UMLDiagramType.BPMN]: BPMNRelationshipType.BPMNFlow,
};
4 changes: 2 additions & 2 deletions src/main/packages/uml-relationships.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import { UMLPetriNetArc } from './uml-petri-net/uml-petri-net-arc/uml-petri-net-
import { UMLReachabilityGraphArc } from './uml-reachability-graph/uml-reachability-graph-arc/uml-reachability-graph-arc';
import { SyntaxTreeLink } from './syntax-tree/syntax-tree-link/syntax-tree-link';
import { FlowchartFlowline } from './flowchart/flowchart-flowline/flowchart-flowline';
import { BPMNSequenceFlow } from './bpmn/bpmn-squence-flow/bpmn-sequence-flow';
import { BPMNFlow } from './bpmn/bpmn-flow/bpmn-flow';

type UMLRelationships = { [key in UMLRelationshipType]: new (values?: IUMLRelationship) => UMLRelationship };

Expand Down Expand Up @@ -55,5 +55,5 @@ export const UMLRelationships = {
[UMLRelationshipType.ReachabilityGraphArc]: UMLReachabilityGraphArc,
[UMLRelationshipType.SyntaxTreeLink]: SyntaxTreeLink,
[UMLRelationshipType.FlowchartFlowline]: FlowchartFlowline,
[UMLRelationshipType.BPMNSequenceFlow]: BPMNSequenceFlow,
[UMLRelationshipType.BPMNFlow]: BPMNFlow,
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`render the bpmn-annotation-component 1`] = `
<body>
<div>
<svg>
<g>
<rect
class="sc-fqkvVR joPxif"
fill="transparent"
height="100"
rx="10"
ry="10"
stroke="transparent"
width="200"
/>
<path
class="sc-gEvEer JpXgg"
d="M20,0 L10,0 A 10 10 280 0 0 0 10 L0,90 A 10 10 180 0 0 10 100 L20, 100"
fill="transparent"
stroke="black"
/>
<text
font-weight="bold"
height="100"
pointer-events="none"
text-anchor="middle"
width="200"
x="100"
y="50"
>
<tspan
dy="5.5"
x="100"
>
Annotation
</tspan>
</text>
</g>
</svg>
</div>
</body>
`;
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { wrappedRender } from '../../../test-utils/render';
import * as React from 'react';
import { SyntaxTreeTerminal } from '../../../../../main/packages/syntax-tree/syntax-tree-terminal/syntax-tree-terminal';
import { SyntaxTreeTerminalComponent } from '../../../../../main/packages/syntax-tree/syntax-tree-terminal/syntax-tree-terminal-component';
import { Multiline } from '../../../../../main/utils/svg/multiline';
import { CSSProperties } from 'react';
import { BPMNAnnotation } from '../../../../../main/packages/bpmn/bpmn-annotation/bpmn-annotation';
import { BPMNAnnotationComponent } from '../../../../../main/packages/bpmn/bpmn-annotation/bpmn-annotation-component';

// override getStringWidth, because it uses by jsdom unsupported SVGElement methods
Multiline.prototype.getStringWidth = (str: string, style?: CSSProperties) => {
return 0;
};

it('render the bpmn-annotation-component', () => {
const annotation: BPMNAnnotation = new BPMNAnnotation({ name: 'Annotation' });
const { getByText, baseElement } = wrappedRender(
<svg>
<BPMNAnnotationComponent element={annotation} />
</svg>,
);
expect(getByText(annotation.name)).toBeInTheDocument();
expect(baseElement).toMatchSnapshot();
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`render the bpmn-call-activity-component 1`] = `
<body>
<div>
<svg>
<g>
<rect
class="sc-fqkvVR kprGcp"
fill="white"
height="100"
rx="10"
ry="10"
stroke="black"
stroke-width="3"
width="200"
/>
<text
font-weight="bold"
height="100"
pointer-events="none"
text-anchor="middle"
width="200"
x="100"
y="50"
>
<tspan
dy="5.5"
x="100"
>
Call Activity
</tspan>
</text>
</g>
</svg>
</div>
</body>
`;
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { wrappedRender } from '../../../test-utils/render';
import * as React from 'react';
import { SyntaxTreeTerminal } from '../../../../../main/packages/syntax-tree/syntax-tree-terminal/syntax-tree-terminal';
import { SyntaxTreeTerminalComponent } from '../../../../../main/packages/syntax-tree/syntax-tree-terminal/syntax-tree-terminal-component';
import { Multiline } from '../../../../../main/utils/svg/multiline';
import { CSSProperties } from 'react';
import { BPMNAnnotation } from '../../../../../main/packages/bpmn/bpmn-annotation/bpmn-annotation';
import { BPMNAnnotationComponent } from '../../../../../main/packages/bpmn/bpmn-annotation/bpmn-annotation-component';
import { BPMNCallActivity } from '../../../../../main/packages/bpmn/bpmn-call-activity/bpmn-call-activity';
import { BPMNCallActivityComponent } from '../../../../../main/packages/bpmn/bpmn-call-activity/bpmn-call-activity-component';

// override getStringWidth, because it uses by jsdom unsupported SVGElement methods
Multiline.prototype.getStringWidth = (str: string, style?: CSSProperties) => {
return 0;
};

it('render the bpmn-call-activity-component', () => {
const callActivity: BPMNCallActivity = new BPMNCallActivity({ name: 'Call Activity' });
const { getByText, baseElement } = wrappedRender(
<svg>
<BPMNCallActivityComponent element={callActivity} />
</svg>,
);
expect(getByText(callActivity.name)).toBeInTheDocument();
expect(baseElement).toMatchSnapshot();
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`render the bpmn-conversation-component 1`] = `
<body>
<div>
<svg>
<g>
<polyline
class="sc-aXZVg bUvEJV"
fill="white"
points="10 0, 30 0, 40 20, 30 40, 10 40, 0 20, 10 0"
stroke="black"
stroke-width="1"
/>
<text
height="40"
pointer-events="none"
text-anchor="start"
width="40"
x="50"
y="20"
>
<tspan
dy="5.5"
x="50"
>
Conversation
</tspan>
</text>
</g>
</svg>
</div>
</body>
`;
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { wrappedRender } from '../../../test-utils/render';
import * as React from 'react';
import { SyntaxTreeTerminal } from '../../../../../main/packages/syntax-tree/syntax-tree-terminal/syntax-tree-terminal';
import { SyntaxTreeTerminalComponent } from '../../../../../main/packages/syntax-tree/syntax-tree-terminal/syntax-tree-terminal-component';
import { Multiline } from '../../../../../main/utils/svg/multiline';
import { CSSProperties } from 'react';
import { BPMNAnnotation } from '../../../../../main/packages/bpmn/bpmn-annotation/bpmn-annotation';
import { BPMNAnnotationComponent } from '../../../../../main/packages/bpmn/bpmn-annotation/bpmn-annotation-component';
import { BPMNConversationComponent } from '../../../../../main/packages/bpmn/bpmn-conversation/bpmn-conversation-component';
import { BPMNConversation } from '../../../../../main/packages/bpmn/bpmn-conversation/bpmn-conversation';

// override getStringWidth, because it uses by jsdom unsupported SVGElement methods
Multiline.prototype.getStringWidth = (str: string, style?: CSSProperties) => {
return 0;
};

it('render the bpmn-conversation-component', () => {
const conversation: BPMNConversation = new BPMNConversation({ name: 'Conversation' });
const { getByText, baseElement } = wrappedRender(
<svg>
<BPMNConversationComponent element={conversation} />
</svg>,
);
expect(getByText(conversation.name)).toBeInTheDocument();
expect(baseElement).toMatchSnapshot();
});
Loading

0 comments on commit e7f187a

Please sign in to comment.