Skip to content

Commit

Permalink
decisionServiceProperties -> containerNodeProperties
Browse files Browse the repository at this point in the history
  • Loading branch information
jomarko committed Apr 2, 2024
1 parent 1e12b1e commit 9bdf7ed
Show file tree
Hide file tree
Showing 9 changed files with 60 additions and 55 deletions.
8 changes: 4 additions & 4 deletions packages/dmn-editor/tests/e2e/__fixtures__/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import { Edges } from "./edges";
import { JsonModel } from "./jsonModel";
import { GeneralProperties } from "./propertiesPanel/generalProperties";
import { PropertiesPanelBase } from "./propertiesPanel/propertiesPanelBase";
import { GeneralDecisionServiceProperties } from "./propertiesPanel/generalDecisionServiceProperties";
import { ContainerNodeGeneralProperties } from "./propertiesPanel/containerNodeGeneralProperties";
import { DecisionProperties } from "./propertiesPanel/decisionProperties";
import { KnowledgeSourceProperties } from "./propertiesPanel/knowledgeSourceProperties";

Expand All @@ -41,7 +41,7 @@ type DmnEditorFixtures = {
decisionProperties: DecisionProperties;
knowledgeSourceProperties: KnowledgeSourceProperties;
propertiesPanel: PropertiesPanelBase;
generalDecisionServiceProperties: GeneralDecisionServiceProperties;
containerNodeGeneralProperties: ContainerNodeGeneralProperties;
};

export const test = base.extend<DmnEditorFixtures>({
Expand Down Expand Up @@ -75,8 +75,8 @@ export const test = base.extend<DmnEditorFixtures>({
propertiesPanel: async ({ diagram, nodes, page }, use) => {
await use(new PropertiesPanelBase(diagram, nodes, page));
},
generalDecisionServiceProperties: async ({ diagram, nodes, page }, use) => {
await use(new GeneralDecisionServiceProperties(diagram, nodes, page));
containerNodeGeneralProperties: async ({ diagram, nodes, page }, use) => {
await use(new ContainerNodeGeneralProperties(diagram, nodes, page));
},
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,11 @@
import { NodePosition } from "../nodes";
import { GeneralProperties } from "./generalProperties";

export class GeneralDecisionServiceProperties extends GeneralProperties {
public async selectNodeToLoadPropertiesPanel(args: { nodeName: string }) {
/**
* Please use this fixture for manipulation with 'Decision Service' and 'Group' nodes
*/
export class ContainerNodeGeneralProperties extends GeneralProperties {
public async selectNodeByClickToAppropriatePosition(args: { nodeName: string }) {
await this.nodes.select({ name: args.nodeName, position: NodePosition.TOP });
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,26 +21,26 @@ import { PropertiesPanelBase } from "./propertiesPanelBase";

export class DecisionProperties extends PropertiesPanelBase {
public async changeNodeQuestion(args: { nodeName: string; newQuestion: string }) {
await this.selectNodeToLoadPropertiesPanel({ nodeName: args.nodeName });
await this.selectNodeByClickToAppropriatePosition({ nodeName: args.nodeName });
await this.panel().getByPlaceholder("Enter a question...").fill(args.newQuestion);
// commit changes by click to the diagram
await this.diagram.resetFocus();
}

public async getNodeQuestion(args: { nodeName: string }) {
await this.selectNodeToLoadPropertiesPanel({ nodeName: args.nodeName });
await this.selectNodeByClickToAppropriatePosition({ nodeName: args.nodeName });
return await this.panel().getByPlaceholder("Enter a question...").inputValue();
}

public async changeNodeAllowedAnswers(args: { nodeName: string; newAllowedAnswers: string }) {
await this.selectNodeToLoadPropertiesPanel({ nodeName: args.nodeName });
await this.selectNodeByClickToAppropriatePosition({ nodeName: args.nodeName });
await this.panel().getByPlaceholder("Enter allowed answers...").fill(args.newAllowedAnswers);
// commit changes by click to the diagram
await this.diagram.resetFocus();
}

public async getNodeAllowedAnswers(args: { nodeName: string }) {
await this.selectNodeToLoadPropertiesPanel({ nodeName: args.nodeName });
await this.selectNodeByClickToAppropriatePosition({ nodeName: args.nodeName });
return await this.panel().getByPlaceholder("Enter allowed answers...").inputValue();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,37 +18,36 @@
*/

import { DataType } from "../jsonModel";
import { NodePosition } from "../nodes";
import { PropertiesPanelBase } from "./propertiesPanelBase";

export class GeneralProperties extends PropertiesPanelBase {
public async changeNodeName(args: { from: string; to: string }) {
await this.selectNodeToLoadPropertiesPanel({ nodeName: args.from });
await this.selectNodeByClickToAppropriatePosition({ nodeName: args.from });
await this.panel().getByPlaceholder("Enter a name...").fill(args.to);
await this.page.keyboard.press("Enter");
}

public async changeNodeDataType(args: { nodeName: string; newDataType: DataType }) {
await this.selectNodeToLoadPropertiesPanel({ nodeName: args.nodeName });
await this.selectNodeByClickToAppropriatePosition({ nodeName: args.nodeName });
await this.panel().getByPlaceholder("Select a data type...").click();
await this.page.getByRole("option").getByText(args.newDataType, { exact: true }).click();
}

public async changeNodeDescription(args: { nodeName: string; newDescription: string }) {
await this.selectNodeToLoadPropertiesPanel({ nodeName: args.nodeName });
await this.selectNodeByClickToAppropriatePosition({ nodeName: args.nodeName });
await this.panel().getByPlaceholder("Enter a description...").fill(args.newDescription);

// commit changes by click to the diagram
await this.diagram.resetFocus();
}

public async getNodeDescription(args: { nodeName: string }) {
await this.selectNodeToLoadPropertiesPanel({ nodeName: args.nodeName });
await this.selectNodeByClickToAppropriatePosition({ nodeName: args.nodeName });
return await this.panel().getByPlaceholder("Enter a description...").inputValue();
}

public async addDocumentationLink(args: { nodeName: string; linkText: string; linkHref: string }) {
await this.selectNodeToLoadPropertiesPanel({ nodeName: args.nodeName });
await this.selectNodeByClickToAppropriatePosition({ nodeName: args.nodeName });
await this.panel().getByTitle("Add documentation link").click();
await this.panel()
.locator(".kie-dmn-editor--documentation-link--row")
Expand All @@ -62,12 +61,12 @@ export class GeneralProperties extends PropertiesPanelBase {
}

public async getDocumentationLinks(args: { nodeName: string }) {
await this.selectNodeToLoadPropertiesPanel({ nodeName: args.nodeName });
await this.selectNodeByClickToAppropriatePosition({ nodeName: args.nodeName });
return await this.panel().locator(".kie-dmn-editor--documentation-link--row-title").locator("a").all();
}

public async changeNodeFont(args: { nodeName: string; newFont: string }) {
await this.selectNodeToLoadPropertiesPanel({ nodeName: args.nodeName });
await this.selectNodeByClickToAppropriatePosition({ nodeName: args.nodeName });
await this.panel().getByTitle("Expand / collapse Font").click();

await this.panel().locator("[data-ouia-component-id='node-font-style-selector']").click();
Expand All @@ -77,17 +76,14 @@ export class GeneralProperties extends PropertiesPanelBase {
}

public async getNodeFont(args: { nodeName: string }) {
await this.selectNodeToLoadPropertiesPanel({ nodeName: args.nodeName });
await this.selectNodeByClickToAppropriatePosition({ nodeName: args.nodeName });
await this.panel().getByTitle("Expand / collapse Font").click();

return await this.panel().locator("[data-ouia-component-id='node-font-style-selector']").textContent();
}

public async getNodeShape(args: { nodeName: string; position?: NodePosition }) {
await this.selectNodeToLoadPropertiesPanel({
nodeName: args.nodeName,
position: args.position ?? NodePosition.CENTER,
});
public async getNodeShape(args: { nodeName: string }) {
await this.selectNodeByClickToAppropriatePosition({ nodeName: args.nodeName });
await this.panel().getByTitle("Expand / collapse Shape").click();

const width = await this.panel().getByTestId("node-shape-width-input-box").inputValue();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,26 +21,26 @@ import { PropertiesPanelBase } from "./propertiesPanelBase";

export class KnowledgeSourceProperties extends PropertiesPanelBase {
public async changeNodeSourceType(args: { nodeName: string; newSourceType: string }) {
await this.selectNodeToLoadPropertiesPanel({ nodeName: args.nodeName });
await this.selectNodeByClickToAppropriatePosition({ nodeName: args.nodeName });
await this.panel().getByPlaceholder("Enter source type...").fill(args.newSourceType);
// commit changes by click to the diagram
await this.diagram.resetFocus();
}

public async getNodeSourceType(args: { nodeName: string }) {
await this.selectNodeToLoadPropertiesPanel({ nodeName: args.nodeName });
await this.selectNodeByClickToAppropriatePosition({ nodeName: args.nodeName });
return await this.panel().getByPlaceholder("Enter source type...").inputValue();
}

public async changeNodeLocationURI(args: { nodeName: string; newLocationURI: string }) {
await this.selectNodeToLoadPropertiesPanel({ nodeName: args.nodeName });
await this.selectNodeByClickToAppropriatePosition({ nodeName: args.nodeName });
await this.panel().getByPlaceholder("Enter location URI...").fill(args.newLocationURI);
// commit changes by click to the diagram
await this.diagram.resetFocus();
}

public async getNodeLocationURI(args: { nodeName: string }) {
await this.selectNodeToLoadPropertiesPanel({ nodeName: args.nodeName });
await this.selectNodeByClickToAppropriatePosition({ nodeName: args.nodeName });
return await this.panel().getByPlaceholder("Enter location URI...").inputValue();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export class PropertiesPanelBase {
return this.page.getByTestId("properties-panel-container");
}

public async selectNodeToLoadPropertiesPanel(args: { nodeName: string; position?: NodePosition }) {
public async selectNodeByClickToAppropriatePosition(args: { nodeName: string; position?: NodePosition }) {
await this.nodes.select({ name: args.nodeName, position: args.position ?? NodePosition.CENTER });
}

Expand Down
14 changes: 10 additions & 4 deletions packages/dmn-editor/tests/e2e/drdArtifacts/resizeGroup.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,26 @@ test.beforeEach(async ({ editor }) => {
});

test.describe("Resize node - Group", () => {
test("should resize Group node", async ({ palette, nodes, generalProperties }) => {
test("should resize Group node", async ({ palette, nodes, containerNodeGeneralProperties }) => {
await palette.dragNewNode({ type: NodeType.GROUP, targetPosition: { x: 300, y: 300 } });

await nodes.resize({ nodeName: DefaultNodeName.GROUP, position: NodePosition.TOP, xOffset: 50, yOffset: 50 });

await generalProperties.open();
await containerNodeGeneralProperties.open();
await expect(
(
await generalProperties.getNodeShape({ nodeName: DefaultNodeName.GROUP, position: NodePosition.TOP })
await containerNodeGeneralProperties.getNodeShape({
nodeName: DefaultNodeName.GROUP,
position: NodePosition.TOP,
})
).width
).toEqual("360");
await expect(
(
await generalProperties.getNodeShape({ nodeName: DefaultNodeName.GROUP, position: NodePosition.TOP })
await containerNodeGeneralProperties.getNodeShape({
nodeName: DefaultNodeName.GROUP,
position: NodePosition.TOP,
})
).height
).toEqual("360");
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,30 +19,30 @@

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

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

test.describe("Change Properties - Decision Service", () => {
test.beforeEach(async ({ palette, nodes, generalDecisionServiceProperties }) => {
test.beforeEach(async ({ palette, nodes, containerNodeGeneralProperties }) => {
await palette.dragNewNode({ type: NodeType.DECISION_SERVICE, targetPosition: { x: 100, y: 100 } });
await nodes.select({ name: DefaultNodeName.DECISION_SERVICE });
await generalDecisionServiceProperties.open();
await nodes.select({ name: DefaultNodeName.DECISION_SERVICE, position: NodePosition.TOP });
await containerNodeGeneralProperties.open();
});

test("should change the Decision Service node name", async ({ nodes, generalDecisionServiceProperties }) => {
await generalDecisionServiceProperties.changeNodeName({
test("should change the Decision Service node name", async ({ nodes, containerNodeGeneralProperties }) => {
await containerNodeGeneralProperties.changeNodeName({
from: DefaultNodeName.DECISION_SERVICE,
to: "Renamed Decision Service",
});

await expect(nodes.get({ name: "Renamed Decision Service" })).toBeVisible();
});

test("should change the Decision Service node data type", async ({ nodes, generalDecisionServiceProperties }) => {
await generalDecisionServiceProperties.changeNodeDataType({
test("should change the Decision Service node data type", async ({ nodes, containerNodeGeneralProperties }) => {
await containerNodeGeneralProperties.changeNodeDataType({
nodeName: DefaultNodeName.DECISION_SERVICE,
newDataType: DataType.Number,
});
Expand All @@ -53,46 +53,46 @@ test.describe("Change Properties - Decision Service", () => {
).toHaveValue(DataType.Number);
});

test("should change the Decision Service node description", async ({ generalDecisionServiceProperties }) => {
await generalDecisionServiceProperties.changeNodeDescription({
test("should change the Decision Service node description", async ({ containerNodeGeneralProperties }) => {
await containerNodeGeneralProperties.changeNodeDescription({
nodeName: DefaultNodeName.DECISION_SERVICE,
newDescription: "New Decision Service Description",
});

expect(
await generalDecisionServiceProperties.getNodeDescription({ nodeName: DefaultNodeName.DECISION_SERVICE })
await containerNodeGeneralProperties.getNodeDescription({ nodeName: DefaultNodeName.DECISION_SERVICE })
).toBe("New Decision Service Description");
});

test("should change the Decision Service node documentation links", async ({ generalDecisionServiceProperties }) => {
await generalDecisionServiceProperties.addDocumentationLink({
test("should change the Decision Service node documentation links", async ({ containerNodeGeneralProperties }) => {
await containerNodeGeneralProperties.addDocumentationLink({
nodeName: DefaultNodeName.DECISION_SERVICE,
linkText: "Link Text",
linkHref: "http://link.test.com",
});

const links = await generalDecisionServiceProperties.getDocumentationLinks({
const links = await containerNodeGeneralProperties.getDocumentationLinks({
nodeName: DefaultNodeName.DECISION_SERVICE,
});
expect(links).toHaveLength(1);
expect(links[0]).toHaveText("Link Text");
expect(links[0]).toHaveAttribute("href", "http://link.test.com/");
});

test("should change the Decision Service node font - family", async ({ generalDecisionServiceProperties }) => {
await generalDecisionServiceProperties.changeNodeFont({
test("should change the Decision Service node font - family", async ({ containerNodeGeneralProperties }) => {
await containerNodeGeneralProperties.changeNodeFont({
nodeName: DefaultNodeName.DECISION_SERVICE,
newFont: "Verdana",
});

expect(await generalDecisionServiceProperties.getNodeFont({ nodeName: DefaultNodeName.DECISION_SERVICE })).toBe(
expect(await containerNodeGeneralProperties.getNodeFont({ nodeName: DefaultNodeName.DECISION_SERVICE })).toBe(
"Verdana"
);
});

test.skip("should change the Decision Service node shape - background color", async ({
nodes,
generalDecisionServiceProperties,
containerNodeGeneralProperties,
}) => {
// blocked https://github.com/microsoft/playwright/issues/19929#issuecomment-1377035969
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ test.beforeEach(async ({ editor }) => {
});

test.describe("Resize node - Decision Service", () => {
test("should resize Decision Service node", async ({ palette, nodes, generalDecisionServiceProperties }) => {
test("should resize Decision Service node", async ({ palette, nodes, containerNodeGeneralProperties }) => {
await palette.dragNewNode({ type: NodeType.DECISION_SERVICE, targetPosition: { x: 100, y: 100 } });

await nodes.resize({
Expand All @@ -35,15 +35,15 @@ test.describe("Resize node - Decision Service", () => {
yOffset: 50,
});

await generalDecisionServiceProperties.open();
await containerNodeGeneralProperties.open();
await expect(
(
await generalDecisionServiceProperties.getNodeShape({ nodeName: DefaultNodeName.DECISION_SERVICE })
await containerNodeGeneralProperties.getNodeShape({ nodeName: DefaultNodeName.DECISION_SERVICE })
).width
).toEqual("360");
await expect(
(
await generalDecisionServiceProperties.getNodeShape({ nodeName: DefaultNodeName.DECISION_SERVICE })
await containerNodeGeneralProperties.getNodeShape({ nodeName: DefaultNodeName.DECISION_SERVICE })
).height
).toEqual("360");
});
Expand Down

0 comments on commit 9bdf7ed

Please sign in to comment.