Skip to content

Commit

Permalink
typeAttribution for relevant nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
jomarko committed Mar 15, 2024
1 parent 9d128d5 commit b31d9db
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 19 deletions.
7 changes: 7 additions & 0 deletions packages/dmn-editor/tests/e2e/__fixtures__/nodes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import { Locator, Page } from "@playwright/test";
import { Diagram } from "./diagram";
import { EdgeType } from "./edges";
import { DataType } from "./jsonModel";

export enum NodeType {
INPUT_DATA,
Expand Down Expand Up @@ -133,6 +134,12 @@ export class Nodes {
await this.diagram.get().press("Enter");
}

public async changeDataType(args: { nodeName: string; from: DataType; to: DataType }) {
await this.hover({ name: args.nodeName });
await this.get({ name: args.nodeName }).getByLabel(args.from).click();
await this.get({ name: args.nodeName }).getByRole("option").getByText(args.to, { exact: true }).click();
}

public async select(args: { name: string; position?: NodePosition }) {
const node = this.get({ name: args.name });

Expand Down
51 changes: 32 additions & 19 deletions packages/dmn-editor/tests/e2e/drgElements/typeAttribution.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,38 +18,51 @@
*/

import { test, expect } from "../__fixtures__/base";
import { DEFAULT_DRD_NAME } from "../__fixtures__/diagram";
import { DataType } from "../__fixtures__/jsonModel";
import { DefaultNodeName, NodeType } from "../__fixtures__/nodes";

test.beforeEach(async ({ editor }) => {
await editor.open();
});

test.describe("Type attribution", () => {
test.describe("Input Data", () => {
test.only("should change Input Data data type", async ({ page, palette, nodes }) => {
await palette.dragNewNode({ type: NodeType.INPUT_DATA, targetPosition: { x: 100, y: 100 } });
test.describe.only("Type attribution", () => {
test("should change Input Data node data type", async ({ palette, nodes }) => {
await palette.dragNewNode({ type: NodeType.INPUT_DATA, targetPosition: { x: 100, y: 100 } });

await nodes.hover({ name: DefaultNodeName.INPUT_DATA });
await nodes.get({ name: DefaultNodeName.INPUT_DATA }).getByLabel(DataType.Undefined).click();
await page.pause();
await nodes
.get({ name: DefaultNodeName.INPUT_DATA })
.getByRole("option")
.getByText(DataType.Number, { exact: true })
.click();
await nodes.changeDataType({ nodeName: DefaultNodeName.INPUT_DATA, from: DataType.Undefined, to: DataType.Number });

await page.pause();
await nodes.hover({ name: DefaultNodeName.INPUT_DATA });
await expect(nodes.get({ name: DefaultNodeName.INPUT_DATA }).locator("input")).toHaveValue(DataType.Number);
});

test("should change Decision node data type", async ({ palette, nodes }) => {
await palette.dragNewNode({ type: NodeType.DECISION, targetPosition: { x: 100, y: 100 } });

await nodes.changeDataType({ nodeName: DefaultNodeName.DECISION, from: DataType.Undefined, to: DataType.Number });

await nodes.hover({ name: DefaultNodeName.DECISION });
await expect(nodes.get({ name: DefaultNodeName.DECISION }).locator("input")).toHaveValue(DataType.Number);
});

test("should change Decision Service node data type", async ({ palette, nodes }) => {
await palette.dragNewNode({ type: NodeType.DECISION_SERVICE, targetPosition: { x: 100, y: 100 } });

await nodes.hover({ name: DefaultNodeName.INPUT_DATA });
await page.pause();
await nodes.changeDataType({
nodeName: DefaultNodeName.DECISION_SERVICE,
from: DataType.Undefined,
to: DataType.Number,
});

await nodes.hover({ name: DefaultNodeName.DECISION_SERVICE });
await expect(nodes.get({ name: DefaultNodeName.DECISION_SERVICE }).locator("input")).toHaveValue(DataType.Number);
});

test.describe("Decision", () => {});
test.only("should change BKM node data type", async ({ palette, nodes }) => {
await palette.dragNewNode({ type: NodeType.BKM, targetPosition: { x: 100, y: 100 } });

test.describe("Decision Service", () => {});
await nodes.changeDataType({ nodeName: DefaultNodeName.BKM, from: DataType.Undefined, to: DataType.Number });

test.describe("BKM", () => {});
await nodes.hover({ name: DefaultNodeName.BKM });
await expect(nodes.get({ name: DefaultNodeName.BKM }).locator("input")).toHaveValue(DataType.Number);
});
});

0 comments on commit b31d9db

Please sign in to comment.