diff --git a/packages/dmn-editor/src/DmnEditor.css b/packages/dmn-editor/src/DmnEditor.css index a74ac8569b1..1011c465840 100644 --- a/packages/dmn-editor/src/DmnEditor.css +++ b/packages/dmn-editor/src/DmnEditor.css @@ -56,7 +56,8 @@ outline: none; } .kie-dmn-editor--node.dimmed, -.kie-dmn-editor--node-shape.dimmed { +.kie-dmn-editor--node-shape.dimmed, +.kie-dmn-editor--input-data-node.dimmed { opacity: 0.3; pointer-events: none; } @@ -577,10 +578,12 @@ the cursor is inside it. By making it adimensional, that never happens. */ .kie-dmn-editor--data-type-node-panel { position: absolute; top: -46px; - padding-bottom: 10px; + padding-bottom: 14px; display: flex; align-items: end; - zoom: 0.8; + + /* zoom is not supported by Playwright library */ + transform: scale(0.8); } .kie-dmn-editor--data-type-node-panel .kie-dmn-editor--data-type-jump-to-definition { padding-left: 4px; diff --git a/packages/dmn-editor/src/DmnEditor.tsx b/packages/dmn-editor/src/DmnEditor.tsx index 385f821128a..d667fd89829 100644 --- a/packages/dmn-editor/src/DmnEditor.tsx +++ b/packages/dmn-editor/src/DmnEditor.tsx @@ -151,12 +151,17 @@ export type DmnEditorProps = { * If undefined, the relative paths will be displayed. */ onRequestToResolvePath?: OnRequestToResolvePath; + /** + * Notifies the caller when the DMN Editor performs a new edit after the debounce time. + */ + onModelDebounceStateChanged?: (changed: boolean) => void; }; export const DmnEditorInternal = ({ model, originalVersion, onModelChange, + onModelDebounceStateChanged, forwardRef, }: DmnEditorProps & { forwardRef?: React.Ref }) => { const boxedExpressionEditorActiveDrgElementId = useDmnEditorStore((s) => s.boxedExpressionEditor.activeDrgElementId); @@ -254,6 +259,7 @@ export const DmnEditorInternal = ({ if (isDiagramEditingInProgress) { return; } + onModelDebounceStateChanged?.(false); const timeout = setTimeout(() => { // Ignore changes made outside... If the controller of the component @@ -262,6 +268,7 @@ export const DmnEditorInternal = ({ return; } + onModelDebounceStateChanged?.(true); console.debug("DMN EDITOR: Model changed!"); onModelChange?.(dmn.model); }, ON_MODEL_CHANGE_DEBOUNCE_TIME_IN_MS); diff --git a/packages/dmn-editor/src/diagram/Diagram.tsx b/packages/dmn-editor/src/diagram/Diagram.tsx index 14d8206437b..bc3393e9ba7 100644 --- a/packages/dmn-editor/src/diagram/Diagram.tsx +++ b/packages/dmn-editor/src/diagram/Diagram.tsx @@ -133,7 +133,7 @@ const PAN_ON_DRAG = [1, 2]; const FIT_VIEW_OPTIONS: RF.FitViewOptions = { maxZoom: 1, minZoom: 0.1, duration: 400 }; -const DEFAULT_VIEWPORT = { x: 100, y: 0, zoom: 1 }; +const DEFAULT_VIEWPORT = { x: 100, y: 100, zoom: 1 }; const DELETE_NODE_KEY_CODES = ["Backspace", "Delete"]; diff --git a/packages/dmn-editor/src/diagram/edges/Waypoints.tsx b/packages/dmn-editor/src/diagram/edges/Waypoints.tsx index ec3f318c001..e5fca361a2a 100644 --- a/packages/dmn-editor/src/diagram/edges/Waypoints.tsx +++ b/packages/dmn-editor/src/diagram/edges/Waypoints.tsx @@ -105,6 +105,7 @@ export function Waypoint({ return ( {/* {`render count: ${renderCount.current}`}
*/} -
+
) { - const [args, updateArgs] = useArgs(); +export type StorybookDmnEditorProps = DmnEditorProps & { xml: string }; + +export function DmnEditorWrapper(props?: Partial) { + const [args, updateArgs] = useArgs(); const argsCopy = useRef(args); const ref = useRef(null); const [modelArgs, setModelArgs] = useState(args.model); const model = useMemo(() => props?.model ?? modelArgs, [modelArgs, props?.model]); + const [modelChanged, setModelChange] = useState(false); const onModelChange = useMemo( () => (props?.onModelChange ? props.onModelChange : setModelArgs), @@ -41,7 +45,11 @@ export function DmnEditorWrapper(props?: Partial) { useEffect(() => { if (Object.keys(diff(argsCopy.current.model, model)).length !== 0) { - updateArgs({ ...argsCopy.current, model: model }); + updateArgs({ + ...argsCopy.current, + model: model, + xml: getMarshaller(generateEmptyDmn15(), { upgradeTo: "latest" }).builder.build(model), + }); } }, [updateArgs, model]); @@ -56,25 +64,37 @@ export function DmnEditorWrapper(props?: Partial) { onModelChange(args.model); }, [args, model, onModelChange]); + const onModelDebounceStateChanged = useCallback((changed: boolean) => { + setModelChange(changed); + }, []); + return ( -
- -
+ <> + {modelChanged && ( +
+ {JSON.stringify(model)} +
+ )} +
+ +
+ ); } diff --git a/packages/dmn-editor/stories/misc/empty/Empty.mdx b/packages/dmn-editor/stories/misc/empty/Empty.mdx index a83b772bf49..20950758c29 100644 --- a/packages/dmn-editor/stories/misc/empty/Empty.mdx +++ b/packages/dmn-editor/stories/misc/empty/Empty.mdx @@ -22,4 +22,5 @@ import * as Empty from "./Empty.stories"; ## Empty -When user starts with an empty diagram, a wizard for quick content initialization is displayed. The wizard enables to create simple diagram with one input and one output or a diagram with one decision table expression. +When user starts with an empty diagram, a wizard for quick content initialization is displayed. +The wizard enables to create simple diagram with one input and one output or a diagram with one decision table expression. diff --git a/packages/dmn-editor/stories/misc/empty/Empty.stories.tsx b/packages/dmn-editor/stories/misc/empty/Empty.stories.tsx index 4c7b970b58e..29cc5f9a671 100644 --- a/packages/dmn-editor/stories/misc/empty/Empty.stories.tsx +++ b/packages/dmn-editor/stories/misc/empty/Empty.stories.tsx @@ -22,7 +22,7 @@ import { getMarshaller } from "@kie-tools/dmn-marshaller"; import { ns as dmn15ns } from "@kie-tools/dmn-marshaller/dist/schemas/dmn-1_5/ts-gen/meta"; import { generateUuid } from "@kie-tools/boxed-expression-component/dist/api"; import { DMN15_SPEC } from "@kie-tools/dmn-marshaller/dist/schemas/dmn-1_5/Dmn15Spec"; -import { DmnEditorWrapper } from "../../dmnEditorStoriesWrapper"; +import { DmnEditorWrapper, StorybookDmnEditorProps } from "../../dmnEditorStoriesWrapper"; import { DmnEditor, DmnEditorProps } from "../../../src/DmnEditor"; export const generateEmptyDmn15 = () => ` @@ -41,12 +41,15 @@ const meta: Meta = { }; export default meta; -type Story = StoryObj; +type Story = StoryObj; + +const marshaller = getMarshaller(generateEmptyDmn15(), { upgradeTo: "latest" }); +const model = marshaller.parser.parse(); export const Empty: Story = { render: (args) => DmnEditorWrapper(), args: { - model: getMarshaller(generateEmptyDmn15(), { upgradeTo: "latest" }).parser.parse(), + model: model, originalVersion: "1.5", evaluationResults: {}, externalContextDescription: "", @@ -54,5 +57,6 @@ export const Empty: Story = { externalModelsByNamespace: {}, issueTrackerHref: "", validationMessages: {}, + xml: marshaller.builder.build(model), }, }; diff --git a/packages/dmn-editor/stories/useCases/loanPreQualification/LoanPreQualification.stories.tsx b/packages/dmn-editor/stories/useCases/loanPreQualification/LoanPreQualification.stories.tsx index ab73789fab0..ad330ff470e 100644 --- a/packages/dmn-editor/stories/useCases/loanPreQualification/LoanPreQualification.stories.tsx +++ b/packages/dmn-editor/stories/useCases/loanPreQualification/LoanPreQualification.stories.tsx @@ -22,6 +22,7 @@ import type { Meta, StoryObj } from "@storybook/react"; import { getMarshaller } from "@kie-tools/dmn-marshaller"; import { Empty } from "../../misc/empty/Empty.stories"; import { DmnEditor, DmnEditorProps } from "../../../src/DmnEditor"; +import { StorybookDmnEditorProps } from "../../dmnEditorStoriesWrapper"; export const loanPreQualificationDmn = ` = { }; export default meta; -type Story = StoryObj; +type Story = StoryObj; + +const marshaller = getMarshaller(loanPreQualificationDmn, { upgradeTo: "latest" }); +const model = marshaller.parser.parse(); export const LoanPreQualification: Story = { ...Empty.render, args: { ...Empty.args, - model: getMarshaller(loanPreQualificationDmn, { upgradeTo: "latest" }).parser.parse(), + model: model, + xml: marshaller.builder.build(model), }, }; diff --git a/packages/dmn-editor/tests/e2e/__fixtures__/base.ts b/packages/dmn-editor/tests/e2e/__fixtures__/base.ts index 157ac60564d..579344a07ab 100644 --- a/packages/dmn-editor/tests/e2e/__fixtures__/base.ts +++ b/packages/dmn-editor/tests/e2e/__fixtures__/base.ts @@ -23,11 +23,13 @@ import { Palette } from "./palette"; import { Nodes } from "./nodes"; import { Editor } from "./editor"; import { Edges } from "./edges"; +import { JsonModel } from "./jsonModel"; type DmnEditorFixtures = { diagram: Diagram; edges: Edges; editor: Editor; + jsonModel: JsonModel; nodes: Nodes; palette: Palette; }; @@ -36,14 +38,17 @@ export const test = base.extend({ editor: async ({ page, baseURL }, use) => { await use(new Editor(page, baseURL)); }, + jsonModel: async ({ page, baseURL }, use) => { + await use(new JsonModel(page, baseURL)); + }, diagram: async ({ page }, use) => { await use(new Diagram(page)); }, nodes: async ({ page, diagram, browserName }, use) => { await use(new Nodes(page, diagram, browserName)); }, - edges: async ({ page, nodes }, use) => { - await use(new Edges(page, nodes)); + edges: async ({ page, nodes, diagram }, use) => { + await use(new Edges(page, nodes, diagram)); }, palette: async ({ page, diagram, nodes }, use) => { await use(new Palette(page, diagram, nodes)); diff --git a/packages/dmn-editor/tests/e2e/__fixtures__/diagram.ts b/packages/dmn-editor/tests/e2e/__fixtures__/diagram.ts index 8aba01bd380..7d633f6795c 100644 --- a/packages/dmn-editor/tests/e2e/__fixtures__/diagram.ts +++ b/packages/dmn-editor/tests/e2e/__fixtures__/diagram.ts @@ -19,6 +19,11 @@ import { Page } from "@playwright/test"; +export const DEFAULT_DRD_NAME = "Default DRD"; +export const UNNAMED_DRD_NAME = "Unnamed DRD"; +const VIEWPORT_OFFSET_X = 100; +const VIEWPORT_OFFSET_Y = 100; + export class Diagram { constructor(public page: Page) {} @@ -26,6 +31,10 @@ export class Diagram { return this.page.getByTestId("kie-dmn-editor--diagram-container"); } + public async dblclick(position: { x: number; y: number }) { + return this.get().dblclick({ position: { x: position.x + VIEWPORT_OFFSET_X, y: position.y + VIEWPORT_OFFSET_Y } }); + } + public async resetFocus() { return this.get().click({ position: { x: 0, y: 0 } }); } @@ -36,4 +45,10 @@ export class Diagram { await this.page.mouse.move(args.endPosition.x, args.endPosition.y); await this.page.mouse.up(); } + + public async selectAlternativeInputDataShape() { + await this.get().getByTitle("Select or edit DRD").click(); + await this.page.getByLabel("Tweak the shape of the input data node").getByText("Alternative").click(); + await this.get().getByTitle("Select or edit DRD").click(); + } } diff --git a/packages/dmn-editor/tests/e2e/__fixtures__/edges.ts b/packages/dmn-editor/tests/e2e/__fixtures__/edges.ts index 110ed64d507..d45f4570087 100644 --- a/packages/dmn-editor/tests/e2e/__fixtures__/edges.ts +++ b/packages/dmn-editor/tests/e2e/__fixtures__/edges.ts @@ -19,6 +19,7 @@ import { Page } from "@playwright/test"; import { Nodes } from "./nodes"; +import { Diagram } from "./diagram"; export enum EdgeType { ASSOCIATION = "association", @@ -28,7 +29,7 @@ export enum EdgeType { } export class Edges { - constructor(public page: Page, public nodes: Nodes) {} + constructor(public page: Page, public nodes: Nodes, public diagram: Diagram) {} public async get(args: { from: string; to: string }) { const from = await this.nodes.getId({ name: args.from }); @@ -37,12 +38,67 @@ export class Edges { return this.page.getByRole("button", { name: `Edge from ${from} to ${to}` }); } + public async getWaypoint(args: { from: string; to: string; waypointIndex: number }) { + return (await this.get({ from: args.from, to: args.to })).locator(`[data-waypointindex="${args.waypointIndex}"]`); + } + public async getType(args: { from: string; to: string }) { return (await this.get({ from: args.from, to: args.to })).locator("path").nth(0).getAttribute("data-edgetype"); } - public async addWaypoint(args: { from: string; to: string }) { - await (await this.get({ from: args.from, to: args.to })).dblclick(); + public async addWaypoint(args: { from: string; to: string; afterWaypointIndex?: number }) { + const dAttribute = await (await this.get({ from: args.from, to: args.to })) + .locator("path") + .first() + .getAttribute("d"); + + const edgeSegments = dAttribute?.match(/M [0-9]*,[0-9]* L [0-9]*,[0-9]*/); + + if (edgeSegments) { + const edgeSegment = args.afterWaypointIndex + ? edgeSegments[Math.min(edgeSegments.length - 1, args.afterWaypointIndex)] + : edgeSegments[0]; + + const [fromX, fromY] = edgeSegment + .split(/ L [0-9]*,[0-9]*/)[0] + .slice(2) + .split(","); + const [toX, toY] = edgeSegment + .split(/M [0-9]*,[0-9]* /)[1] + .slice(2) + .split(","); + + await this.diagram.dblclick({ + x: (parseInt(fromX) + parseInt(toX)) / 2, + y: (parseInt(fromY) + parseInt(toY)) / 2, + }); + } + } + + public async moveWaypoint(args: { + from: string; + to: string; + waypointIndex: number; + targetPosition: { x: number; y: number }; + }) { + await this.select({ from: args.from, to: args.to }); + + await ( + await this.getWaypoint({ from: args.from, to: args.to, waypointIndex: args.waypointIndex }) + ).dragTo(this.diagram.get(), { + targetPosition: args.targetPosition, + }); + } + + public async deleteWaypoint(args: { from: string; to: string; waypointIndex: number }) { + await this.select({ from: args.from, to: args.to }); + await (await this.getWaypoint({ from: args.from, to: args.to, waypointIndex: args.waypointIndex })).dblclick(); + } + + public async deleteWaypoints(args: { from: string; to: string; waypointsCount: number }) { + for (let i = 0; i < args.waypointsCount; i++) { + await this.deleteWaypoint({ from: args.from, to: args.to, waypointIndex: 1 }); + } } public async delete(args: { from: string; to: string; isBackspace?: boolean }) { @@ -55,6 +111,7 @@ export class Edges { } public async select(args: { from: string; to: string }) { - await (await this.get({ from: args.from, to: args.to })).click(); + // because of the waypoints on the edge, we can not click into the edge bounding box middle + await (await this.get({ from: args.from, to: args.to })).locator("circle").nth(1).click(); } } diff --git a/packages/dmn-editor/tests/e2e/__fixtures__/jsonModel.ts b/packages/dmn-editor/tests/e2e/__fixtures__/jsonModel.ts new file mode 100644 index 00000000000..2d6c476b2b3 --- /dev/null +++ b/packages/dmn-editor/tests/e2e/__fixtures__/jsonModel.ts @@ -0,0 +1,49 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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 { DmnLatestModel } from "@kie-tools/dmn-marshaller"; +import { Page } from "@playwright/test"; +import { DrgElement } from "./jsonModel/drgElement"; +import { Drd } from "./jsonModel/drd"; + +export enum DataType { + Undefined = "", + Any = "Any", + Boolean = "boolean", + Context = "context", + Date = "date", + DateTime = "date and time", + DateTimeDuration = "days and time duration", + Number = "number", + String = "string", + Time = "time", + YearsMonthsDuration = "years and months duration", +} + +export const STORYBOOK__DMN_EDITOR_MODEL = "div[data-testid='storybook--dmn-editor-model']"; + +export class JsonModel { + public drgElements: DrgElement; + public drd: Drd; + + constructor(public page: Page, public baseURL?: string) { + this.drgElements = new DrgElement(page); + this.drd = new Drd(page, this.drgElements); + } +} diff --git a/packages/dmn-editor/tests/e2e/__fixtures__/jsonModel/drd.ts b/packages/dmn-editor/tests/e2e/__fixtures__/jsonModel/drd.ts new file mode 100644 index 00000000000..f1a0d21fe1e --- /dev/null +++ b/packages/dmn-editor/tests/e2e/__fixtures__/jsonModel/drd.ts @@ -0,0 +1,43 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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 { DmnLatestModel } from "@kie-tools/dmn-marshaller"; +import { DMNDI15__DMNDiagram, DMNDI15__DMNShape } from "@kie-tools/dmn-marshaller/dist/schemas/dmn-1_5/ts-gen/types"; +import { Page } from "@playwright/test"; +import { DrgElement } from "./drgElement"; + +export class Drd { + constructor(public page: Page, public drgElement: DrgElement) {} + + public async getDrgElementBoundsOnDrd(args: { drgElementIndex: number; drdIndex: number }) { + const drd = await this.getDrd({ drdIndex: args.drdIndex }); + return (drd?.["dmndi:DMNDiagramElement"]?.[args.drgElementIndex] as DMNDI15__DMNShape)?.["dc:Bounds"]; + } + + private async getDrd(args: { drdIndex: number }): Promise { + const textContent = await this.page.getByTestId("storybook--dmn-editor-model").textContent(); + + if (textContent === null || textContent === undefined) { + return; + } + return (JSON.parse(textContent) as DmnLatestModel).definitions?.["dmndi:DMNDI"]?.["dmndi:DMNDiagram"]?.[ + args.drdIndex + ]; + } +} diff --git a/packages/dmn-editor/tests/e2e/__fixtures__/jsonModel/drgElement.ts b/packages/dmn-editor/tests/e2e/__fixtures__/jsonModel/drgElement.ts new file mode 100644 index 00000000000..83217d3f096 --- /dev/null +++ b/packages/dmn-editor/tests/e2e/__fixtures__/jsonModel/drgElement.ts @@ -0,0 +1,100 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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 { DmnLatestModel } from "@kie-tools/dmn-marshaller"; +import { + DMN15__tBusinessKnowledgeModel, + DMN15__tDecision, + DMN15__tDecisionService, + DMN15__tDefinitions, + DMN15__tInputData, + DMN15__tKnowledgeSource, +} from "@kie-tools/dmn-marshaller/dist/schemas/dmn-1_5/ts-gen/types"; +import { Page } from "@playwright/test"; + +type AllDrgElements = NonNullable[0]; + +export class DrgElement { + constructor(public page: Page) {} + + public async getBkm(args: { drgElementIndex: number; drdIndex: number }) { + const drgElement = (await this.getDrgElement({ + drgElementIndex: args.drgElementIndex, + })) as DMN15__tBusinessKnowledgeModel & { + __$$element: string; + }; + if (drgElement === undefined) { + throw new Error("Couldn't find DRG element"); + } + return drgElement; + } + + public async getDecision(args: { drgElementIndex: number; drdIndex: number }) { + const drgElement = (await this.getDrgElement({ drgElementIndex: args.drgElementIndex })) as DMN15__tDecision & { + __$$element: string; + }; + if (drgElement === undefined) { + throw new Error("Couldn't find DRG element"); + } + return drgElement; + } + + public async getDecisionService(args: { drgElementIndex: number; drdIndex: number }) { + const drgElement = (await this.getDrgElement({ + drgElementIndex: args.drgElementIndex, + })) as DMN15__tDecisionService & { + __$$element: string; + }; + if (drgElement === undefined) { + throw new Error("Couldn't find DRG element"); + } + return drgElement; + } + + public async getInputData(args: { drgElementIndex: number; drdIndex: number }) { + const drgElement = (await this.getDrgElement({ drgElementIndex: args.drgElementIndex })) as DMN15__tInputData & { + __$$element: string; + }; + if (drgElement === undefined) { + throw new Error("Couldn't find DRG element"); + } + return drgElement; + } + + public async getKnowledgeSource(args: { drgElementIndex: number; drdIndex: number }) { + const drgElement = (await this.getDrgElement({ + drgElementIndex: args.drgElementIndex, + })) as DMN15__tKnowledgeSource & { + __$$element: string; + }; + if (drgElement === undefined) { + throw new Error("Couldn't find DRG element"); + } + return drgElement; + } + + public async getDrgElement(args: { drgElementIndex: number }): Promise { + const textContent = await this.page.getByTestId("storybook--dmn-editor-model").textContent(); + + if (textContent === null || textContent === undefined) { + return; + } + return (JSON.parse(textContent) as DmnLatestModel).definitions.drgElement?.[args.drgElementIndex]; + } +} diff --git a/packages/dmn-editor/tests/e2e/__fixtures__/nodes.ts b/packages/dmn-editor/tests/e2e/__fixtures__/nodes.ts index eb87dbb60b2..6c79cff4a16 100644 --- a/packages/dmn-editor/tests/e2e/__fixtures__/nodes.ts +++ b/packages/dmn-editor/tests/e2e/__fixtures__/nodes.ts @@ -82,16 +82,7 @@ export class Nodes { ? await this.getPositionalNodeHandleCoordinates({ node: to, position: args.position }) : undefined; - switch (args.type) { - case EdgeType.ASSOCIATION: - return from.getByTitle("Add Association edge").dragTo(to, { targetPosition }); - case EdgeType.AUTHORITY_REQUIREMENT: - return from.getByTitle("Add Authority Requirement edge").dragTo(to, { targetPosition }); - case EdgeType.INFORMATION_REQUIREMENT: - return from.getByTitle("Add Information Requirement edge").dragTo(to, { targetPosition }); - case EdgeType.KNOWLEDGE_REQUIREMENT: - return from.getByTitle("Add Knowledge Requirement edge").dragTo(to, { targetPosition }); - } + return from.getByTitle(this.getAddEdgeTitle(args.type)).dragTo(to, { targetPosition }); } public async dragNewConnectedNode(args: { @@ -173,6 +164,13 @@ export class Nodes { return this.get({ name: args.name }).locator("span", { hasText: args.name }).dblclick(); } + // Used for testing invalid edges. No edge is created using this method. + public async startDraggingEdge(args: { from: string; edgeType: EdgeType }) { + await this.select({ name: args.from, position: NodePosition.TOP }); + await this.get({ name: args.from }).getByTitle(this.getAddEdgeTitle(args.edgeType)).hover(); + await this.page.mouse.down(); + } + // After creating a node takes a while to get the focus. // This methods waits until it gets the focus. public async waitForNodeToBeFocused(args: { name: string }) { @@ -219,4 +217,17 @@ export class Nodes { return { x: toBoundingBox.width / 2, y: 10 }; } } + + private getAddEdgeTitle(edgeType: EdgeType) { + switch (edgeType) { + case EdgeType.ASSOCIATION: + return "Add Association edge"; + case EdgeType.AUTHORITY_REQUIREMENT: + return "Add Authority Requirement edge"; + case EdgeType.INFORMATION_REQUIREMENT: + return "Add Information Requirement edge"; + case EdgeType.KNOWLEDGE_REQUIREMENT: + return "Add Knowledge Requirement edge"; + } + } } diff --git a/packages/dmn-editor/tests/e2e/__screenshots__/Google-Chrome/drdArtifacts/add-multiple-association-waypoint-and-not-move-them.png b/packages/dmn-editor/tests/e2e/__screenshots__/Google-Chrome/drdArtifacts/add-multiple-association-waypoint-and-not-move-them.png deleted file mode 100644 index 940405e9dc0..00000000000 Binary files a/packages/dmn-editor/tests/e2e/__screenshots__/Google-Chrome/drdArtifacts/add-multiple-association-waypoint-and-not-move-them.png and /dev/null differ diff --git a/packages/dmn-editor/tests/e2e/__screenshots__/Google-Chrome/drdArtifacts/delete-association-waypoint-edge-with-corner.png b/packages/dmn-editor/tests/e2e/__screenshots__/Google-Chrome/drdArtifacts/delete-association-waypoint-edge-with-corner.png new file mode 100644 index 00000000000..3f3f0c93369 Binary files /dev/null and b/packages/dmn-editor/tests/e2e/__screenshots__/Google-Chrome/drdArtifacts/delete-association-waypoint-edge-with-corner.png differ diff --git a/packages/dmn-editor/tests/e2e/__screenshots__/Google-Chrome/drdArtifacts/delete-association-waypoint-straight-edge.png b/packages/dmn-editor/tests/e2e/__screenshots__/Google-Chrome/drdArtifacts/delete-association-waypoint-straight-edge.png new file mode 100644 index 00000000000..a5aca3768f9 Binary files /dev/null and b/packages/dmn-editor/tests/e2e/__screenshots__/Google-Chrome/drdArtifacts/delete-association-waypoint-straight-edge.png differ diff --git a/packages/dmn-editor/tests/e2e/__screenshots__/Google-Chrome/drdArtifacts/add-association-waypoint-and-not-move-it.png b/packages/dmn-editor/tests/e2e/__screenshots__/Google-Chrome/drdArtifacts/move-association-ending-waypoint.png similarity index 100% rename from packages/dmn-editor/tests/e2e/__screenshots__/Google-Chrome/drdArtifacts/add-association-waypoint-and-not-move-it.png rename to packages/dmn-editor/tests/e2e/__screenshots__/Google-Chrome/drdArtifacts/move-association-ending-waypoint.png diff --git a/packages/dmn-editor/tests/e2e/__screenshots__/Google-Chrome/drdArtifacts/move-association-middle-waypoint.png b/packages/dmn-editor/tests/e2e/__screenshots__/Google-Chrome/drdArtifacts/move-association-middle-waypoint.png new file mode 100644 index 00000000000..62a3f77ed73 Binary files /dev/null and b/packages/dmn-editor/tests/e2e/__screenshots__/Google-Chrome/drdArtifacts/move-association-middle-waypoint.png differ diff --git a/packages/dmn-editor/tests/e2e/__screenshots__/Google-Chrome/drdArtifacts/move-association-middle-waypoints.png b/packages/dmn-editor/tests/e2e/__screenshots__/Google-Chrome/drdArtifacts/move-association-middle-waypoints.png new file mode 100644 index 00000000000..e392a5ea2c8 Binary files /dev/null and b/packages/dmn-editor/tests/e2e/__screenshots__/Google-Chrome/drdArtifacts/move-association-middle-waypoints.png differ diff --git a/packages/dmn-editor/tests/e2e/__screenshots__/Google-Chrome/drdArtifacts/move-association-starting-and-ending-waypoint.png b/packages/dmn-editor/tests/e2e/__screenshots__/Google-Chrome/drdArtifacts/move-association-starting-and-ending-waypoint.png new file mode 100644 index 00000000000..a06dea883ee Binary files /dev/null and b/packages/dmn-editor/tests/e2e/__screenshots__/Google-Chrome/drdArtifacts/move-association-starting-and-ending-waypoint.png differ diff --git a/packages/dmn-editor/tests/e2e/__screenshots__/Google-Chrome/drgRequirements/add-multiple-authority-requirement-waypoints-and-not-move-them.png b/packages/dmn-editor/tests/e2e/__screenshots__/Google-Chrome/drgRequirements/add-multiple-authority-requirement-waypoints-and-not-move-them.png deleted file mode 100644 index b03f6abb6ad..00000000000 Binary files a/packages/dmn-editor/tests/e2e/__screenshots__/Google-Chrome/drgRequirements/add-multiple-authority-requirement-waypoints-and-not-move-them.png and /dev/null differ diff --git a/packages/dmn-editor/tests/e2e/__screenshots__/Google-Chrome/drgRequirements/add-multiple-information-requirement-waypoints-and-not-move-them.png b/packages/dmn-editor/tests/e2e/__screenshots__/Google-Chrome/drgRequirements/add-multiple-information-requirement-waypoints-and-not-move-them.png deleted file mode 100644 index 7b217bea582..00000000000 Binary files a/packages/dmn-editor/tests/e2e/__screenshots__/Google-Chrome/drgRequirements/add-multiple-information-requirement-waypoints-and-not-move-them.png and /dev/null differ diff --git a/packages/dmn-editor/tests/e2e/__screenshots__/Google-Chrome/drgRequirements/add-multiple-knowledge-requirement-waypoints-and-not-move-them.png b/packages/dmn-editor/tests/e2e/__screenshots__/Google-Chrome/drgRequirements/add-multiple-knowledge-requirement-waypoints-and-not-move-them.png deleted file mode 100644 index 625b875ade9..00000000000 Binary files a/packages/dmn-editor/tests/e2e/__screenshots__/Google-Chrome/drgRequirements/add-multiple-knowledge-requirement-waypoints-and-not-move-them.png and /dev/null differ diff --git a/packages/dmn-editor/tests/e2e/__screenshots__/Google-Chrome/drgRequirements/delete-authority-requirement-waypoint-edge-with-corner.png b/packages/dmn-editor/tests/e2e/__screenshots__/Google-Chrome/drgRequirements/delete-authority-requirement-waypoint-edge-with-corner.png new file mode 100644 index 00000000000..d6ad263ffd4 Binary files /dev/null and b/packages/dmn-editor/tests/e2e/__screenshots__/Google-Chrome/drgRequirements/delete-authority-requirement-waypoint-edge-with-corner.png differ diff --git a/packages/dmn-editor/tests/e2e/__screenshots__/Google-Chrome/drgRequirements/delete-authority-requirement-waypoint-straight-edge.png b/packages/dmn-editor/tests/e2e/__screenshots__/Google-Chrome/drgRequirements/delete-authority-requirement-waypoint-straight-edge.png new file mode 100644 index 00000000000..9d93f25799a Binary files /dev/null and b/packages/dmn-editor/tests/e2e/__screenshots__/Google-Chrome/drgRequirements/delete-authority-requirement-waypoint-straight-edge.png differ diff --git a/packages/dmn-editor/tests/e2e/__screenshots__/Google-Chrome/drgRequirements/delete-information-requirement-waypoint-edge-with-corner.png b/packages/dmn-editor/tests/e2e/__screenshots__/Google-Chrome/drgRequirements/delete-information-requirement-waypoint-edge-with-corner.png new file mode 100644 index 00000000000..4f80bcbfa18 Binary files /dev/null and b/packages/dmn-editor/tests/e2e/__screenshots__/Google-Chrome/drgRequirements/delete-information-requirement-waypoint-edge-with-corner.png differ diff --git a/packages/dmn-editor/tests/e2e/__screenshots__/Google-Chrome/drgRequirements/delete-information-requirement-waypoint-straight-edge.png b/packages/dmn-editor/tests/e2e/__screenshots__/Google-Chrome/drgRequirements/delete-information-requirement-waypoint-straight-edge.png new file mode 100644 index 00000000000..2ebd952c96e Binary files /dev/null and b/packages/dmn-editor/tests/e2e/__screenshots__/Google-Chrome/drgRequirements/delete-information-requirement-waypoint-straight-edge.png differ diff --git a/packages/dmn-editor/tests/e2e/__screenshots__/Google-Chrome/drgRequirements/delete-knowledge-requirement-waypoint-edge-with-corner.png b/packages/dmn-editor/tests/e2e/__screenshots__/Google-Chrome/drgRequirements/delete-knowledge-requirement-waypoint-edge-with-corner.png new file mode 100644 index 00000000000..ef5bf3c3234 Binary files /dev/null and b/packages/dmn-editor/tests/e2e/__screenshots__/Google-Chrome/drgRequirements/delete-knowledge-requirement-waypoint-edge-with-corner.png differ diff --git a/packages/dmn-editor/tests/e2e/__screenshots__/Google-Chrome/drgRequirements/delete-knowledge-requirement-waypoint-straight-edge.png b/packages/dmn-editor/tests/e2e/__screenshots__/Google-Chrome/drgRequirements/delete-knowledge-requirement-waypoint-straight-edge.png new file mode 100644 index 00000000000..8f1fa23961a Binary files /dev/null and b/packages/dmn-editor/tests/e2e/__screenshots__/Google-Chrome/drgRequirements/delete-knowledge-requirement-waypoint-straight-edge.png differ diff --git a/packages/dmn-editor/tests/e2e/__screenshots__/Google-Chrome/drgRequirements/add-authority-requirement-waypoint-and-not-move-it.png b/packages/dmn-editor/tests/e2e/__screenshots__/Google-Chrome/drgRequirements/move-authority-requirement-ending-waypoint.png similarity index 100% rename from packages/dmn-editor/tests/e2e/__screenshots__/Google-Chrome/drgRequirements/add-authority-requirement-waypoint-and-not-move-it.png rename to packages/dmn-editor/tests/e2e/__screenshots__/Google-Chrome/drgRequirements/move-authority-requirement-ending-waypoint.png diff --git a/packages/dmn-editor/tests/e2e/__screenshots__/Google-Chrome/drgRequirements/move-authority-requirement-middle-waypoint.png b/packages/dmn-editor/tests/e2e/__screenshots__/Google-Chrome/drgRequirements/move-authority-requirement-middle-waypoint.png new file mode 100644 index 00000000000..6affb970283 Binary files /dev/null and b/packages/dmn-editor/tests/e2e/__screenshots__/Google-Chrome/drgRequirements/move-authority-requirement-middle-waypoint.png differ diff --git a/packages/dmn-editor/tests/e2e/__screenshots__/Google-Chrome/drgRequirements/move-authority-requirement-middle-waypoints.png b/packages/dmn-editor/tests/e2e/__screenshots__/Google-Chrome/drgRequirements/move-authority-requirement-middle-waypoints.png new file mode 100644 index 00000000000..01d323bf8ff Binary files /dev/null and b/packages/dmn-editor/tests/e2e/__screenshots__/Google-Chrome/drgRequirements/move-authority-requirement-middle-waypoints.png differ diff --git a/packages/dmn-editor/tests/e2e/__screenshots__/Google-Chrome/drgRequirements/move-authority-requirement-starting-and-ending-waypoint.png b/packages/dmn-editor/tests/e2e/__screenshots__/Google-Chrome/drgRequirements/move-authority-requirement-starting-and-ending-waypoint.png new file mode 100644 index 00000000000..bb5a3eed0a1 Binary files /dev/null and b/packages/dmn-editor/tests/e2e/__screenshots__/Google-Chrome/drgRequirements/move-authority-requirement-starting-and-ending-waypoint.png differ diff --git a/packages/dmn-editor/tests/e2e/__screenshots__/Google-Chrome/drgRequirements/add-information-requirement-waypoint-and-not-move-it.png b/packages/dmn-editor/tests/e2e/__screenshots__/Google-Chrome/drgRequirements/move-information-requirement-ending-waypoint.png similarity index 100% rename from packages/dmn-editor/tests/e2e/__screenshots__/Google-Chrome/drgRequirements/add-information-requirement-waypoint-and-not-move-it.png rename to packages/dmn-editor/tests/e2e/__screenshots__/Google-Chrome/drgRequirements/move-information-requirement-ending-waypoint.png diff --git a/packages/dmn-editor/tests/e2e/__screenshots__/Google-Chrome/drgRequirements/move-information-requirement-middle-waypoint.png b/packages/dmn-editor/tests/e2e/__screenshots__/Google-Chrome/drgRequirements/move-information-requirement-middle-waypoint.png new file mode 100644 index 00000000000..082f239ad13 Binary files /dev/null and b/packages/dmn-editor/tests/e2e/__screenshots__/Google-Chrome/drgRequirements/move-information-requirement-middle-waypoint.png differ diff --git a/packages/dmn-editor/tests/e2e/__screenshots__/Google-Chrome/drgRequirements/move-information-requirement-middle-waypoints.png b/packages/dmn-editor/tests/e2e/__screenshots__/Google-Chrome/drgRequirements/move-information-requirement-middle-waypoints.png new file mode 100644 index 00000000000..20cd5b61039 Binary files /dev/null and b/packages/dmn-editor/tests/e2e/__screenshots__/Google-Chrome/drgRequirements/move-information-requirement-middle-waypoints.png differ diff --git a/packages/dmn-editor/tests/e2e/__screenshots__/Google-Chrome/drgRequirements/move-information-requirement-starting-and-ending-waypoint.png b/packages/dmn-editor/tests/e2e/__screenshots__/Google-Chrome/drgRequirements/move-information-requirement-starting-and-ending-waypoint.png new file mode 100644 index 00000000000..1fa310aec51 Binary files /dev/null and b/packages/dmn-editor/tests/e2e/__screenshots__/Google-Chrome/drgRequirements/move-information-requirement-starting-and-ending-waypoint.png differ diff --git a/packages/dmn-editor/tests/e2e/__screenshots__/Google-Chrome/drgRequirements/add-knowledge-requirement-waypoint-and-not-move-it.png b/packages/dmn-editor/tests/e2e/__screenshots__/Google-Chrome/drgRequirements/move-knowledge-requirement-ending-waypoint.png similarity index 100% rename from packages/dmn-editor/tests/e2e/__screenshots__/Google-Chrome/drgRequirements/add-knowledge-requirement-waypoint-and-not-move-it.png rename to packages/dmn-editor/tests/e2e/__screenshots__/Google-Chrome/drgRequirements/move-knowledge-requirement-ending-waypoint.png diff --git a/packages/dmn-editor/tests/e2e/__screenshots__/Google-Chrome/drgRequirements/move-knowledge-requirement-middle-waypoint.png b/packages/dmn-editor/tests/e2e/__screenshots__/Google-Chrome/drgRequirements/move-knowledge-requirement-middle-waypoint.png new file mode 100644 index 00000000000..dadb9638cc8 Binary files /dev/null and b/packages/dmn-editor/tests/e2e/__screenshots__/Google-Chrome/drgRequirements/move-knowledge-requirement-middle-waypoint.png differ diff --git a/packages/dmn-editor/tests/e2e/__screenshots__/Google-Chrome/drgRequirements/move-knowledge-requirement-middle-waypoints.png b/packages/dmn-editor/tests/e2e/__screenshots__/Google-Chrome/drgRequirements/move-knowledge-requirement-middle-waypoints.png new file mode 100644 index 00000000000..8747dd78a6d Binary files /dev/null and b/packages/dmn-editor/tests/e2e/__screenshots__/Google-Chrome/drgRequirements/move-knowledge-requirement-middle-waypoints.png differ diff --git a/packages/dmn-editor/tests/e2e/__screenshots__/Google-Chrome/drgRequirements/move-knowledge-requirement-starting-and-ending-waypoint.png b/packages/dmn-editor/tests/e2e/__screenshots__/Google-Chrome/drgRequirements/move-knowledge-requirement-starting-and-ending-waypoint.png new file mode 100644 index 00000000000..479897f3c4a Binary files /dev/null and b/packages/dmn-editor/tests/e2e/__screenshots__/Google-Chrome/drgRequirements/move-knowledge-requirement-starting-and-ending-waypoint.png differ diff --git a/packages/dmn-editor/tests/e2e/__screenshots__/chromium/drdArtifacts/add-multiple-association-waypoint-and-not-move-them.png b/packages/dmn-editor/tests/e2e/__screenshots__/chromium/drdArtifacts/add-multiple-association-waypoint-and-not-move-them.png deleted file mode 100644 index 3a2d78d2bd8..00000000000 Binary files a/packages/dmn-editor/tests/e2e/__screenshots__/chromium/drdArtifacts/add-multiple-association-waypoint-and-not-move-them.png and /dev/null differ diff --git a/packages/dmn-editor/tests/e2e/__screenshots__/chromium/drdArtifacts/delete-association-waypoint-edge-with-corner.png b/packages/dmn-editor/tests/e2e/__screenshots__/chromium/drdArtifacts/delete-association-waypoint-edge-with-corner.png new file mode 100644 index 00000000000..b7c22c48abf Binary files /dev/null and b/packages/dmn-editor/tests/e2e/__screenshots__/chromium/drdArtifacts/delete-association-waypoint-edge-with-corner.png differ diff --git a/packages/dmn-editor/tests/e2e/__screenshots__/chromium/drdArtifacts/delete-association-waypoint-straight-edge.png b/packages/dmn-editor/tests/e2e/__screenshots__/chromium/drdArtifacts/delete-association-waypoint-straight-edge.png new file mode 100644 index 00000000000..d28fbfe1d97 Binary files /dev/null and b/packages/dmn-editor/tests/e2e/__screenshots__/chromium/drdArtifacts/delete-association-waypoint-straight-edge.png differ diff --git a/packages/dmn-editor/tests/e2e/__screenshots__/chromium/drdArtifacts/add-association-waypoint-and-not-move-it.png b/packages/dmn-editor/tests/e2e/__screenshots__/chromium/drdArtifacts/move-association-ending-waypoint.png similarity index 100% rename from packages/dmn-editor/tests/e2e/__screenshots__/chromium/drdArtifacts/add-association-waypoint-and-not-move-it.png rename to packages/dmn-editor/tests/e2e/__screenshots__/chromium/drdArtifacts/move-association-ending-waypoint.png diff --git a/packages/dmn-editor/tests/e2e/__screenshots__/chromium/drdArtifacts/move-association-middle-waypoint.png b/packages/dmn-editor/tests/e2e/__screenshots__/chromium/drdArtifacts/move-association-middle-waypoint.png new file mode 100644 index 00000000000..392e34af151 Binary files /dev/null and b/packages/dmn-editor/tests/e2e/__screenshots__/chromium/drdArtifacts/move-association-middle-waypoint.png differ diff --git a/packages/dmn-editor/tests/e2e/__screenshots__/chromium/drdArtifacts/move-association-middle-waypoints.png b/packages/dmn-editor/tests/e2e/__screenshots__/chromium/drdArtifacts/move-association-middle-waypoints.png new file mode 100644 index 00000000000..c2eb1db404b Binary files /dev/null and b/packages/dmn-editor/tests/e2e/__screenshots__/chromium/drdArtifacts/move-association-middle-waypoints.png differ diff --git a/packages/dmn-editor/tests/e2e/__screenshots__/chromium/drdArtifacts/move-association-starting-and-ending-waypoint.png b/packages/dmn-editor/tests/e2e/__screenshots__/chromium/drdArtifacts/move-association-starting-and-ending-waypoint.png new file mode 100644 index 00000000000..b2337be3230 Binary files /dev/null and b/packages/dmn-editor/tests/e2e/__screenshots__/chromium/drdArtifacts/move-association-starting-and-ending-waypoint.png differ diff --git a/packages/dmn-editor/tests/e2e/__screenshots__/chromium/drgRequirements/add-multiple-authority-requirement-waypoints-and-not-move-them.png b/packages/dmn-editor/tests/e2e/__screenshots__/chromium/drgRequirements/add-multiple-authority-requirement-waypoints-and-not-move-them.png deleted file mode 100644 index 4112ecbc2e1..00000000000 Binary files a/packages/dmn-editor/tests/e2e/__screenshots__/chromium/drgRequirements/add-multiple-authority-requirement-waypoints-and-not-move-them.png and /dev/null differ diff --git a/packages/dmn-editor/tests/e2e/__screenshots__/chromium/drgRequirements/add-multiple-information-requirement-waypoints-and-not-move-them.png b/packages/dmn-editor/tests/e2e/__screenshots__/chromium/drgRequirements/add-multiple-information-requirement-waypoints-and-not-move-them.png deleted file mode 100644 index 55768f8adc1..00000000000 Binary files a/packages/dmn-editor/tests/e2e/__screenshots__/chromium/drgRequirements/add-multiple-information-requirement-waypoints-and-not-move-them.png and /dev/null differ diff --git a/packages/dmn-editor/tests/e2e/__screenshots__/chromium/drgRequirements/add-multiple-knowledge-requirement-waypoints-and-not-move-them.png b/packages/dmn-editor/tests/e2e/__screenshots__/chromium/drgRequirements/add-multiple-knowledge-requirement-waypoints-and-not-move-them.png deleted file mode 100644 index 259be99dd6b..00000000000 Binary files a/packages/dmn-editor/tests/e2e/__screenshots__/chromium/drgRequirements/add-multiple-knowledge-requirement-waypoints-and-not-move-them.png and /dev/null differ diff --git a/packages/dmn-editor/tests/e2e/__screenshots__/chromium/drgRequirements/delete-authority-requirement-waypoint-edge-with-corner.png b/packages/dmn-editor/tests/e2e/__screenshots__/chromium/drgRequirements/delete-authority-requirement-waypoint-edge-with-corner.png new file mode 100644 index 00000000000..7ab74472bb2 Binary files /dev/null and b/packages/dmn-editor/tests/e2e/__screenshots__/chromium/drgRequirements/delete-authority-requirement-waypoint-edge-with-corner.png differ diff --git a/packages/dmn-editor/tests/e2e/__screenshots__/chromium/drgRequirements/delete-authority-requirement-waypoint-straight-edge.png b/packages/dmn-editor/tests/e2e/__screenshots__/chromium/drgRequirements/delete-authority-requirement-waypoint-straight-edge.png new file mode 100644 index 00000000000..18079439f8b Binary files /dev/null and b/packages/dmn-editor/tests/e2e/__screenshots__/chromium/drgRequirements/delete-authority-requirement-waypoint-straight-edge.png differ diff --git a/packages/dmn-editor/tests/e2e/__screenshots__/chromium/drgRequirements/delete-information-requirement-waypoint-edge-with-corner.png b/packages/dmn-editor/tests/e2e/__screenshots__/chromium/drgRequirements/delete-information-requirement-waypoint-edge-with-corner.png new file mode 100644 index 00000000000..3466f69daa4 Binary files /dev/null and b/packages/dmn-editor/tests/e2e/__screenshots__/chromium/drgRequirements/delete-information-requirement-waypoint-edge-with-corner.png differ diff --git a/packages/dmn-editor/tests/e2e/__screenshots__/chromium/drgRequirements/delete-information-requirement-waypoint-straight-edge.png b/packages/dmn-editor/tests/e2e/__screenshots__/chromium/drgRequirements/delete-information-requirement-waypoint-straight-edge.png new file mode 100644 index 00000000000..8593e0ebceb Binary files /dev/null and b/packages/dmn-editor/tests/e2e/__screenshots__/chromium/drgRequirements/delete-information-requirement-waypoint-straight-edge.png differ diff --git a/packages/dmn-editor/tests/e2e/__screenshots__/chromium/drgRequirements/delete-knowledge-requirement-waypoint-edge-with-corner.png b/packages/dmn-editor/tests/e2e/__screenshots__/chromium/drgRequirements/delete-knowledge-requirement-waypoint-edge-with-corner.png new file mode 100644 index 00000000000..63a46cca7ba Binary files /dev/null and b/packages/dmn-editor/tests/e2e/__screenshots__/chromium/drgRequirements/delete-knowledge-requirement-waypoint-edge-with-corner.png differ diff --git a/packages/dmn-editor/tests/e2e/__screenshots__/chromium/drgRequirements/delete-knowledge-requirement-waypoint-straight-edge.png b/packages/dmn-editor/tests/e2e/__screenshots__/chromium/drgRequirements/delete-knowledge-requirement-waypoint-straight-edge.png new file mode 100644 index 00000000000..c387a1b35fe Binary files /dev/null and b/packages/dmn-editor/tests/e2e/__screenshots__/chromium/drgRequirements/delete-knowledge-requirement-waypoint-straight-edge.png differ diff --git a/packages/dmn-editor/tests/e2e/__screenshots__/chromium/drgRequirements/add-authority-requirement-waypoint-and-not-move-it.png b/packages/dmn-editor/tests/e2e/__screenshots__/chromium/drgRequirements/move-authority-requirement-ending-waypoint.png similarity index 100% rename from packages/dmn-editor/tests/e2e/__screenshots__/chromium/drgRequirements/add-authority-requirement-waypoint-and-not-move-it.png rename to packages/dmn-editor/tests/e2e/__screenshots__/chromium/drgRequirements/move-authority-requirement-ending-waypoint.png diff --git a/packages/dmn-editor/tests/e2e/__screenshots__/chromium/drgRequirements/move-authority-requirement-middle-waypoint.png b/packages/dmn-editor/tests/e2e/__screenshots__/chromium/drgRequirements/move-authority-requirement-middle-waypoint.png new file mode 100644 index 00000000000..2ec8554336a Binary files /dev/null and b/packages/dmn-editor/tests/e2e/__screenshots__/chromium/drgRequirements/move-authority-requirement-middle-waypoint.png differ diff --git a/packages/dmn-editor/tests/e2e/__screenshots__/chromium/drgRequirements/move-authority-requirement-middle-waypoints.png b/packages/dmn-editor/tests/e2e/__screenshots__/chromium/drgRequirements/move-authority-requirement-middle-waypoints.png new file mode 100644 index 00000000000..a06794348bf Binary files /dev/null and b/packages/dmn-editor/tests/e2e/__screenshots__/chromium/drgRequirements/move-authority-requirement-middle-waypoints.png differ diff --git a/packages/dmn-editor/tests/e2e/__screenshots__/chromium/drgRequirements/move-authority-requirement-starting-and-ending-waypoint.png b/packages/dmn-editor/tests/e2e/__screenshots__/chromium/drgRequirements/move-authority-requirement-starting-and-ending-waypoint.png new file mode 100644 index 00000000000..4fb1260a6fe Binary files /dev/null and b/packages/dmn-editor/tests/e2e/__screenshots__/chromium/drgRequirements/move-authority-requirement-starting-and-ending-waypoint.png differ diff --git a/packages/dmn-editor/tests/e2e/__screenshots__/chromium/drgRequirements/add-information-requirement-waypoint-and-not-move-it.png b/packages/dmn-editor/tests/e2e/__screenshots__/chromium/drgRequirements/move-information-requirement-ending-waypoint.png similarity index 100% rename from packages/dmn-editor/tests/e2e/__screenshots__/chromium/drgRequirements/add-information-requirement-waypoint-and-not-move-it.png rename to packages/dmn-editor/tests/e2e/__screenshots__/chromium/drgRequirements/move-information-requirement-ending-waypoint.png diff --git a/packages/dmn-editor/tests/e2e/__screenshots__/chromium/drgRequirements/move-information-requirement-middle-waypoint.png b/packages/dmn-editor/tests/e2e/__screenshots__/chromium/drgRequirements/move-information-requirement-middle-waypoint.png new file mode 100644 index 00000000000..dc6511ae185 Binary files /dev/null and b/packages/dmn-editor/tests/e2e/__screenshots__/chromium/drgRequirements/move-information-requirement-middle-waypoint.png differ diff --git a/packages/dmn-editor/tests/e2e/__screenshots__/chromium/drgRequirements/move-information-requirement-middle-waypoints.png b/packages/dmn-editor/tests/e2e/__screenshots__/chromium/drgRequirements/move-information-requirement-middle-waypoints.png new file mode 100644 index 00000000000..b89cb548531 Binary files /dev/null and b/packages/dmn-editor/tests/e2e/__screenshots__/chromium/drgRequirements/move-information-requirement-middle-waypoints.png differ diff --git a/packages/dmn-editor/tests/e2e/__screenshots__/chromium/drgRequirements/move-information-requirement-starting-and-ending-waypoint.png b/packages/dmn-editor/tests/e2e/__screenshots__/chromium/drgRequirements/move-information-requirement-starting-and-ending-waypoint.png new file mode 100644 index 00000000000..3a9cb3333f4 Binary files /dev/null and b/packages/dmn-editor/tests/e2e/__screenshots__/chromium/drgRequirements/move-information-requirement-starting-and-ending-waypoint.png differ diff --git a/packages/dmn-editor/tests/e2e/__screenshots__/chromium/drgRequirements/add-knowledge-requirement-waypoint-and-not-move-it.png b/packages/dmn-editor/tests/e2e/__screenshots__/chromium/drgRequirements/move-knowledge-requirement-ending-waypoint.png similarity index 100% rename from packages/dmn-editor/tests/e2e/__screenshots__/chromium/drgRequirements/add-knowledge-requirement-waypoint-and-not-move-it.png rename to packages/dmn-editor/tests/e2e/__screenshots__/chromium/drgRequirements/move-knowledge-requirement-ending-waypoint.png diff --git a/packages/dmn-editor/tests/e2e/__screenshots__/chromium/drgRequirements/move-knowledge-requirement-middle-waypoint.png b/packages/dmn-editor/tests/e2e/__screenshots__/chromium/drgRequirements/move-knowledge-requirement-middle-waypoint.png new file mode 100644 index 00000000000..0370ed76f18 Binary files /dev/null and b/packages/dmn-editor/tests/e2e/__screenshots__/chromium/drgRequirements/move-knowledge-requirement-middle-waypoint.png differ diff --git a/packages/dmn-editor/tests/e2e/__screenshots__/chromium/drgRequirements/move-knowledge-requirement-middle-waypoints.png b/packages/dmn-editor/tests/e2e/__screenshots__/chromium/drgRequirements/move-knowledge-requirement-middle-waypoints.png new file mode 100644 index 00000000000..8ac341e9675 Binary files /dev/null and b/packages/dmn-editor/tests/e2e/__screenshots__/chromium/drgRequirements/move-knowledge-requirement-middle-waypoints.png differ diff --git a/packages/dmn-editor/tests/e2e/__screenshots__/chromium/drgRequirements/move-knowledge-requirement-starting-and-ending-waypoint.png b/packages/dmn-editor/tests/e2e/__screenshots__/chromium/drgRequirements/move-knowledge-requirement-starting-and-ending-waypoint.png new file mode 100644 index 00000000000..75f1f6abe87 Binary files /dev/null and b/packages/dmn-editor/tests/e2e/__screenshots__/chromium/drgRequirements/move-knowledge-requirement-starting-and-ending-waypoint.png differ diff --git a/packages/dmn-editor/tests/e2e/__screenshots__/webkit/drdArtifacts/add-multiple-association-waypoint-and-not-move-them.png b/packages/dmn-editor/tests/e2e/__screenshots__/webkit/drdArtifacts/add-multiple-association-waypoint-and-not-move-them.png deleted file mode 100644 index 9b648a3f78c..00000000000 Binary files a/packages/dmn-editor/tests/e2e/__screenshots__/webkit/drdArtifacts/add-multiple-association-waypoint-and-not-move-them.png and /dev/null differ diff --git a/packages/dmn-editor/tests/e2e/__screenshots__/webkit/drdArtifacts/add-association-waypoint-and-not-move-it.png b/packages/dmn-editor/tests/e2e/__screenshots__/webkit/drdArtifacts/move-association-ending-waypoint.png similarity index 100% rename from packages/dmn-editor/tests/e2e/__screenshots__/webkit/drdArtifacts/add-association-waypoint-and-not-move-it.png rename to packages/dmn-editor/tests/e2e/__screenshots__/webkit/drdArtifacts/move-association-ending-waypoint.png diff --git a/packages/dmn-editor/tests/e2e/__screenshots__/webkit/drdArtifacts/move-association-starting-and-ending-waypoint.png b/packages/dmn-editor/tests/e2e/__screenshots__/webkit/drdArtifacts/move-association-starting-and-ending-waypoint.png new file mode 100644 index 00000000000..ddbd826b973 Binary files /dev/null and b/packages/dmn-editor/tests/e2e/__screenshots__/webkit/drdArtifacts/move-association-starting-and-ending-waypoint.png differ diff --git a/packages/dmn-editor/tests/e2e/__screenshots__/webkit/drgRequirements/add-multiple-authority-requirement-waypoints-and-not-move-them.png b/packages/dmn-editor/tests/e2e/__screenshots__/webkit/drgRequirements/add-multiple-authority-requirement-waypoints-and-not-move-them.png deleted file mode 100644 index b84a0bd9786..00000000000 Binary files a/packages/dmn-editor/tests/e2e/__screenshots__/webkit/drgRequirements/add-multiple-authority-requirement-waypoints-and-not-move-them.png and /dev/null differ diff --git a/packages/dmn-editor/tests/e2e/__screenshots__/webkit/drgRequirements/add-multiple-information-requirement-waypoints-and-not-move-them.png b/packages/dmn-editor/tests/e2e/__screenshots__/webkit/drgRequirements/add-multiple-information-requirement-waypoints-and-not-move-them.png deleted file mode 100644 index 5c5377fd5c0..00000000000 Binary files a/packages/dmn-editor/tests/e2e/__screenshots__/webkit/drgRequirements/add-multiple-information-requirement-waypoints-and-not-move-them.png and /dev/null differ diff --git a/packages/dmn-editor/tests/e2e/__screenshots__/webkit/drgRequirements/add-multiple-knowledge-requirement-waypoints-and-not-move-them.png b/packages/dmn-editor/tests/e2e/__screenshots__/webkit/drgRequirements/add-multiple-knowledge-requirement-waypoints-and-not-move-them.png deleted file mode 100644 index a1ef8b36f19..00000000000 Binary files a/packages/dmn-editor/tests/e2e/__screenshots__/webkit/drgRequirements/add-multiple-knowledge-requirement-waypoints-and-not-move-them.png and /dev/null differ diff --git a/packages/dmn-editor/tests/e2e/__screenshots__/webkit/drgRequirements/add-authority-requirement-waypoint-and-not-move-it.png b/packages/dmn-editor/tests/e2e/__screenshots__/webkit/drgRequirements/move-authority-requirement-ending-waypoint.png similarity index 100% rename from packages/dmn-editor/tests/e2e/__screenshots__/webkit/drgRequirements/add-authority-requirement-waypoint-and-not-move-it.png rename to packages/dmn-editor/tests/e2e/__screenshots__/webkit/drgRequirements/move-authority-requirement-ending-waypoint.png diff --git a/packages/dmn-editor/tests/e2e/__screenshots__/webkit/drgRequirements/move-authority-requirement-starting-and-ending-waypoint.png b/packages/dmn-editor/tests/e2e/__screenshots__/webkit/drgRequirements/move-authority-requirement-starting-and-ending-waypoint.png new file mode 100644 index 00000000000..19677f6403f Binary files /dev/null and b/packages/dmn-editor/tests/e2e/__screenshots__/webkit/drgRequirements/move-authority-requirement-starting-and-ending-waypoint.png differ diff --git a/packages/dmn-editor/tests/e2e/__screenshots__/webkit/drgRequirements/add-information-requirement-waypoint-and-not-move-it.png b/packages/dmn-editor/tests/e2e/__screenshots__/webkit/drgRequirements/move-information-requirement-ending-waypoint.png similarity index 100% rename from packages/dmn-editor/tests/e2e/__screenshots__/webkit/drgRequirements/add-information-requirement-waypoint-and-not-move-it.png rename to packages/dmn-editor/tests/e2e/__screenshots__/webkit/drgRequirements/move-information-requirement-ending-waypoint.png diff --git a/packages/dmn-editor/tests/e2e/__screenshots__/webkit/drgRequirements/move-information-requirement-starting-and-ending-waypoint.png b/packages/dmn-editor/tests/e2e/__screenshots__/webkit/drgRequirements/move-information-requirement-starting-and-ending-waypoint.png new file mode 100644 index 00000000000..a2f7da470ab Binary files /dev/null and b/packages/dmn-editor/tests/e2e/__screenshots__/webkit/drgRequirements/move-information-requirement-starting-and-ending-waypoint.png differ diff --git a/packages/dmn-editor/tests/e2e/__screenshots__/webkit/drgRequirements/add-knowledge-requirement-waypoint-and-not-move-it.png b/packages/dmn-editor/tests/e2e/__screenshots__/webkit/drgRequirements/move-knowledge-requirement-ending-waypoint.png similarity index 100% rename from packages/dmn-editor/tests/e2e/__screenshots__/webkit/drgRequirements/add-knowledge-requirement-waypoint-and-not-move-it.png rename to packages/dmn-editor/tests/e2e/__screenshots__/webkit/drgRequirements/move-knowledge-requirement-ending-waypoint.png diff --git a/packages/dmn-editor/tests/e2e/__screenshots__/webkit/drgRequirements/move-knowledge-requirement-starting-and-ending-waypoint.png b/packages/dmn-editor/tests/e2e/__screenshots__/webkit/drgRequirements/move-knowledge-requirement-starting-and-ending-waypoint.png new file mode 100644 index 00000000000..b48a4cc2fc0 Binary files /dev/null and b/packages/dmn-editor/tests/e2e/__screenshots__/webkit/drgRequirements/move-knowledge-requirement-starting-and-ending-waypoint.png differ diff --git a/packages/dmn-editor/tests/e2e/drdArtifacts/addAssociationWaypoint.spec.ts b/packages/dmn-editor/tests/e2e/drdArtifacts/addAssociationWaypoint.spec.ts index fcfc251d151..b8c79bb6751 100644 --- a/packages/dmn-editor/tests/e2e/drdArtifacts/addAssociationWaypoint.spec.ts +++ b/packages/dmn-editor/tests/e2e/drdArtifacts/addAssociationWaypoint.spec.ts @@ -35,29 +35,46 @@ test.describe("Add edge waypoint - Association", () => { }); }); - test("should add single waypoint to Association edge and should not move when the ending node is moved", async ({ - diagram, - nodes, - edges, - }) => { + test("should attach single Association waypoint to the edge", async ({ edges }) => { await edges.addWaypoint({ from: DefaultNodeName.INPUT_DATA, to: DefaultNodeName.TEXT_ANNOTATION }); - await nodes.move({ name: DefaultNodeName.TEXT_ANNOTATION, targetPosition: { x: 500, y: 300 } }); - await expect(diagram.get()).toHaveScreenshot("add-association-waypoint-and-not-move-it.png"); + await expect( + await edges.getWaypoint({ + from: DefaultNodeName.INPUT_DATA, + to: DefaultNodeName.TEXT_ANNOTATION, + waypointIndex: 1, + }) + ).toBeAttached(); + await expect( + await edges.getWaypoint({ + from: DefaultNodeName.INPUT_DATA, + to: DefaultNodeName.TEXT_ANNOTATION, + waypointIndex: 2, + }) + ).not.toBeAttached(); }); - test("should add multiple waypoints to Association edge and should not move when the ending nodes are moved", async ({ - diagram, - nodes, - edges, - }) => { + test("should attach multiple Association waypoints to the edge", async ({ edges }) => { await edges.addWaypoint({ from: DefaultNodeName.INPUT_DATA, to: DefaultNodeName.TEXT_ANNOTATION }); - await nodes.move({ name: DefaultNodeName.TEXT_ANNOTATION, targetPosition: { x: 200, y: 500 } }); - - await edges.addWaypoint({ from: DefaultNodeName.INPUT_DATA, to: DefaultNodeName.TEXT_ANNOTATION }); - await nodes.move({ name: DefaultNodeName.TEXT_ANNOTATION, targetPosition: { x: 500, y: 500 } }); - await nodes.move({ name: DefaultNodeName.INPUT_DATA, targetPosition: { x: 500, y: 100 } }); + await edges.addWaypoint({ + from: DefaultNodeName.INPUT_DATA, + to: DefaultNodeName.TEXT_ANNOTATION, + afterWaypointIndex: 1, + }); - await expect(diagram.get()).toHaveScreenshot("add-multiple-association-waypoint-and-not-move-them.png"); + await expect( + await edges.getWaypoint({ + from: DefaultNodeName.INPUT_DATA, + to: DefaultNodeName.TEXT_ANNOTATION, + waypointIndex: 1, + }) + ).toBeAttached(); + await expect( + await edges.getWaypoint({ + from: DefaultNodeName.INPUT_DATA, + to: DefaultNodeName.TEXT_ANNOTATION, + waypointIndex: 2, + }) + ).toBeAttached(); }); }); diff --git a/packages/dmn-editor/tests/e2e/drdArtifacts/deleteAssociationWaypoint.spec.ts b/packages/dmn-editor/tests/e2e/drdArtifacts/deleteAssociationWaypoint.spec.ts new file mode 100644 index 00000000000..c98d689c739 --- /dev/null +++ b/packages/dmn-editor/tests/e2e/drdArtifacts/deleteAssociationWaypoint.spec.ts @@ -0,0 +1,138 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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 { expect } from "@playwright/test"; +import { test } from "../__fixtures__/base"; +import { DefaultNodeName, NodeType } from "../__fixtures__/nodes"; +import { TestAnnotations } from "@kie-tools/playwright-base/annotations"; + +test.beforeEach(async ({ editor }) => { + await editor.open(); +}); + +test.describe("Delete edge waypoint - Association", () => { + test.beforeEach(async ({ palette, nodes, browserName }) => { + test.skip(browserName === "webkit", "https://github.com/apache/incubator-kie-issues/issues/991"); + test.info().annotations.push({ + type: TestAnnotations.REGRESSION, + description: "https://github.com/apache/incubator-kie-issues/issues/991", + }); + + await palette.dragNewNode({ type: NodeType.INPUT_DATA, targetPosition: { x: 100, y: 100 } }); + await nodes.dragNewConnectedNode({ + from: DefaultNodeName.INPUT_DATA, + type: NodeType.TEXT_ANNOTATION, + targetPosition: { x: 100, y: 300 }, + }); + }); + + test("should delete one Association edge waypoint", async ({ edges }) => { + await edges.addWaypoint({ from: DefaultNodeName.INPUT_DATA, to: DefaultNodeName.TEXT_ANNOTATION }); + + await edges.deleteWaypoint({ + from: DefaultNodeName.INPUT_DATA, + to: DefaultNodeName.TEXT_ANNOTATION, + waypointIndex: 1, + }); + + await expect( + await edges.getWaypoint({ + from: DefaultNodeName.INPUT_DATA, + to: DefaultNodeName.TEXT_ANNOTATION, + waypointIndex: 1, + }) + ).not.toBeAttached(); + }); + + test("should move and delete one Association edge waypoint", async ({ diagram, edges }) => { + await edges.addWaypoint({ from: DefaultNodeName.INPUT_DATA, to: DefaultNodeName.TEXT_ANNOTATION }); + await edges.moveWaypoint({ + from: DefaultNodeName.INPUT_DATA, + to: DefaultNodeName.TEXT_ANNOTATION, + waypointIndex: 1, + targetPosition: { x: 500, y: 300 }, + }); + + await edges.deleteWaypoint({ + from: DefaultNodeName.INPUT_DATA, + to: DefaultNodeName.TEXT_ANNOTATION, + waypointIndex: 1, + }); + await expect(diagram.get()).toHaveScreenshot("delete-association-waypoint-straight-edge.png"); + }); + + test("should delete two Association edge waypoints", async ({ edges }) => { + await edges.addWaypoint({ from: DefaultNodeName.INPUT_DATA, to: DefaultNodeName.TEXT_ANNOTATION }); + await edges.addWaypoint({ + from: DefaultNodeName.INPUT_DATA, + to: DefaultNodeName.TEXT_ANNOTATION, + afterWaypointIndex: 1, + }); + + await edges.deleteWaypoints({ + from: DefaultNodeName.INPUT_DATA, + to: DefaultNodeName.TEXT_ANNOTATION, + waypointsCount: 2, + }); + + await expect( + await edges.getWaypoint({ + from: DefaultNodeName.INPUT_DATA, + to: DefaultNodeName.TEXT_ANNOTATION, + waypointIndex: 1, + }) + ).not.toBeAttached(); + await expect( + await edges.getWaypoint({ + from: DefaultNodeName.INPUT_DATA, + to: DefaultNodeName.TEXT_ANNOTATION, + waypointIndex: 2, + }) + ).not.toBeAttached(); + }); + + test("should move two and delete one Association edge waypoints", async ({ diagram, edges }) => { + await edges.addWaypoint({ from: DefaultNodeName.INPUT_DATA, to: DefaultNodeName.TEXT_ANNOTATION }); + await edges.addWaypoint({ + from: DefaultNodeName.INPUT_DATA, + to: DefaultNodeName.TEXT_ANNOTATION, + afterWaypointIndex: 1, + }); + await edges.moveWaypoint({ + from: DefaultNodeName.INPUT_DATA, + to: DefaultNodeName.TEXT_ANNOTATION, + waypointIndex: 1, + targetPosition: { x: 500, y: 100 }, + }); + await edges.moveWaypoint({ + from: DefaultNodeName.INPUT_DATA, + to: DefaultNodeName.TEXT_ANNOTATION, + waypointIndex: 2, + targetPosition: { x: 500, y: 500 }, + }); + + await edges.deleteWaypoint({ + from: DefaultNodeName.INPUT_DATA, + to: DefaultNodeName.TEXT_ANNOTATION, + waypointIndex: 1, + }); + + await expect(diagram.get()).toHaveScreenshot("delete-association-waypoint-edge-with-corner.png"); + }); +}); diff --git a/packages/dmn-editor/tests/e2e/drdArtifacts/moveAssociationWaypoint.spec.ts b/packages/dmn-editor/tests/e2e/drdArtifacts/moveAssociationWaypoint.spec.ts new file mode 100644 index 00000000000..4c2ca38c365 --- /dev/null +++ b/packages/dmn-editor/tests/e2e/drdArtifacts/moveAssociationWaypoint.spec.ts @@ -0,0 +1,126 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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 { expect } from "@playwright/test"; +import { test } from "../__fixtures__/base"; +import { DefaultNodeName, NodeType } from "../__fixtures__/nodes"; +import { TestAnnotations } from "@kie-tools/playwright-base/annotations"; + +test.beforeEach(async ({ editor }) => { + await editor.open(); +}); + +test.describe("Move edge waypoint - Association", () => { + test.beforeEach(async ({ palette, nodes }) => { + await palette.dragNewNode({ type: NodeType.INPUT_DATA, targetPosition: { x: 100, y: 100 } }); + await nodes.dragNewConnectedNode({ + from: DefaultNodeName.INPUT_DATA, + type: NodeType.TEXT_ANNOTATION, + targetPosition: { x: 100, y: 300 }, + }); + }); + + test.describe("Add Single Waypoint", () => { + test("Association edge waypoint should not move when the ending node is moved", async ({ + diagram, + edges, + nodes, + }) => { + await edges.addWaypoint({ from: DefaultNodeName.INPUT_DATA, to: DefaultNodeName.TEXT_ANNOTATION }); + await nodes.move({ name: DefaultNodeName.TEXT_ANNOTATION, targetPosition: { x: 500, y: 300 } }); + + await expect(diagram.get()).toHaveScreenshot("move-association-ending-waypoint.png"); + }); + + test("Association edge ending nodes should not move when the waypoint is moved", async ({ + diagram, + edges, + browserName, + }) => { + test.skip(browserName === "webkit", "https://github.com/apache/incubator-kie-issues/issues/991"); + test.info().annotations.push({ + type: TestAnnotations.REGRESSION, + description: "https://github.com/apache/incubator-kie-issues/issues/991", + }); + + await edges.addWaypoint({ from: DefaultNodeName.INPUT_DATA, to: DefaultNodeName.TEXT_ANNOTATION }); + await edges.moveWaypoint({ + from: DefaultNodeName.INPUT_DATA, + to: DefaultNodeName.TEXT_ANNOTATION, + waypointIndex: 1, + targetPosition: { x: 500, y: 300 }, + }); + + await expect(diagram.get()).toHaveScreenshot("move-association-middle-waypoint.png"); + }); + }); + + test.describe("Add Multiple Waypoints", () => { + test("Association edge waypoints should not move when the ending nodes are moved", async ({ + diagram, + nodes, + edges, + }) => { + await edges.addWaypoint({ from: DefaultNodeName.INPUT_DATA, to: DefaultNodeName.TEXT_ANNOTATION }); + await edges.addWaypoint({ + from: DefaultNodeName.INPUT_DATA, + to: DefaultNodeName.TEXT_ANNOTATION, + afterWaypointIndex: 1, + }); + await nodes.move({ name: DefaultNodeName.TEXT_ANNOTATION, targetPosition: { x: 500, y: 500 } }); + await nodes.move({ name: DefaultNodeName.INPUT_DATA, targetPosition: { x: 500, y: 100 } }); + + await expect(diagram.get()).toHaveScreenshot("move-association-starting-and-ending-waypoint.png"); + }); + + test("Association edge ending nodes should not move when the waypoints are moved", async ({ + diagram, + edges, + browserName, + }) => { + test.skip(browserName === "webkit", "https://github.com/apache/incubator-kie-issues/issues/991"); + test.info().annotations.push({ + type: TestAnnotations.REGRESSION, + description: "https://github.com/apache/incubator-kie-issues/issues/991", + }); + + await edges.addWaypoint({ from: DefaultNodeName.INPUT_DATA, to: DefaultNodeName.TEXT_ANNOTATION }); + await edges.addWaypoint({ + from: DefaultNodeName.INPUT_DATA, + to: DefaultNodeName.TEXT_ANNOTATION, + afterWaypointIndex: 1, + }); + + await edges.moveWaypoint({ + from: DefaultNodeName.INPUT_DATA, + to: DefaultNodeName.TEXT_ANNOTATION, + waypointIndex: 1, + targetPosition: { x: 500, y: 100 }, + }); + await edges.moveWaypoint({ + from: DefaultNodeName.INPUT_DATA, + to: DefaultNodeName.TEXT_ANNOTATION, + waypointIndex: 2, + targetPosition: { x: 500, y: 500 }, + }); + + await expect(diagram.get()).toHaveScreenshot("move-association-middle-waypoints.png"); + }); + }); +}); diff --git a/packages/dmn-editor/tests/e2e/drgElements/addBkm.spec.ts b/packages/dmn-editor/tests/e2e/drgElements/addBkm.spec.ts index 029a283fe33..03a858f2dcc 100644 --- a/packages/dmn-editor/tests/e2e/drgElements/addBkm.spec.ts +++ b/packages/dmn-editor/tests/e2e/drgElements/addBkm.spec.ts @@ -19,6 +19,7 @@ import { test, expect } from "../__fixtures__/base"; import { EdgeType } from "../__fixtures__/edges"; +import { DataType } from "../__fixtures__/jsonModel"; import { DefaultNodeName, NodeType } from "../__fixtures__/nodes"; test.beforeEach(async ({ editor }) => { @@ -28,11 +29,30 @@ test.beforeEach(async ({ editor }) => { test.describe("Add node - BKM", () => { test.describe("Add to the DRG", () => { test.describe("add from the palette", () => { - test("should add new BKM node from palette", async ({ palette, nodes, diagram }) => { + test("should add new BKM node from palette", async ({ jsonModel, palette, nodes, diagram }) => { await palette.dragNewNode({ type: NodeType.BKM, targetPosition: { x: 100, y: 100 } }); expect(nodes.get({ name: DefaultNodeName.BKM })).toBeAttached(); await expect(diagram.get()).toHaveScreenshot("add-bkm-node-from-palette.png"); + + // JSON model assertions + const bkm = await jsonModel.drgElements.getBkm({ drgElementIndex: 0, drdIndex: 0 }); + expect(bkm).toEqual({ + __$$element: "businessKnowledgeModel", + "@_id": bkm["@_id"], + "@_name": DefaultNodeName.BKM, + variable: { + "@_id": bkm.variable?.["@_id"], + "@_name": DefaultNodeName.BKM, + "@_typeRef": DataType.Undefined, + }, + }); + expect(await jsonModel.drd.getDrgElementBoundsOnDrd({ drgElementIndex: 0, drdIndex: 0 })).toEqual({ + "@_x": 0, + "@_y": 0, + "@_width": 160, + "@_height": 80, + }); }); }); diff --git a/packages/dmn-editor/tests/e2e/drgElements/addDecision.spec.ts b/packages/dmn-editor/tests/e2e/drgElements/addDecision.spec.ts index ac26ad6c4d7..e4dd1156876 100644 --- a/packages/dmn-editor/tests/e2e/drgElements/addDecision.spec.ts +++ b/packages/dmn-editor/tests/e2e/drgElements/addDecision.spec.ts @@ -19,6 +19,7 @@ import { test, expect } from "../__fixtures__/base"; import { EdgeType } from "../__fixtures__/edges"; +import { DataType } from "../__fixtures__/jsonModel"; import { DefaultNodeName, NodeType } from "../__fixtures__/nodes"; test.beforeEach(async ({ editor }) => { @@ -28,16 +29,41 @@ test.beforeEach(async ({ editor }) => { test.describe("Add node - Decision", () => { test.describe("Add to the DRG", () => { test.describe("add from the palette", () => { - test("should add Decision node from palette", async ({ palette, nodes, diagram }) => { + test("should add Decision node from palette", async ({ jsonModel, palette, nodes, diagram }) => { await palette.dragNewNode({ type: NodeType.DECISION, targetPosition: { x: 100, y: 100 } }); expect(nodes.get({ name: DefaultNodeName.DECISION })).toBeAttached(); await expect(diagram.get()).toHaveScreenshot("add-decision-node-from-palette.png"); + + // JSON model assertions + const decision = await jsonModel.drgElements.getDecision({ drgElementIndex: 0, drdIndex: 0 }); + expect(decision).toEqual({ + __$$element: "decision", + "@_id": decision["@_id"], + "@_name": DefaultNodeName.DECISION, + variable: { + "@_id": decision.variable?.["@_id"], + "@_name": DefaultNodeName.DECISION, + "@_typeRef": DataType.Undefined, + }, + }); + expect(await jsonModel.drd.getDrgElementBoundsOnDrd({ drgElementIndex: 0, drdIndex: 0 })).toEqual({ + "@_x": 0, + "@_y": 0, + "@_width": 160, + "@_height": 80, + }); }); }); test.describe("add from nodes", () => { - test("should add connected Decision node from Input Data node", async ({ diagram, palette, nodes, edges }) => { + test("should add connected Decision node from Input Data node", async ({ + jsonModel, + diagram, + palette, + nodes, + edges, + }) => { await palette.dragNewNode({ type: NodeType.INPUT_DATA, targetPosition: { x: 100, y: 100 }, @@ -53,6 +79,38 @@ test.describe("Add node - Decision", () => { EdgeType.INFORMATION_REQUIREMENT ); await expect(diagram.get()).toHaveScreenshot("add-decision-node-from-input-data-node.png"); + + // JSON model assertions + const inputData = await jsonModel.drgElements.getInputData({ drgElementIndex: 0, drdIndex: 0 }); + expect(inputData).toEqual({ + __$$element: "inputData", + "@_id": inputData["@_id"], + "@_name": DefaultNodeName.INPUT_DATA, + variable: { + "@_id": inputData.variable?.["@_id"], + "@_name": DefaultNodeName.INPUT_DATA, + "@_typeRef": DataType.Undefined, + }, + }); + const decision = await jsonModel.drgElements.getDecision({ drgElementIndex: 1, drdIndex: 0 }); + expect(decision).toEqual({ + __$$element: "decision", + "@_id": decision["@_id"], + "@_name": DefaultNodeName.DECISION, + informationRequirement: [ + { + "@_id": decision.informationRequirement?.[0]["@_id"], + requiredInput: { + "@_href": "#" + inputData["@_id"], + }, + }, + ], + variable: { + "@_id": decision.variable?.["@_id"], + "@_name": DefaultNodeName.DECISION, + "@_typeRef": DataType.Undefined, + }, + }); }); test("should add connected Decision node from Decision node", async ({ diagram, palette, nodes, edges }) => { diff --git a/packages/dmn-editor/tests/e2e/drgElements/addDecisionService.spec.ts b/packages/dmn-editor/tests/e2e/drgElements/addDecisionService.spec.ts index 40a4ae0e64e..59b6437ec2b 100644 --- a/packages/dmn-editor/tests/e2e/drgElements/addDecisionService.spec.ts +++ b/packages/dmn-editor/tests/e2e/drgElements/addDecisionService.spec.ts @@ -18,6 +18,7 @@ */ import { test, expect } from "../__fixtures__/base"; +import { DataType } from "../__fixtures__/jsonModel"; import { DefaultNodeName, NodeType } from "../__fixtures__/nodes"; test.beforeEach(async ({ editor }) => { @@ -27,11 +28,33 @@ test.beforeEach(async ({ editor }) => { test.describe("Add node - Decision Service", () => { test.describe("Add to the DRG", () => { test.describe("add from the palette", () => { - test("should add Decision Service node from palette", async ({ palette, nodes, diagram }) => { + test("should add Decision Service node from palette", async ({ jsonModel, palette, nodes, diagram }) => { await palette.dragNewNode({ type: NodeType.DECISION_SERVICE, targetPosition: { x: 100, y: 100 } }); expect(nodes.get({ name: DefaultNodeName.DECISION_SERVICE })).toBeAttached(); await expect(diagram.get()).toHaveScreenshot("add-decision-service-node-from-palette.png"); + + // JSON model assertions + // JSON model assertions + const decisionService = await jsonModel.drgElements.getDecisionService({ drgElementIndex: 0, drdIndex: 0 }); + expect(decisionService).toEqual({ + __$$element: "decisionService", + "@_id": decisionService["@_id"], + "@_name": DefaultNodeName.DECISION_SERVICE, + inputData: [], + inputDecision: [], + variable: { + "@_id": decisionService.variable?.["@_id"], + "@_name": DefaultNodeName.DECISION_SERVICE, + "@_typeRef": DataType.Undefined, + }, + }); + expect(await jsonModel.drd.getDrgElementBoundsOnDrd({ drgElementIndex: 0, drdIndex: 0 })).toEqual({ + "@_x": 0, + "@_y": 0, + "@_width": 320, + "@_height": 320, + }); }); }); }); diff --git a/packages/dmn-editor/tests/e2e/drgElements/addInputData.spec.ts b/packages/dmn-editor/tests/e2e/drgElements/addInputData.spec.ts index d2c6b99e018..1ceb8771677 100644 --- a/packages/dmn-editor/tests/e2e/drgElements/addInputData.spec.ts +++ b/packages/dmn-editor/tests/e2e/drgElements/addInputData.spec.ts @@ -18,6 +18,7 @@ */ import { test, expect } from "../__fixtures__/base"; +import { DataType } from "../__fixtures__/jsonModel"; import { DefaultNodeName, NodeType } from "../__fixtures__/nodes"; test.beforeEach(async ({ editor }) => { @@ -27,11 +28,30 @@ test.beforeEach(async ({ editor }) => { test.describe("Add node - Input Data", () => { test.describe("Add to the DRG", () => { test.describe("add from the palette", () => { - test("should add Input Data node from palette", async ({ palette, nodes, diagram }) => { + test("should add Input Data node from palette", async ({ jsonModel, palette, nodes, diagram }) => { await palette.dragNewNode({ type: NodeType.INPUT_DATA, targetPosition: { x: 100, y: 100 } }); expect(nodes.get({ name: DefaultNodeName.INPUT_DATA })).toBeAttached(); await expect(diagram.get()).toHaveScreenshot("add-input-data-node-from-palette.png"); + + // JSON model assertions + const inputData = await jsonModel.drgElements.getInputData({ drgElementIndex: 0, drdIndex: 0 }); + expect(inputData).toEqual({ + __$$element: "inputData", + "@_id": inputData["@_id"], + "@_name": DefaultNodeName.INPUT_DATA, + variable: { + "@_id": inputData.variable?.["@_id"], + "@_name": DefaultNodeName.INPUT_DATA, + "@_typeRef": DataType.Undefined, + }, + }); + expect(await jsonModel.drd.getDrgElementBoundsOnDrd({ drgElementIndex: 0, drdIndex: 0 })).toEqual({ + "@_x": 0, + "@_y": 0, + "@_width": 160, + "@_height": 80, + }); }); }); }); diff --git a/packages/dmn-editor/tests/e2e/drgElements/addKnowledgeSource.spec.ts b/packages/dmn-editor/tests/e2e/drgElements/addKnowledgeSource.spec.ts index b0d001a9fd8..28ef3c99185 100644 --- a/packages/dmn-editor/tests/e2e/drgElements/addKnowledgeSource.spec.ts +++ b/packages/dmn-editor/tests/e2e/drgElements/addKnowledgeSource.spec.ts @@ -28,11 +28,25 @@ test.beforeEach(async ({ editor }) => { test.describe("Add node - Knowledge Source", () => { test.describe("Add to the DRG", () => { test.describe("add from the palette", () => { - test("should add Knowledge Source node from palette", async ({ palette, nodes, diagram }) => { + test("should add Knowledge Source node from palette", async ({ jsonModel, palette, nodes, diagram }) => { await palette.dragNewNode({ type: NodeType.KNOWLEDGE_SOURCE, targetPosition: { x: 100, y: 100 } }); expect(nodes.get({ name: DefaultNodeName.KNOWLEDGE_SOURCE })).toBeAttached(); await expect(diagram.get()).toHaveScreenshot("add-knowledge-source-node-from-palette.png"); + + // JSON model assertions + const knowledgeSource = await jsonModel.drgElements.getKnowledgeSource({ drgElementIndex: 0, drdIndex: 0 }); + expect(knowledgeSource).toEqual({ + __$$element: "knowledgeSource", + "@_id": knowledgeSource["@_id"], + "@_name": DefaultNodeName.KNOWLEDGE_SOURCE, + }); + expect(await jsonModel.drd.getDrgElementBoundsOnDrd({ drgElementIndex: 0, drdIndex: 0 })).toEqual({ + "@_x": 0, + "@_y": 0, + "@_width": 160, + "@_height": 80, + }); }); }); diff --git a/packages/dmn-editor/tests/e2e/drgRequirements/addAuthorityRequirementWaypoint.spec.ts b/packages/dmn-editor/tests/e2e/drgRequirements/addAuthorityRequirementWaypoint.spec.ts index 31480a53cbf..6be0d070a50 100644 --- a/packages/dmn-editor/tests/e2e/drgRequirements/addAuthorityRequirementWaypoint.spec.ts +++ b/packages/dmn-editor/tests/e2e/drgRequirements/addAuthorityRequirementWaypoint.spec.ts @@ -35,29 +35,45 @@ test.describe("Add edge waypoint - Authority Requirement", () => { }); }); - test("should add single waypoint to Authority Requirement and should not move when the ending node is moved", async ({ - diagram, - nodes, - edges, - }) => { + test("should attach single Authority Requirement waypoint to the edge", async ({ edges }) => { await edges.addWaypoint({ from: DefaultNodeName.INPUT_DATA, to: DefaultNodeName.KNOWLEDGE_SOURCE }); - await nodes.move({ name: DefaultNodeName.KNOWLEDGE_SOURCE, targetPosition: { x: 300, y: 300 } }); - - await expect(diagram.get()).toHaveScreenshot("add-authority-requirement-waypoint-and-not-move-it.png"); + await expect( + await edges.getWaypoint({ + from: DefaultNodeName.INPUT_DATA, + to: DefaultNodeName.KNOWLEDGE_SOURCE, + waypointIndex: 1, + }) + ).toBeAttached(); + await expect( + await edges.getWaypoint({ + from: DefaultNodeName.INPUT_DATA, + to: DefaultNodeName.KNOWLEDGE_SOURCE, + waypointIndex: 2, + }) + ).not.toBeAttached(); }); - test("should add multiple waypoints to Authority Requirement and should not move when the ending nodes are moved", async ({ - diagram, - nodes, - edges, - }) => { - await edges.addWaypoint({ from: DefaultNodeName.INPUT_DATA, to: DefaultNodeName.KNOWLEDGE_SOURCE }); - await nodes.move({ name: DefaultNodeName.KNOWLEDGE_SOURCE, targetPosition: { x: 200, y: 500 } }); - + test("should attach multiple Authority Requirement waypoints to the edge", async ({ edges }) => { await edges.addWaypoint({ from: DefaultNodeName.INPUT_DATA, to: DefaultNodeName.KNOWLEDGE_SOURCE }); - await nodes.move({ name: DefaultNodeName.KNOWLEDGE_SOURCE, targetPosition: { x: 500, y: 500 } }); - await nodes.move({ name: DefaultNodeName.INPUT_DATA, targetPosition: { x: 500, y: 100 } }); + await edges.addWaypoint({ + from: DefaultNodeName.INPUT_DATA, + to: DefaultNodeName.KNOWLEDGE_SOURCE, + afterWaypointIndex: 1, + }); - await expect(diagram.get()).toHaveScreenshot("add-multiple-authority-requirement-waypoints-and-not-move-them.png"); + await expect( + await edges.getWaypoint({ + from: DefaultNodeName.INPUT_DATA, + to: DefaultNodeName.KNOWLEDGE_SOURCE, + waypointIndex: 1, + }) + ).toBeAttached(); + await expect( + await edges.getWaypoint({ + from: DefaultNodeName.INPUT_DATA, + to: DefaultNodeName.KNOWLEDGE_SOURCE, + waypointIndex: 2, + }) + ).toBeAttached(); }); }); diff --git a/packages/dmn-editor/tests/e2e/drgRequirements/addInformationRequirementWaypoint.spec.ts b/packages/dmn-editor/tests/e2e/drgRequirements/addInformationRequirementWaypoint.spec.ts index 308bb13b8ae..b4f11054cd0 100644 --- a/packages/dmn-editor/tests/e2e/drgRequirements/addInformationRequirementWaypoint.spec.ts +++ b/packages/dmn-editor/tests/e2e/drgRequirements/addInformationRequirementWaypoint.spec.ts @@ -35,31 +35,26 @@ test.describe("Add edge waypoint - Information Requirement", () => { }); }); - test("should add single waypoint to Information Requirement edge and should not move when the ending node is moved", async ({ - diagram, - nodes, - edges, - }) => { + test("should attach single Information Requirement edge waypoint to the edge", async ({ edges }) => { await edges.addWaypoint({ from: DefaultNodeName.INPUT_DATA, to: DefaultNodeName.DECISION }); - await nodes.move({ name: DefaultNodeName.DECISION, targetPosition: { x: 300, y: 300 } }); - await expect(diagram.get()).toHaveScreenshot("add-information-requirement-waypoint-and-not-move-it.png"); + await expect( + await edges.getWaypoint({ from: DefaultNodeName.INPUT_DATA, to: DefaultNodeName.DECISION, waypointIndex: 1 }) + ).toBeAttached(); + await expect( + await edges.getWaypoint({ from: DefaultNodeName.INPUT_DATA, to: DefaultNodeName.DECISION, waypointIndex: 2 }) + ).not.toBeAttached(); }); - test("should add multiple waypoints to Information Requirement edge and should not move when the ending nodes are moved", async ({ - diagram, - nodes, - edges, - }) => { + test("should attach multiple Information Requirement edge waypoints to the edge", async ({ edges }) => { await edges.addWaypoint({ from: DefaultNodeName.INPUT_DATA, to: DefaultNodeName.DECISION }); - await nodes.move({ name: DefaultNodeName.DECISION, targetPosition: { x: 200, y: 500 } }); - - await edges.addWaypoint({ from: DefaultNodeName.INPUT_DATA, to: DefaultNodeName.DECISION }); - await nodes.move({ name: DefaultNodeName.DECISION, targetPosition: { x: 500, y: 500 } }); - await nodes.move({ name: DefaultNodeName.INPUT_DATA, targetPosition: { x: 500, y: 100 } }); - - await expect(diagram.get()).toHaveScreenshot( - "add-multiple-information-requirement-waypoints-and-not-move-them.png" - ); + await edges.addWaypoint({ from: DefaultNodeName.INPUT_DATA, to: DefaultNodeName.DECISION, afterWaypointIndex: 1 }); + + await expect( + await edges.getWaypoint({ from: DefaultNodeName.INPUT_DATA, to: DefaultNodeName.DECISION, waypointIndex: 1 }) + ).toBeAttached(); + await expect( + await edges.getWaypoint({ from: DefaultNodeName.INPUT_DATA, to: DefaultNodeName.DECISION, waypointIndex: 2 }) + ).toBeAttached(); }); }); diff --git a/packages/dmn-editor/tests/e2e/drgRequirements/addKnowledgeRequirementWaypoint.spec.ts b/packages/dmn-editor/tests/e2e/drgRequirements/addKnowledgeRequirementWaypoint.spec.ts index 9990c815f4b..98abffce258 100644 --- a/packages/dmn-editor/tests/e2e/drgRequirements/addKnowledgeRequirementWaypoint.spec.ts +++ b/packages/dmn-editor/tests/e2e/drgRequirements/addKnowledgeRequirementWaypoint.spec.ts @@ -35,29 +35,26 @@ test.describe("Add edge waypoint - Knowledge Requirement", () => { }); }); - test("should add single waypoint to Knowledge Requirement edge and should not move when the ending node is moved", async ({ - diagram, - nodes, - edges, - }) => { + test("should attach single Knowledge Requirement edge waypoint to the edge", async ({ edges }) => { await edges.addWaypoint({ from: DefaultNodeName.BKM, to: DefaultNodeName.DECISION }); - await nodes.move({ name: DefaultNodeName.DECISION, targetPosition: { x: 300, y: 300 } }); - await expect(diagram.get()).toHaveScreenshot("add-knowledge-requirement-waypoint-and-not-move-it.png"); + await expect( + await edges.getWaypoint({ from: DefaultNodeName.BKM, to: DefaultNodeName.DECISION, waypointIndex: 1 }) + ).toBeAttached(); + await expect( + await edges.getWaypoint({ from: DefaultNodeName.BKM, to: DefaultNodeName.DECISION, waypointIndex: 2 }) + ).not.toBeAttached(); }); - test("should add multiple waypoints to Knowledge Requirement edge and should not move when the ending nodes are moved", async ({ - diagram, - nodes, - edges, - }) => { + test("should attach multiple Knowledge Requirement edge waypoints to the edge", async ({ edges }) => { await edges.addWaypoint({ from: DefaultNodeName.BKM, to: DefaultNodeName.DECISION }); - await nodes.move({ name: DefaultNodeName.DECISION, targetPosition: { x: 200, y: 500 } }); - - await edges.addWaypoint({ from: DefaultNodeName.BKM, to: DefaultNodeName.DECISION }); - await nodes.move({ name: DefaultNodeName.DECISION, targetPosition: { x: 500, y: 500 } }); - await nodes.move({ name: DefaultNodeName.BKM, targetPosition: { x: 500, y: 100 } }); - - await expect(diagram.get()).toHaveScreenshot("add-multiple-knowledge-requirement-waypoints-and-not-move-them.png"); + await edges.addWaypoint({ from: DefaultNodeName.BKM, to: DefaultNodeName.DECISION, afterWaypointIndex: 1 }); + + await expect( + await edges.getWaypoint({ from: DefaultNodeName.BKM, to: DefaultNodeName.DECISION, waypointIndex: 1 }) + ).toBeAttached(); + await expect( + await edges.getWaypoint({ from: DefaultNodeName.BKM, to: DefaultNodeName.DECISION, waypointIndex: 2 }) + ).toBeAttached(); }); }); diff --git a/packages/dmn-editor/tests/e2e/drgRequirements/deleteAuthorityRequirementWaypoint.spec.ts b/packages/dmn-editor/tests/e2e/drgRequirements/deleteAuthorityRequirementWaypoint.spec.ts new file mode 100644 index 00000000000..04ddbd290e5 --- /dev/null +++ b/packages/dmn-editor/tests/e2e/drgRequirements/deleteAuthorityRequirementWaypoint.spec.ts @@ -0,0 +1,137 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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 { expect } from "@playwright/test"; +import { test } from "../__fixtures__/base"; +import { DefaultNodeName, NodeType } from "../__fixtures__/nodes"; +import { TestAnnotations } from "@kie-tools/playwright-base/annotations"; + +test.beforeEach(async ({ editor }) => { + await editor.open(); +}); + +test.describe("Delete edge waypoint - Authority Requirement", () => { + test.beforeEach(async ({ palette, nodes, browserName }) => { + test.skip(browserName === "webkit", "https://github.com/apache/incubator-kie-issues/issues/991"); + test.info().annotations.push({ + type: TestAnnotations.REGRESSION, + description: "https://github.com/apache/incubator-kie-issues/issues/991", + }); + + await palette.dragNewNode({ type: NodeType.INPUT_DATA, targetPosition: { x: 100, y: 100 } }); + await nodes.dragNewConnectedNode({ + from: DefaultNodeName.INPUT_DATA, + type: NodeType.KNOWLEDGE_SOURCE, + targetPosition: { x: 100, y: 300 }, + }); + }); + + test("should delete one Authority Requirement edge waypoint", async ({ edges }) => { + await edges.addWaypoint({ from: DefaultNodeName.INPUT_DATA, to: DefaultNodeName.KNOWLEDGE_SOURCE }); + + await edges.deleteWaypoint({ + from: DefaultNodeName.INPUT_DATA, + to: DefaultNodeName.KNOWLEDGE_SOURCE, + waypointIndex: 1, + }); + + await expect( + await edges.getWaypoint({ + from: DefaultNodeName.INPUT_DATA, + to: DefaultNodeName.KNOWLEDGE_SOURCE, + waypointIndex: 1, + }) + ).not.toBeAttached(); + }); + + test("should move and delete one Authority Requirement edge waypoint", async ({ diagram, edges }) => { + await edges.addWaypoint({ from: DefaultNodeName.INPUT_DATA, to: DefaultNodeName.KNOWLEDGE_SOURCE }); + await edges.moveWaypoint({ + from: DefaultNodeName.INPUT_DATA, + to: DefaultNodeName.KNOWLEDGE_SOURCE, + waypointIndex: 1, + targetPosition: { x: 300, y: 300 }, + }); + + await edges.deleteWaypoint({ + from: DefaultNodeName.INPUT_DATA, + to: DefaultNodeName.KNOWLEDGE_SOURCE, + waypointIndex: 1, + }); + await expect(diagram.get()).toHaveScreenshot("delete-authority-requirement-waypoint-straight-edge.png"); + }); + + test("should delete two Authority Requirement edge waypoints", async ({ edges }) => { + await edges.addWaypoint({ from: DefaultNodeName.INPUT_DATA, to: DefaultNodeName.KNOWLEDGE_SOURCE }); + await edges.addWaypoint({ + from: DefaultNodeName.INPUT_DATA, + to: DefaultNodeName.KNOWLEDGE_SOURCE, + afterWaypointIndex: 1, + }); + + await edges.deleteWaypoints({ + from: DefaultNodeName.INPUT_DATA, + to: DefaultNodeName.KNOWLEDGE_SOURCE, + waypointsCount: 2, + }); + + await expect( + await edges.getWaypoint({ + from: DefaultNodeName.INPUT_DATA, + to: DefaultNodeName.KNOWLEDGE_SOURCE, + waypointIndex: 1, + }) + ).not.toBeAttached(); + await expect( + await edges.getWaypoint({ + from: DefaultNodeName.INPUT_DATA, + to: DefaultNodeName.KNOWLEDGE_SOURCE, + waypointIndex: 2, + }) + ).not.toBeAttached(); + }); + + test("should move two and delete one Authority Requirement edge waypoints", async ({ diagram, edges }) => { + await edges.addWaypoint({ from: DefaultNodeName.INPUT_DATA, to: DefaultNodeName.KNOWLEDGE_SOURCE }); + await edges.addWaypoint({ + from: DefaultNodeName.INPUT_DATA, + to: DefaultNodeName.KNOWLEDGE_SOURCE, + afterWaypointIndex: 1, + }); + await edges.moveWaypoint({ + from: DefaultNodeName.INPUT_DATA, + to: DefaultNodeName.KNOWLEDGE_SOURCE, + waypointIndex: 1, + targetPosition: { x: 500, y: 100 }, + }); + await edges.moveWaypoint({ + from: DefaultNodeName.INPUT_DATA, + to: DefaultNodeName.KNOWLEDGE_SOURCE, + waypointIndex: 2, + targetPosition: { x: 500, y: 500 }, + }); + + await edges.deleteWaypoint({ + from: DefaultNodeName.INPUT_DATA, + to: DefaultNodeName.KNOWLEDGE_SOURCE, + waypointIndex: 1, + }); + await expect(diagram.get()).toHaveScreenshot("delete-authority-requirement-waypoint-edge-with-corner.png"); + }); +}); diff --git a/packages/dmn-editor/tests/e2e/drgRequirements/deleteInformationRequirementWaypoint.spec.ts b/packages/dmn-editor/tests/e2e/drgRequirements/deleteInformationRequirementWaypoint.spec.ts new file mode 100644 index 00000000000..77af0efc48f --- /dev/null +++ b/packages/dmn-editor/tests/e2e/drgRequirements/deleteInformationRequirementWaypoint.spec.ts @@ -0,0 +1,123 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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 { expect } from "@playwright/test"; +import { test } from "../__fixtures__/base"; +import { DefaultNodeName, NodeType } from "../__fixtures__/nodes"; +import { TestAnnotations } from "@kie-tools/playwright-base/annotations"; + +test.beforeEach(async ({ editor }) => { + await editor.open(); +}); + +test.describe("Delete edge waypoint - Information Requirement", () => { + test.beforeEach(async ({ palette, nodes, browserName }) => { + test.skip(browserName === "webkit", "https://github.com/apache/incubator-kie-issues/issues/991"); + test.info().annotations.push({ + type: TestAnnotations.REGRESSION, + description: "https://github.com/apache/incubator-kie-issues/issues/991", + }); + + await palette.dragNewNode({ type: NodeType.INPUT_DATA, targetPosition: { x: 100, y: 100 } }); + await nodes.dragNewConnectedNode({ + from: DefaultNodeName.INPUT_DATA, + type: NodeType.DECISION, + targetPosition: { x: 100, y: 300 }, + }); + }); + + test("should delete one Information Requirement edge waypoint", async ({ edges }) => { + await edges.addWaypoint({ from: DefaultNodeName.INPUT_DATA, to: DefaultNodeName.DECISION }); + + await edges.deleteWaypoint({ from: DefaultNodeName.INPUT_DATA, to: DefaultNodeName.DECISION, waypointIndex: 1 }); + + await expect( + await edges.getWaypoint({ + from: DefaultNodeName.INPUT_DATA, + to: DefaultNodeName.DECISION, + waypointIndex: 1, + }) + ).not.toBeAttached(); + }); + + test("should move and delete one Information Requirement edge waypoint", async ({ diagram, edges }) => { + await edges.addWaypoint({ from: DefaultNodeName.INPUT_DATA, to: DefaultNodeName.DECISION }); + await edges.moveWaypoint({ + from: DefaultNodeName.INPUT_DATA, + to: DefaultNodeName.DECISION, + waypointIndex: 1, + targetPosition: { x: 300, y: 300 }, + }); + + await edges.deleteWaypoint({ from: DefaultNodeName.INPUT_DATA, to: DefaultNodeName.DECISION, waypointIndex: 1 }); + + await expect(diagram.get()).toHaveScreenshot("delete-information-requirement-waypoint-straight-edge.png"); + }); + + test("should delete two Information Requirement edge waypoints", async ({ edges }) => { + await edges.addWaypoint({ from: DefaultNodeName.INPUT_DATA, to: DefaultNodeName.DECISION }); + await edges.addWaypoint({ from: DefaultNodeName.INPUT_DATA, to: DefaultNodeName.DECISION, afterWaypointIndex: 1 }); + + await edges.deleteWaypoints({ + from: DefaultNodeName.INPUT_DATA, + to: DefaultNodeName.DECISION, + waypointsCount: 2, + }); + + await expect( + await edges.getWaypoint({ + from: DefaultNodeName.INPUT_DATA, + to: DefaultNodeName.DECISION, + waypointIndex: 1, + }) + ).not.toBeAttached(); + await expect( + await edges.getWaypoint({ + from: DefaultNodeName.INPUT_DATA, + to: DefaultNodeName.DECISION, + waypointIndex: 2, + }) + ).not.toBeAttached(); + }); + + test("should move two and delete one Information Requirement edge waypoints", async ({ diagram, edges }) => { + await edges.addWaypoint({ from: DefaultNodeName.INPUT_DATA, to: DefaultNodeName.DECISION }); + await edges.addWaypoint({ from: DefaultNodeName.INPUT_DATA, to: DefaultNodeName.DECISION, afterWaypointIndex: 1 }); + await edges.moveWaypoint({ + from: DefaultNodeName.INPUT_DATA, + to: DefaultNodeName.DECISION, + waypointIndex: 1, + targetPosition: { x: 500, y: 100 }, + }); + await edges.moveWaypoint({ + from: DefaultNodeName.INPUT_DATA, + to: DefaultNodeName.DECISION, + waypointIndex: 2, + targetPosition: { x: 500, y: 500 }, + }); + + await edges.deleteWaypoint({ + from: DefaultNodeName.INPUT_DATA, + to: DefaultNodeName.DECISION, + waypointIndex: 1, + }); + + await expect(diagram.get()).toHaveScreenshot("delete-information-requirement-waypoint-edge-with-corner.png"); + }); +}); diff --git a/packages/dmn-editor/tests/e2e/drgRequirements/deleteKnowledgeRequirementWaypoint.spec.ts b/packages/dmn-editor/tests/e2e/drgRequirements/deleteKnowledgeRequirementWaypoint.spec.ts new file mode 100644 index 00000000000..a0b519dc3e2 --- /dev/null +++ b/packages/dmn-editor/tests/e2e/drgRequirements/deleteKnowledgeRequirementWaypoint.spec.ts @@ -0,0 +1,131 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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 { expect } from "@playwright/test"; +import { test } from "../__fixtures__/base"; +import { DefaultNodeName, NodeType } from "../__fixtures__/nodes"; +import { TestAnnotations } from "@kie-tools/playwright-base/annotations"; + +test.beforeEach(async ({ editor }) => { + await editor.open(); +}); + +test.describe("Delete edge waypoint - Knowledge Requirement", () => { + test.beforeEach(async ({ palette, nodes, browserName }) => { + test.skip(browserName === "webkit", "https://github.com/apache/incubator-kie-issues/issues/991"); + test.info().annotations.push({ + type: TestAnnotations.REGRESSION, + description: "https://github.com/apache/incubator-kie-issues/issues/991", + }); + + await palette.dragNewNode({ type: NodeType.BKM, targetPosition: { x: 100, y: 100 } }); + await nodes.dragNewConnectedNode({ + from: DefaultNodeName.BKM, + type: NodeType.DECISION, + targetPosition: { x: 100, y: 300 }, + }); + }); + + test("should delete one Knowledge Requirement edge waypoint", async ({ edges }) => { + await edges.addWaypoint({ from: DefaultNodeName.BKM, to: DefaultNodeName.DECISION }); + + await edges.deleteWaypoint({ + from: DefaultNodeName.BKM, + to: DefaultNodeName.DECISION, + waypointIndex: 1, + }); + + await expect( + await edges.getWaypoint({ + from: DefaultNodeName.BKM, + to: DefaultNodeName.DECISION, + waypointIndex: 1, + }) + ).not.toBeAttached(); + }); + + test("should move and delete one Knowledge Requirement edge waypoint", async ({ diagram, edges }) => { + await edges.addWaypoint({ from: DefaultNodeName.BKM, to: DefaultNodeName.DECISION }); + await edges.moveWaypoint({ + from: DefaultNodeName.BKM, + to: DefaultNodeName.DECISION, + waypointIndex: 1, + targetPosition: { x: 300, y: 300 }, + }); + + await edges.deleteWaypoint({ + from: DefaultNodeName.BKM, + to: DefaultNodeName.DECISION, + waypointIndex: 1, + }); + + await expect(diagram.get()).toHaveScreenshot("delete-knowledge-requirement-waypoint-straight-edge.png"); + }); + + test("should delete two Knowledge Requirement edge waypoints", async ({ edges }) => { + await edges.addWaypoint({ from: DefaultNodeName.BKM, to: DefaultNodeName.DECISION }); + await edges.addWaypoint({ from: DefaultNodeName.BKM, to: DefaultNodeName.DECISION, afterWaypointIndex: 1 }); + + await edges.deleteWaypoints({ + from: DefaultNodeName.BKM, + to: DefaultNodeName.DECISION, + waypointsCount: 2, + }); + + await expect( + await edges.getWaypoint({ + from: DefaultNodeName.BKM, + to: DefaultNodeName.DECISION, + waypointIndex: 1, + }) + ).not.toBeAttached(); + + await expect( + await edges.getWaypoint({ + from: DefaultNodeName.BKM, + to: DefaultNodeName.DECISION, + waypointIndex: 2, + }) + ).not.toBeAttached(); + }); + + test("should move two and delete one Knowledge Requirement edge waypoints", async ({ diagram, edges }) => { + await edges.addWaypoint({ from: DefaultNodeName.BKM, to: DefaultNodeName.DECISION }); + await edges.addWaypoint({ from: DefaultNodeName.BKM, to: DefaultNodeName.DECISION, afterWaypointIndex: 1 }); + await edges.moveWaypoint({ + from: DefaultNodeName.BKM, + to: DefaultNodeName.DECISION, + waypointIndex: 1, + targetPosition: { x: 500, y: 100 }, + }); + await edges.moveWaypoint({ + from: DefaultNodeName.BKM, + to: DefaultNodeName.DECISION, + waypointIndex: 2, + targetPosition: { x: 500, y: 500 }, + }); + + await edges.deleteWaypoint({ + from: DefaultNodeName.BKM, + to: DefaultNodeName.DECISION, + waypointIndex: 1, + }); + await expect(diagram.get()).toHaveScreenshot("delete-knowledge-requirement-waypoint-edge-with-corner.png"); + }); +}); diff --git a/packages/dmn-editor/tests/e2e/drgRequirements/invalidAuthorityRequirement.spec.ts b/packages/dmn-editor/tests/e2e/drgRequirements/invalidAuthorityRequirement.spec.ts new file mode 100644 index 00000000000..8d4205ab017 --- /dev/null +++ b/packages/dmn-editor/tests/e2e/drgRequirements/invalidAuthorityRequirement.spec.ts @@ -0,0 +1,172 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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 { test, expect } from "../__fixtures__/base"; +import { DefaultNodeName, NodePosition, NodeType } from "../__fixtures__/nodes"; +import { EdgeType } from "../__fixtures__/edges"; + +test.beforeEach(async ({ editor }) => { + await editor.open(); +}); + +test.describe("Invalid edge - Authority Requirement", () => { + test.describe("Invalid edge - Authority Requirement - From Knowledge Source", () => { + test.beforeEach(async ({ palette }) => { + await palette.dragNewNode({ + type: NodeType.KNOWLEDGE_SOURCE, + targetPosition: { x: 100, y: 100 }, + thenRenameTo: "Source Node", + }); + }); + + test("shouldn't add an Authority Requirement edge from Knowledge Source node to Input Data node", async ({ + palette, + nodes, + edges, + }) => { + await palette.dragNewNode({ + type: NodeType.INPUT_DATA, + targetPosition: { x: 300, y: 100 }, + }); + + await nodes.dragNewConnectedEdge({ + type: EdgeType.AUTHORITY_REQUIREMENT, + from: "Source Node", + to: DefaultNodeName.INPUT_DATA, + }); + + expect(await edges.get({ from: "Source Node", to: DefaultNodeName.INPUT_DATA })).not.toBeAttached(); + }); + + test("should dim the target Input Data node", async ({ palette, nodes }) => { + await palette.dragNewNode({ + type: NodeType.INPUT_DATA, + targetPosition: { x: 300, y: 100 }, + }); + + await nodes.startDraggingEdge({ from: "Source Node", edgeType: EdgeType.AUTHORITY_REQUIREMENT }); + + await expect(nodes.get({ name: DefaultNodeName.INPUT_DATA })).toHaveClass(/.*dimmed/); + }); + + test("should dim the target Alternative Input Data node", async ({ diagram, palette, nodes }) => { + await diagram.selectAlternativeInputDataShape(); + await palette.dragNewNode({ + type: NodeType.INPUT_DATA, + targetPosition: { x: 300, y: 100 }, + }); + + await nodes.startDraggingEdge({ from: "Source Node", edgeType: EdgeType.AUTHORITY_REQUIREMENT }); + + await expect(nodes.get({ name: DefaultNodeName.INPUT_DATA })).toHaveClass(/.*dimmed/); + }); + + test("shouldn't add an Authority Requirement edge from Knowledge Source node to Decision Service node", async ({ + palette, + nodes, + edges, + }) => { + await palette.dragNewNode({ + type: NodeType.DECISION_SERVICE, + targetPosition: { x: 300, y: 100 }, + }); + + await nodes.dragNewConnectedEdge({ + type: EdgeType.AUTHORITY_REQUIREMENT, + from: "Source Node", + to: DefaultNodeName.DECISION_SERVICE, + position: NodePosition.TOP, + }); + + expect(await edges.get({ from: "Source Node", to: DefaultNodeName.DECISION_SERVICE })).not.toBeAttached(); + }); + + test("should dim the target Decision Service node", async ({ palette, nodes }) => { + await palette.dragNewNode({ + type: NodeType.DECISION_SERVICE, + targetPosition: { x: 300, y: 100 }, + }); + + await nodes.startDraggingEdge({ from: "Source Node", edgeType: EdgeType.AUTHORITY_REQUIREMENT }); + + await expect(nodes.get({ name: DefaultNodeName.DECISION_SERVICE })).toHaveClass(/.*dimmed/); + }); + + test("shouldn't add an Authority Requirement edge from Knowledge Source node to Group node", async ({ + palette, + nodes, + edges, + }) => { + await palette.dragNewNode({ + type: NodeType.GROUP, + targetPosition: { x: 400, y: 400 }, + }); + + await nodes.dragNewConnectedEdge({ + type: EdgeType.AUTHORITY_REQUIREMENT, + from: "Source Node", + to: DefaultNodeName.GROUP, + position: NodePosition.TOP, + }); + + expect(await edges.get({ from: "Source Node", to: DefaultNodeName.GROUP })).not.toBeAttached(); + }); + + test("should dim the target Group node", async ({ palette, nodes }) => { + await palette.dragNewNode({ + type: NodeType.GROUP, + targetPosition: { x: 300, y: 100 }, + }); + + await nodes.startDraggingEdge({ from: "Source Node", edgeType: EdgeType.AUTHORITY_REQUIREMENT }); + + await expect(nodes.get({ name: DefaultNodeName.GROUP })).toHaveClass(/.*dimmed/); + }); + + test("shouldn't add an Authority Requirement edge from Knowledge Source node to Text Annotation node", async ({ + palette, + nodes, + edges, + }) => { + await palette.dragNewNode({ + type: NodeType.TEXT_ANNOTATION, + targetPosition: { x: 300, y: 100 }, + }); + + await nodes.dragNewConnectedEdge({ + type: EdgeType.AUTHORITY_REQUIREMENT, + from: "Source Node", + to: DefaultNodeName.TEXT_ANNOTATION, + }); + + expect(await edges.get({ from: "Source Node", to: DefaultNodeName.TEXT_ANNOTATION })).not.toBeAttached(); + }); + + test("should dim the target Text Annotation node", async ({ palette, nodes }) => { + await palette.dragNewNode({ + type: NodeType.TEXT_ANNOTATION, + targetPosition: { x: 300, y: 100 }, + }); + + await nodes.startDraggingEdge({ from: "Source Node", edgeType: EdgeType.AUTHORITY_REQUIREMENT }); + + await expect(nodes.get({ name: DefaultNodeName.TEXT_ANNOTATION })).toHaveClass(/.*dimmed/); + }); + }); +}); diff --git a/packages/dmn-editor/tests/e2e/drgRequirements/invalidInformationRequirement.spec.ts b/packages/dmn-editor/tests/e2e/drgRequirements/invalidInformationRequirement.spec.ts new file mode 100644 index 00000000000..147faf2ce32 --- /dev/null +++ b/packages/dmn-editor/tests/e2e/drgRequirements/invalidInformationRequirement.spec.ts @@ -0,0 +1,356 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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 { test, expect } from "../__fixtures__/base"; +import { DefaultNodeName, NodePosition, NodeType } from "../__fixtures__/nodes"; +import { EdgeType } from "../__fixtures__/edges"; + +test.beforeEach(async ({ editor }) => { + await editor.open(); +}); + +test.describe("Invalid edge - Information Requirement", () => { + test.describe("Invalid edge - Information Requirement - From Input Data", () => { + test.beforeEach(async ({ palette }) => { + await palette.dragNewNode({ + type: NodeType.INPUT_DATA, + targetPosition: { x: 100, y: 100 }, + thenRenameTo: "Source Node", + }); + }); + + test("shouldn't add an Information Requirement edge from Input Data node to Input Data node", async ({ + palette, + nodes, + edges, + }) => { + await palette.dragNewNode({ + type: NodeType.INPUT_DATA, + targetPosition: { x: 300, y: 100 }, + }); + + await nodes.dragNewConnectedEdge({ + type: EdgeType.INFORMATION_REQUIREMENT, + from: "Source Node", + to: DefaultNodeName.INPUT_DATA, + }); + + expect(await edges.get({ from: "Source Node", to: DefaultNodeName.INPUT_DATA })).not.toBeAttached(); + }); + + test("should dim the target Input Data node", async ({ palette, nodes }) => { + await palette.dragNewNode({ + type: NodeType.INPUT_DATA, + targetPosition: { x: 300, y: 100 }, + }); + + await nodes.startDraggingEdge({ from: "Source Node", edgeType: EdgeType.INFORMATION_REQUIREMENT }); + + await expect(nodes.get({ name: DefaultNodeName.INPUT_DATA })).toHaveClass(/.*dimmed/); + }); + + test("should dim the target Alternative Input Data node", async ({ diagram, palette, nodes }) => { + await diagram.selectAlternativeInputDataShape(); + await palette.dragNewNode({ + type: NodeType.INPUT_DATA, + targetPosition: { x: 300, y: 100 }, + }); + + await nodes.startDraggingEdge({ from: "Source Node", edgeType: EdgeType.INFORMATION_REQUIREMENT }); + + await expect(nodes.get({ name: DefaultNodeName.INPUT_DATA })).toHaveClass(/.*dimmed/); + }); + + test("shouldn't add an Information Requirement edge from Input Data node to BKM node", async ({ + palette, + edges, + nodes, + }) => { + await palette.dragNewNode({ + type: NodeType.BKM, + targetPosition: { x: 300, y: 100 }, + }); + + await nodes.dragNewConnectedEdge({ + type: EdgeType.INFORMATION_REQUIREMENT, + from: "Source Node", + to: DefaultNodeName.BKM, + }); + + expect(await edges.get({ from: "Source Node", to: DefaultNodeName.BKM })).not.toBeAttached(); + }); + + test("should dim the target BKM node", async ({ palette, nodes }) => { + await palette.dragNewNode({ + type: NodeType.BKM, + targetPosition: { x: 300, y: 100 }, + }); + + await nodes.startDraggingEdge({ from: "Source Node", edgeType: EdgeType.INFORMATION_REQUIREMENT }); + + await expect(nodes.get({ name: DefaultNodeName.BKM })).toHaveClass(/.*dimmed/); + }); + + test("shouldn't add an Information Requirement edge from Input Data node to Decision Service node", async ({ + palette, + nodes, + edges, + }) => { + await palette.dragNewNode({ + type: NodeType.DECISION_SERVICE, + targetPosition: { x: 300, y: 100 }, + }); + + await nodes.dragNewConnectedEdge({ + type: EdgeType.INFORMATION_REQUIREMENT, + from: "Source Node", + to: DefaultNodeName.DECISION_SERVICE, + }); + + expect(await edges.get({ from: "Source Node", to: DefaultNodeName.DECISION_SERVICE })).not.toBeAttached(); + }); + + test("should dim the target Decision Service node", async ({ palette, nodes }) => { + await palette.dragNewNode({ + type: NodeType.DECISION_SERVICE, + targetPosition: { x: 300, y: 100 }, + }); + + await nodes.startDraggingEdge({ from: "Source Node", edgeType: EdgeType.INFORMATION_REQUIREMENT }); + + await expect(nodes.get({ name: DefaultNodeName.DECISION_SERVICE })).toHaveClass(/.*dimmed/); + }); + + test("shouldn't add an Information Requirement edge from Input Data node to Knowledge Source node", async ({ + palette, + nodes, + edges, + }) => { + await palette.dragNewNode({ + type: NodeType.KNOWLEDGE_SOURCE, + targetPosition: { x: 300, y: 100 }, + }); + + await nodes.dragNewConnectedEdge({ + type: EdgeType.INFORMATION_REQUIREMENT, + from: "Source Node", + to: DefaultNodeName.KNOWLEDGE_SOURCE, + }); + + expect(await edges.get({ from: "Source Node", to: DefaultNodeName.KNOWLEDGE_SOURCE })).not.toBeAttached(); + }); + + test("should dim the target Knowledge Source node", async ({ palette, nodes }) => { + await palette.dragNewNode({ + type: NodeType.KNOWLEDGE_SOURCE, + targetPosition: { x: 300, y: 100 }, + }); + + await nodes.startDraggingEdge({ from: "Source Node", edgeType: EdgeType.INFORMATION_REQUIREMENT }); + + await expect(nodes.get({ name: DefaultNodeName.KNOWLEDGE_SOURCE })).toHaveClass(/.*dimmed/); + }); + + test("shouldn't add an Information Requirement edge from Input Data node to Group node", async ({ + palette, + nodes, + edges, + }) => { + await palette.dragNewNode({ + type: NodeType.GROUP, + targetPosition: { x: 400, y: 400 }, + }); + + await nodes.dragNewConnectedEdge({ + type: EdgeType.INFORMATION_REQUIREMENT, + from: "Source Node", + to: DefaultNodeName.GROUP, + position: NodePosition.TOP, + }); + + expect(await edges.get({ from: "Source Node", to: DefaultNodeName.GROUP })).not.toBeAttached(); + }); + + test("should dim the target Group node", async ({ palette, nodes }) => { + await palette.dragNewNode({ + type: NodeType.GROUP, + targetPosition: { x: 300, y: 100 }, + }); + + await nodes.startDraggingEdge({ from: "Source Node", edgeType: EdgeType.INFORMATION_REQUIREMENT }); + + await expect(nodes.get({ name: DefaultNodeName.GROUP })).toHaveClass(/.*dimmed/); + }); + + test("shouldn't add an Information Requirement edge from Input Data node to Text Annotation node", async ({ + palette, + nodes, + edges, + }) => { + await palette.dragNewNode({ + type: NodeType.TEXT_ANNOTATION, + targetPosition: { x: 300, y: 100 }, + }); + + await nodes.dragNewConnectedEdge({ + type: EdgeType.INFORMATION_REQUIREMENT, + from: "Source Node", + to: DefaultNodeName.TEXT_ANNOTATION, + }); + + expect(await edges.get({ from: "Source Node", to: DefaultNodeName.TEXT_ANNOTATION })).not.toBeAttached(); + }); + + test("should dim the target Text Annotation node", async ({ palette, nodes }) => { + await palette.dragNewNode({ + type: NodeType.TEXT_ANNOTATION, + targetPosition: { x: 300, y: 100 }, + }); + + await nodes.startDraggingEdge({ from: "Source Node", edgeType: EdgeType.INFORMATION_REQUIREMENT }); + + await expect(nodes.get({ name: DefaultNodeName.TEXT_ANNOTATION })).toHaveClass(/.*dimmed/); + }); + }); + + test.describe("Invalid edge - Information Requirement - From Decision", () => { + test.beforeEach(async ({ palette }) => { + await palette.dragNewNode({ + type: NodeType.DECISION, + targetPosition: { x: 100, y: 100 }, + thenRenameTo: "Source Node", + }); + }); + + test("shouldn't add an Information Requirement edge from Decision node to Input Data node", async ({ + palette, + nodes, + edges, + }) => { + await palette.dragNewNode({ + type: NodeType.INPUT_DATA, + targetPosition: { x: 300, y: 100 }, + }); + + await nodes.dragNewConnectedEdge({ + type: EdgeType.INFORMATION_REQUIREMENT, + from: "Source Node", + to: DefaultNodeName.INPUT_DATA, + }); + + expect(await edges.get({ from: "Source Node", to: DefaultNodeName.INPUT_DATA })).not.toBeAttached(); + }); + + test("shouldn't add an Information Requirement edge from Decision node to BKM node", async ({ + palette, + nodes, + edges, + }) => { + await palette.dragNewNode({ + type: NodeType.BKM, + targetPosition: { x: 300, y: 100 }, + }); + + await nodes.dragNewConnectedEdge({ + type: EdgeType.INFORMATION_REQUIREMENT, + from: "Source Node", + to: DefaultNodeName.BKM, + }); + + expect(await edges.get({ from: "Source Node", to: DefaultNodeName.BKM })).not.toBeAttached(); + }); + + test("shouldn't add an Information Requirement edge from Decision node to Decision Service node", async ({ + palette, + nodes, + edges, + }) => { + await palette.dragNewNode({ + type: NodeType.DECISION_SERVICE, + targetPosition: { x: 300, y: 100 }, + }); + + await nodes.dragNewConnectedEdge({ + type: EdgeType.INFORMATION_REQUIREMENT, + from: "Source Node", + to: DefaultNodeName.DECISION_SERVICE, + }); + + expect(await edges.get({ from: "Source Node", to: DefaultNodeName.DECISION_SERVICE })).not.toBeAttached(); + }); + + test("shouldn't add an Information Requirement edge from Decision node to Knowledge Source node", async ({ + palette, + nodes, + edges, + }) => { + await palette.dragNewNode({ + type: NodeType.KNOWLEDGE_SOURCE, + targetPosition: { x: 300, y: 100 }, + }); + + await nodes.dragNewConnectedEdge({ + type: EdgeType.INFORMATION_REQUIREMENT, + from: "Source Node", + to: DefaultNodeName.KNOWLEDGE_SOURCE, + }); + + expect(await edges.get({ from: "Source Node", to: DefaultNodeName.KNOWLEDGE_SOURCE })).not.toBeAttached(); + }); + + test("shouldn't add an Information Requirement edge from Decision node to Group node", async ({ + palette, + nodes, + edges, + }) => { + await palette.dragNewNode({ + type: NodeType.GROUP, + targetPosition: { x: 400, y: 400 }, + }); + + await nodes.dragNewConnectedEdge({ + type: EdgeType.INFORMATION_REQUIREMENT, + from: "Source Node", + to: DefaultNodeName.GROUP, + position: NodePosition.TOP, + }); + + expect(await edges.get({ from: "Source Node", to: DefaultNodeName.GROUP })).not.toBeAttached(); + }); + + test("shouldn't add an Information Requirement edge from Decision node to Text Annotation node", async ({ + palette, + nodes, + edges, + }) => { + await palette.dragNewNode({ + type: NodeType.TEXT_ANNOTATION, + targetPosition: { x: 300, y: 100 }, + }); + + await nodes.dragNewConnectedEdge({ + type: EdgeType.INFORMATION_REQUIREMENT, + from: "Source Node", + to: DefaultNodeName.TEXT_ANNOTATION, + }); + + expect(await edges.get({ from: "Source Node", to: DefaultNodeName.TEXT_ANNOTATION })).not.toBeAttached(); + }); + }); +}); diff --git a/packages/dmn-editor/tests/e2e/drgRequirements/invalidKnowledgeRequirement.spec.ts b/packages/dmn-editor/tests/e2e/drgRequirements/invalidKnowledgeRequirement.spec.ts new file mode 100644 index 00000000000..bb331d11390 --- /dev/null +++ b/packages/dmn-editor/tests/e2e/drgRequirements/invalidKnowledgeRequirement.spec.ts @@ -0,0 +1,171 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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 { test, expect } from "../__fixtures__/base"; +import { DefaultNodeName, NodePosition, NodeType } from "../__fixtures__/nodes"; +import { EdgeType } from "../__fixtures__/edges"; + +test.beforeEach(async ({ editor }) => { + await editor.open(); +}); + +test.describe("Invalid edge - Knowledge Requirement", () => { + test.describe("Invalid edge - Knowledge Requirement - From BKM", () => { + test.beforeEach(async ({ palette }) => { + await palette.dragNewNode({ + type: NodeType.BKM, + targetPosition: { x: 100, y: 100 }, + thenRenameTo: "Source Node", + }); + }); + + test("shouldn't add an Knowledge Requirement edge from BKM node to Input Data node", async ({ + palette, + nodes, + edges, + }) => { + await palette.dragNewNode({ + type: NodeType.INPUT_DATA, + targetPosition: { x: 300, y: 100 }, + }); + + await nodes.dragNewConnectedEdge({ + type: EdgeType.KNOWLEDGE_REQUIREMENT, + from: "Source Node", + to: DefaultNodeName.INPUT_DATA, + }); + + expect(await edges.get({ from: "Source Node", to: DefaultNodeName.INPUT_DATA })).not.toBeAttached(); + }); + + test("should dim the target Input Data node", async ({ palette, nodes }) => { + await palette.dragNewNode({ + type: NodeType.INPUT_DATA, + targetPosition: { x: 300, y: 100 }, + }); + + await nodes.startDraggingEdge({ from: "Source Node", edgeType: EdgeType.KNOWLEDGE_REQUIREMENT }); + + await expect(nodes.get({ name: DefaultNodeName.INPUT_DATA })).toHaveClass(/.*dimmed/); + }); + + test("should dim the target Alternative Input Data node", async ({ diagram, palette, nodes }) => { + await diagram.selectAlternativeInputDataShape(); + await palette.dragNewNode({ + type: NodeType.INPUT_DATA, + targetPosition: { x: 300, y: 100 }, + }); + + await nodes.startDraggingEdge({ from: "Source Node", edgeType: EdgeType.KNOWLEDGE_REQUIREMENT }); + + await expect(nodes.get({ name: DefaultNodeName.INPUT_DATA })).toHaveClass(/.*dimmed/); + }); + + test("shouldn't add an Knowledge Requirement edge from BKM node to Knowledge Source node", async ({ + palette, + nodes, + edges, + }) => { + await palette.dragNewNode({ + type: NodeType.KNOWLEDGE_SOURCE, + targetPosition: { x: 300, y: 100 }, + }); + + await nodes.dragNewConnectedEdge({ + type: EdgeType.KNOWLEDGE_REQUIREMENT, + from: "Source Node", + to: DefaultNodeName.KNOWLEDGE_SOURCE, + }); + + expect(await edges.get({ from: "Source Node", to: DefaultNodeName.KNOWLEDGE_SOURCE })).not.toBeAttached(); + }); + + test("should dim the target Knowledge Source node", async ({ palette, nodes }) => { + await palette.dragNewNode({ + type: NodeType.KNOWLEDGE_SOURCE, + targetPosition: { x: 300, y: 100 }, + }); + + await nodes.startDraggingEdge({ from: "Source Node", edgeType: EdgeType.KNOWLEDGE_REQUIREMENT }); + + await expect(nodes.get({ name: DefaultNodeName.KNOWLEDGE_SOURCE })).toHaveClass(/.*dimmed/); + }); + + test("shouldn't add an Knowledge Requirement edge from BKM node to Group node", async ({ + palette, + nodes, + edges, + }) => { + await palette.dragNewNode({ + type: NodeType.GROUP, + targetPosition: { x: 400, y: 400 }, + }); + + await nodes.dragNewConnectedEdge({ + type: EdgeType.KNOWLEDGE_REQUIREMENT, + from: "Source Node", + to: DefaultNodeName.GROUP, + position: NodePosition.TOP, + }); + + expect(await edges.get({ from: "Source Node", to: DefaultNodeName.GROUP })).not.toBeAttached(); + }); + + test("should dim the target Group node", async ({ palette, nodes }) => { + await palette.dragNewNode({ + type: NodeType.GROUP, + targetPosition: { x: 300, y: 100 }, + }); + + await nodes.startDraggingEdge({ from: "Source Node", edgeType: EdgeType.KNOWLEDGE_REQUIREMENT }); + + await expect(nodes.get({ name: DefaultNodeName.GROUP })).toHaveClass(/.*dimmed/); + }); + + test("shouldn't add an Knowledge Requirement edge from BKM node to Text Annotation node", async ({ + palette, + nodes, + edges, + }) => { + await palette.dragNewNode({ + type: NodeType.TEXT_ANNOTATION, + targetPosition: { x: 300, y: 100 }, + }); + + await nodes.dragNewConnectedEdge({ + type: EdgeType.KNOWLEDGE_REQUIREMENT, + from: "Source Node", + to: DefaultNodeName.TEXT_ANNOTATION, + }); + + expect(await edges.get({ from: "Source Node", to: DefaultNodeName.TEXT_ANNOTATION })).not.toBeAttached(); + }); + + test("should dim the target Text Annotation node", async ({ palette, nodes }) => { + await palette.dragNewNode({ + type: NodeType.TEXT_ANNOTATION, + targetPosition: { x: 300, y: 100 }, + }); + + await nodes.startDraggingEdge({ from: "Source Node", edgeType: EdgeType.KNOWLEDGE_REQUIREMENT }); + + await expect(nodes.get({ name: DefaultNodeName.TEXT_ANNOTATION })).toHaveClass(/.*dimmed/); + }); + }); +}); diff --git a/packages/dmn-editor/tests/e2e/drgRequirements/moveAuthorityRequirementWaypoint.spec.ts b/packages/dmn-editor/tests/e2e/drgRequirements/moveAuthorityRequirementWaypoint.spec.ts new file mode 100644 index 00000000000..3c47820c919 --- /dev/null +++ b/packages/dmn-editor/tests/e2e/drgRequirements/moveAuthorityRequirementWaypoint.spec.ts @@ -0,0 +1,126 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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 { expect } from "@playwright/test"; +import { test } from "../__fixtures__/base"; +import { DefaultNodeName, NodeType } from "../__fixtures__/nodes"; +import { TestAnnotations } from "@kie-tools/playwright-base/annotations"; + +test.beforeEach(async ({ editor }) => { + await editor.open(); +}); + +test.describe("Move edge waypoint - Authority Requirement", () => { + test.beforeEach(async ({ palette, nodes }) => { + await palette.dragNewNode({ type: NodeType.INPUT_DATA, targetPosition: { x: 100, y: 100 } }); + await nodes.dragNewConnectedNode({ + from: DefaultNodeName.INPUT_DATA, + type: NodeType.KNOWLEDGE_SOURCE, + targetPosition: { x: 100, y: 300 }, + }); + }); + + test.describe("Add Single Waypoint", () => { + test("Authority Requirement waypoint should not move when the ending node is moved", async ({ + diagram, + nodes, + edges, + }) => { + await edges.addWaypoint({ from: DefaultNodeName.INPUT_DATA, to: DefaultNodeName.KNOWLEDGE_SOURCE }); + await nodes.move({ name: DefaultNodeName.KNOWLEDGE_SOURCE, targetPosition: { x: 300, y: 300 } }); + + await expect(diagram.get()).toHaveScreenshot("move-authority-requirement-ending-waypoint.png"); + }); + + test("Authority Requirement ending nodes should not move when the waypoint is moved", async ({ + diagram, + edges, + browserName, + }) => { + test.skip(browserName === "webkit", "https://github.com/apache/incubator-kie-issues/issues/991"); + test.info().annotations.push({ + type: TestAnnotations.REGRESSION, + description: "https://github.com/apache/incubator-kie-issues/issues/991", + }); + + await edges.addWaypoint({ from: DefaultNodeName.INPUT_DATA, to: DefaultNodeName.KNOWLEDGE_SOURCE }); + await edges.moveWaypoint({ + from: DefaultNodeName.INPUT_DATA, + to: DefaultNodeName.KNOWLEDGE_SOURCE, + waypointIndex: 1, + targetPosition: { x: 300, y: 300 }, + }); + + await expect(diagram.get()).toHaveScreenshot("move-authority-requirement-middle-waypoint.png"); + }); + }); + + test.describe("Add Multiple Waypoints", () => { + test("Authority Requirement waypoints should not move when the ending nodes are moved", async ({ + diagram, + nodes, + edges, + }) => { + await edges.addWaypoint({ from: DefaultNodeName.INPUT_DATA, to: DefaultNodeName.KNOWLEDGE_SOURCE }); + await edges.addWaypoint({ + from: DefaultNodeName.INPUT_DATA, + to: DefaultNodeName.KNOWLEDGE_SOURCE, + afterWaypointIndex: 1, + }); + await nodes.move({ name: DefaultNodeName.KNOWLEDGE_SOURCE, targetPosition: { x: 500, y: 500 } }); + await nodes.move({ name: DefaultNodeName.INPUT_DATA, targetPosition: { x: 500, y: 100 } }); + + await expect(diagram.get()).toHaveScreenshot("move-authority-requirement-starting-and-ending-waypoint.png"); + }); + + test("Authority Requirement ending nodes should not move when the waypoints are moved", async ({ + diagram, + edges, + browserName, + }) => { + test.skip(browserName === "webkit", "https://github.com/apache/incubator-kie-issues/issues/991"); + test.info().annotations.push({ + type: TestAnnotations.REGRESSION, + description: "https://github.com/apache/incubator-kie-issues/issues/991", + }); + + await edges.addWaypoint({ from: DefaultNodeName.INPUT_DATA, to: DefaultNodeName.KNOWLEDGE_SOURCE }); + await edges.addWaypoint({ + from: DefaultNodeName.INPUT_DATA, + to: DefaultNodeName.KNOWLEDGE_SOURCE, + afterWaypointIndex: 1, + }); + + await edges.moveWaypoint({ + from: DefaultNodeName.INPUT_DATA, + to: DefaultNodeName.KNOWLEDGE_SOURCE, + waypointIndex: 1, + targetPosition: { x: 500, y: 100 }, + }); + await edges.moveWaypoint({ + from: DefaultNodeName.INPUT_DATA, + to: DefaultNodeName.KNOWLEDGE_SOURCE, + waypointIndex: 2, + targetPosition: { x: 500, y: 500 }, + }); + + await expect(diagram.get()).toHaveScreenshot("move-authority-requirement-middle-waypoints.png"); + }); + }); +}); diff --git a/packages/dmn-editor/tests/e2e/drgRequirements/moveInformationRequirementWaypoint.spec.ts b/packages/dmn-editor/tests/e2e/drgRequirements/moveInformationRequirementWaypoint.spec.ts new file mode 100644 index 00000000000..bcba06bbb50 --- /dev/null +++ b/packages/dmn-editor/tests/e2e/drgRequirements/moveInformationRequirementWaypoint.spec.ts @@ -0,0 +1,126 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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 { expect } from "@playwright/test"; +import { test } from "../__fixtures__/base"; +import { DefaultNodeName, NodeType } from "../__fixtures__/nodes"; +import { TestAnnotations } from "@kie-tools/playwright-base/annotations"; + +test.beforeEach(async ({ editor }) => { + await editor.open(); +}); + +test.describe("Move edge waypoint - Information Requirement", () => { + test.beforeEach(async ({ palette, nodes }) => { + await palette.dragNewNode({ type: NodeType.INPUT_DATA, targetPosition: { x: 100, y: 100 } }); + await nodes.dragNewConnectedNode({ + from: DefaultNodeName.INPUT_DATA, + type: NodeType.DECISION, + targetPosition: { x: 100, y: 300 }, + }); + }); + + test.describe("Add Single Waypoint", () => { + test("Information Requirement edge waypoint should not move when the ending node is moved", async ({ + diagram, + nodes, + edges, + }) => { + await edges.addWaypoint({ from: DefaultNodeName.INPUT_DATA, to: DefaultNodeName.DECISION }); + await nodes.move({ name: DefaultNodeName.DECISION, targetPosition: { x: 300, y: 300 } }); + + await expect(diagram.get()).toHaveScreenshot("move-information-requirement-ending-waypoint.png"); + }); + + test("Information Requirement edge ending nodes should not move when the waypoint is moved", async ({ + diagram, + edges, + browserName, + }) => { + test.skip(browserName === "webkit", "https://github.com/apache/incubator-kie-issues/issues/991"); + test.info().annotations.push({ + type: TestAnnotations.REGRESSION, + description: "https://github.com/apache/incubator-kie-issues/issues/991", + }); + + await edges.addWaypoint({ from: DefaultNodeName.INPUT_DATA, to: DefaultNodeName.DECISION }); + await edges.moveWaypoint({ + from: DefaultNodeName.INPUT_DATA, + to: DefaultNodeName.DECISION, + waypointIndex: 1, + targetPosition: { x: 300, y: 300 }, + }); + + await expect(diagram.get()).toHaveScreenshot("move-information-requirement-middle-waypoint.png"); + }); + }); + + test.describe("Add Multiple Waypoints", () => { + test("Information Requirement edge waypoints should not move when the ending nodes are moved", async ({ + diagram, + nodes, + edges, + }) => { + await edges.addWaypoint({ from: DefaultNodeName.INPUT_DATA, to: DefaultNodeName.DECISION }); + await edges.addWaypoint({ + from: DefaultNodeName.INPUT_DATA, + to: DefaultNodeName.DECISION, + afterWaypointIndex: 1, + }); + await nodes.move({ name: DefaultNodeName.DECISION, targetPosition: { x: 500, y: 500 } }); + await nodes.move({ name: DefaultNodeName.INPUT_DATA, targetPosition: { x: 500, y: 100 } }); + + await expect(diagram.get()).toHaveScreenshot("move-information-requirement-starting-and-ending-waypoint.png"); + }); + + test("Information Requirement edge ending nodes should not move when the waypoints are moved", async ({ + diagram, + edges, + browserName, + }) => { + test.skip(browserName === "webkit", "https://github.com/apache/incubator-kie-issues/issues/991"); + test.info().annotations.push({ + type: TestAnnotations.REGRESSION, + description: "https://github.com/apache/incubator-kie-issues/issues/991", + }); + + await edges.addWaypoint({ from: DefaultNodeName.INPUT_DATA, to: DefaultNodeName.DECISION }); + await edges.addWaypoint({ + from: DefaultNodeName.INPUT_DATA, + to: DefaultNodeName.DECISION, + afterWaypointIndex: 1, + }); + + await edges.moveWaypoint({ + from: DefaultNodeName.INPUT_DATA, + to: DefaultNodeName.DECISION, + waypointIndex: 1, + targetPosition: { x: 500, y: 100 }, + }); + await edges.moveWaypoint({ + from: DefaultNodeName.INPUT_DATA, + to: DefaultNodeName.DECISION, + waypointIndex: 2, + targetPosition: { x: 500, y: 500 }, + }); + + await expect(diagram.get()).toHaveScreenshot("move-information-requirement-middle-waypoints.png"); + }); + }); +}); diff --git a/packages/dmn-editor/tests/e2e/drgRequirements/moveKnowledgeRequirementWaypoint.spec.ts b/packages/dmn-editor/tests/e2e/drgRequirements/moveKnowledgeRequirementWaypoint.spec.ts new file mode 100644 index 00000000000..a06cf738dff --- /dev/null +++ b/packages/dmn-editor/tests/e2e/drgRequirements/moveKnowledgeRequirementWaypoint.spec.ts @@ -0,0 +1,118 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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 { expect } from "@playwright/test"; +import { test } from "../__fixtures__/base"; +import { DefaultNodeName, NodeType } from "../__fixtures__/nodes"; +import { TestAnnotations } from "@kie-tools/playwright-base/annotations"; + +test.beforeEach(async ({ editor }) => { + await editor.open(); +}); + +test.describe("Move edge waypoint - Knowledge Requirement", () => { + test.beforeEach(async ({ palette, nodes }) => { + await palette.dragNewNode({ type: NodeType.BKM, targetPosition: { x: 100, y: 100 } }); + await nodes.dragNewConnectedNode({ + from: DefaultNodeName.BKM, + type: NodeType.DECISION, + targetPosition: { x: 100, y: 300 }, + }); + }); + + test.describe("Add Single Waypoint", () => { + test("Knowledge Requirement edge waypoint should not move when the ending node is moved", async ({ + diagram, + nodes, + edges, + }) => { + await edges.addWaypoint({ from: DefaultNodeName.BKM, to: DefaultNodeName.DECISION }); + await nodes.move({ name: DefaultNodeName.DECISION, targetPosition: { x: 300, y: 300 } }); + + await expect(diagram.get()).toHaveScreenshot("move-knowledge-requirement-ending-waypoint.png"); + }); + + test("Knowledge Requirement edge ending nodes should not move when the waypoint is moved", async ({ + diagram, + edges, + browserName, + }) => { + test.skip(browserName === "webkit", "https://github.com/apache/incubator-kie-issues/issues/991"); + test.info().annotations.push({ + type: TestAnnotations.REGRESSION, + description: "https://github.com/apache/incubator-kie-issues/issues/991", + }); + + await edges.addWaypoint({ from: DefaultNodeName.BKM, to: DefaultNodeName.DECISION }); + await edges.moveWaypoint({ + from: DefaultNodeName.BKM, + to: DefaultNodeName.DECISION, + waypointIndex: 1, + targetPosition: { x: 300, y: 300 }, + }); + + await expect(diagram.get()).toHaveScreenshot("move-knowledge-requirement-middle-waypoint.png"); + }); + }); + + test.describe("Add Multiple Waypoints", () => { + test("Knowledge Requirement edge waypoints should not move when the ending nodes are moved", async ({ + diagram, + nodes, + edges, + }) => { + await edges.addWaypoint({ from: DefaultNodeName.BKM, to: DefaultNodeName.DECISION }); + await edges.addWaypoint({ from: DefaultNodeName.BKM, to: DefaultNodeName.DECISION, afterWaypointIndex: 1 }); + await nodes.move({ name: DefaultNodeName.DECISION, targetPosition: { x: 500, y: 500 } }); + await nodes.move({ name: DefaultNodeName.BKM, targetPosition: { x: 500, y: 100 } }); + + await expect(diagram.get()).toHaveScreenshot("move-knowledge-requirement-starting-and-ending-waypoint.png"); + }); + + test("Knowledge Requirement edge ending nodes should not move when the waypoints are moved", async ({ + diagram, + edges, + browserName, + }) => { + test.skip(browserName === "webkit", "https://github.com/apache/incubator-kie-issues/issues/991"); + test.info().annotations.push({ + type: TestAnnotations.REGRESSION, + description: "https://github.com/apache/incubator-kie-issues/issues/991", + }); + + await edges.addWaypoint({ from: DefaultNodeName.BKM, to: DefaultNodeName.DECISION }); + await edges.addWaypoint({ from: DefaultNodeName.BKM, to: DefaultNodeName.DECISION, afterWaypointIndex: 1 }); + + await edges.moveWaypoint({ + from: DefaultNodeName.BKM, + to: DefaultNodeName.DECISION, + waypointIndex: 1, + targetPosition: { x: 500, y: 100 }, + }); + await edges.moveWaypoint({ + from: DefaultNodeName.BKM, + to: DefaultNodeName.DECISION, + waypointIndex: 2, + targetPosition: { x: 500, y: 500 }, + }); + + await expect(diagram.get()).toHaveScreenshot("move-knowledge-requirement-middle-waypoints.png"); + }); + }); +}); diff --git a/packages/online-editor/tests/e2e/__screenshots__/Google-Chrome/createFiles/sample-dmn.png b/packages/online-editor/tests/e2e/__screenshots__/Google-Chrome/createFiles/sample-dmn.png index 5a6ce84fe13..f0ff3c99415 100644 Binary files a/packages/online-editor/tests/e2e/__screenshots__/Google-Chrome/createFiles/sample-dmn.png and b/packages/online-editor/tests/e2e/__screenshots__/Google-Chrome/createFiles/sample-dmn.png differ diff --git a/packages/online-editor/tests/e2e/__screenshots__/chromium/createFiles/sample-dmn.png b/packages/online-editor/tests/e2e/__screenshots__/chromium/createFiles/sample-dmn.png index 1c9d7e66031..33fb82658f3 100644 Binary files a/packages/online-editor/tests/e2e/__screenshots__/chromium/createFiles/sample-dmn.png and b/packages/online-editor/tests/e2e/__screenshots__/chromium/createFiles/sample-dmn.png differ diff --git a/packages/online-editor/tests/e2e/__screenshots__/webkit/createFiles/sample-dmn.png b/packages/online-editor/tests/e2e/__screenshots__/webkit/createFiles/sample-dmn.png index 9fe9d5c663d..39afe54d573 100644 Binary files a/packages/online-editor/tests/e2e/__screenshots__/webkit/createFiles/sample-dmn.png and b/packages/online-editor/tests/e2e/__screenshots__/webkit/createFiles/sample-dmn.png differ