Skip to content

Commit

Permalink
do not select ndoe as part of panel fixture
Browse files Browse the repository at this point in the history
  • Loading branch information
jomarko committed Apr 3, 2024
1 parent 7a72ca2 commit 2838c91
Show file tree
Hide file tree
Showing 23 changed files with 225 additions and 271 deletions.
36 changes: 18 additions & 18 deletions packages/dmn-editor/tests/e2e/__fixtures__/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,32 +71,32 @@ export const test = base.extend<DmnEditorFixtures>({
palette: async ({ page, diagram, nodes }, use) => {
await use(new Palette(page, diagram, nodes));
},
bkmPropertiesPanel: async ({ diagram, nodes, page }, use) => {
await use(new BkmPropertiesPanel(diagram, nodes, page));
bkmPropertiesPanel: async ({ diagram, page }, use) => {
await use(new BkmPropertiesPanel(diagram, page));
},
decisionPropertiesPanel: async ({ diagram, nodes, page }, use) => {
await use(new DecisionPropertiesPanel(diagram, nodes, page));
decisionPropertiesPanel: async ({ diagram, page }, use) => {
await use(new DecisionPropertiesPanel(diagram, page));
},
decisionServicePropertiesPanel: async ({ diagram, nodes, page }, use) => {
await use(new DecisionServicePropertiesPanel(diagram, nodes, page));
decisionServicePropertiesPanel: async ({ diagram, page }, use) => {
await use(new DecisionServicePropertiesPanel(diagram, page));
},
diagramPropertiesPanel: async ({ diagram, nodes, page }, use) => {
await use(new DiagramPropertiesPanel(diagram, nodes, page));
diagramPropertiesPanel: async ({ diagram, page }, use) => {
await use(new DiagramPropertiesPanel(diagram, page));
},
groupPropertiesPanel: async ({ diagram, nodes, page }, use) => {
await use(new GroupPropertiesPanel(diagram, nodes, page));
groupPropertiesPanel: async ({ diagram, page }, use) => {
await use(new GroupPropertiesPanel(diagram, page));
},
knowledgeSourcePropertiesPanel: async ({ diagram, nodes, page }, use) => {
await use(new KnowledgeSourcePropertiesPanel(diagram, nodes, page));
knowledgeSourcePropertiesPanel: async ({ diagram, page }, use) => {
await use(new KnowledgeSourcePropertiesPanel(diagram, page));
},
inputDataPropertiesPanel: async ({ diagram, nodes, page }, use) => {
await use(new InputDataPropertiesPanel(diagram, nodes, page));
inputDataPropertiesPanel: async ({ diagram, page }, use) => {
await use(new InputDataPropertiesPanel(diagram, page));
},
multipleNodesPropertiesPanel: async ({ diagram, nodes, page }, use) => {
await use(new MultipleNodesPropertiesPanel(diagram, nodes, page));
multipleNodesPropertiesPanel: async ({ diagram, page }, use) => {
await use(new MultipleNodesPropertiesPanel(diagram, page));
},
textAnnotationPropertiesPanel: async ({ diagram, nodes, page }, use) => {
await use(new TextAnnotationPropertiesPanel(diagram, nodes, page));
textAnnotationPropertiesPanel: async ({ diagram, page }, use) => {
await use(new TextAnnotationPropertiesPanel(diagram, page));
},
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,27 +20,23 @@
import { PropertiesPanelBase } from "./propertiesPanelBase";

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

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

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

public async getAllowedAnswers(args: { nodeName: string }) {
await this.selectNodeByClickToAppropriatePosition({ nodeName: args.nodeName });
public async getAllowedAnswers() {
return await this.panel().getByPlaceholder("Enter allowed answers...").inputValue();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,6 @@
* under the License.
*/

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

export class DecisionServicePropertiesPanel extends PropertiesPanelBase {
public async selectNodeByClickToAppropriatePosition(args: { nodeName: string }) {
await this.nodes.select({ name: args.nodeName, position: NodePosition.TOP });
}
}
export class DecisionServicePropertiesPanel extends PropertiesPanelBase {}
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,6 @@
* under the License.
*/

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

export class GroupPropertiesPanel extends PropertiesPanelBase {
public async selectNodeByClickToAppropriatePosition(args: { nodeName: string }) {
await this.nodes.select({ name: args.nodeName, position: NodePosition.TOP });
}
}
export class GroupPropertiesPanel extends PropertiesPanelBase {}
Original file line number Diff line number Diff line change
Expand Up @@ -20,27 +20,23 @@
import { PropertiesPanelBase } from "./propertiesPanelBase";

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

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

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

public async getLocationURI(args: { nodeName: string }) {
await this.selectNodeByClickToAppropriatePosition({ nodeName: args.nodeName });
public async getLocationURI() {
return await this.panel().getByPlaceholder("Enter location URI...").inputValue();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@
import { PropertiesPanelBase } from "./propertiesPanelBase";

export class MultipleNodesPropertiesPanel extends PropertiesPanelBase {
public async setMultipleNodesFont(args: { nodeNames: string[]; newFont: string }) {
await this.nodes.selectMultiple({ names: args.nodeNames });

public async setMultipleNodesFont(args: { newFont: string }) {
await this.panel().getByTestId("node-font-style-selector").click();
await this.panel().getByText(args.newFont).click();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,56 +19,45 @@

import { Page } from "@playwright/test";
import { Diagram } from "../diagram";
import { NodePosition, Nodes } from "../nodes";
import { DataType } from "../jsonModel";

export abstract class PropertiesPanelBase {
constructor(public diagram: Diagram, public nodes: Nodes, public page: Page) {}
constructor(public diagram: Diagram, public page: Page) {}

public panel() {
return this.page.getByTestId("properties-panel-container");
}

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

public async open() {
await this.page.getByTitle("Properties panel").click();
}

public async setName(args: { from: string; to: string }) {
await this.selectNodeByClickToAppropriatePosition({ nodeName: args.from });
await this.panel().getByPlaceholder("Enter a name...").fill(args.to);
public async setName(args: { newName: string }) {
await this.panel().getByPlaceholder("Enter a name...").fill(args.newName);
await this.page.keyboard.press("Enter");
}

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

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

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

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

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

public async addDocumentationLink(args: { nodeName: string; linkText: string; linkHref: string }) {
await this.selectNodeByClickToAppropriatePosition({ nodeName: args.nodeName });
public async addDocumentationLink(args: { linkText: string; linkHref: string }) {
await this.panel().getByTitle("Add documentation link").click();
await this.panel()
.locator(".kie-dmn-editor--documentation-link--row")
Expand All @@ -81,13 +70,11 @@ export abstract class PropertiesPanelBase {
await this.page.keyboard.press("Enter");
}

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

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

await this.panel().getByTestId("node-font-style-selector").click();
Expand All @@ -96,8 +83,7 @@ export abstract class PropertiesPanelBase {
await this.diagram.resetFocus();
}

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

const font = await this.panel().getByTestId("node-font-style-selector").textContent();
Expand All @@ -107,8 +93,7 @@ export abstract class PropertiesPanelBase {
return font;
}

public async getShape(args: { nodeName: string }) {
await this.selectNodeByClickToAppropriatePosition({ nodeName: args.nodeName });
public async getShape() {
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 @@ -20,27 +20,23 @@
import { PropertiesPanelBase } from "./propertiesPanelBase";

export class TextAnnotationProperties extends PropertiesPanelBase {
public async setFormat(args: { nodeName: string; newFormat: string }) {
await this.selectNodeByClickToAppropriatePosition({ nodeName: args.nodeName });
public async setFormat(args: { newFormat: string }) {
await this.panel().getByPlaceholder("Enter a text format...").fill(args.newFormat);
// commit changes by click to the diagram
await this.diagram.resetFocus();
}

public async getFormat(args: { nodeName: string }) {
await this.selectNodeByClickToAppropriatePosition({ nodeName: args.nodeName });
public async getFormat() {
return await this.panel().getByPlaceholder("Enter a text format...").inputValue();
}

public async setText(args: { nodeName: string; newText: string }) {
await this.selectNodeByClickToAppropriatePosition({ nodeName: args.nodeName });
public async setText(args: { newText: string }) {
await this.panel().getByPlaceholder("Enter text...").fill(args.newText);
// commit changes by click to the diagram
await this.diagram.resetFocus();
}

public async getText(args: { nodeName: string }) {
await this.selectNodeByClickToAppropriatePosition({ nodeName: args.nodeName });
public async getText() {
return await this.panel().getByPlaceholder("Enter text...").inputValue();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,27 +32,30 @@ test.describe("Change Properties - Group", () => {
});

test("should change the Group node name", async ({ nodes, groupPropertiesPanel }) => {
await groupPropertiesPanel.setName({ from: DefaultNodeName.GROUP, to: "Renamed Group" });
await nodes.select({ name: DefaultNodeName.GROUP, position: NodePosition.TOP });
await groupPropertiesPanel.setName({ newName: "Renamed Group" });

await nodes.select({ name: "Renamed Group", position: NodePosition.TOP });
await expect(nodes.get({ name: "Renamed Group" })).toBeVisible();
expect(await groupPropertiesPanel.getName({ nodeName: "Renamed Group" })).toBe("Renamed Group");
expect(await groupPropertiesPanel.getName()).toBe("Renamed Group");
});

test("should change the Group node description", async ({ groupPropertiesPanel }) => {
test("should change the Group node description", async ({ nodes, groupPropertiesPanel }) => {
await nodes.select({ name: DefaultNodeName.GROUP, position: NodePosition.TOP });
await groupPropertiesPanel.setDescription({
nodeName: DefaultNodeName.GROUP,
newDescription: "New Group Description",
});

expect(await groupPropertiesPanel.getDescription({ nodeName: DefaultNodeName.GROUP })).toBe(
"New Group Description"
);
await nodes.select({ name: DefaultNodeName.GROUP, position: NodePosition.TOP });
expect(await groupPropertiesPanel.getDescription()).toBe("New Group Description");
});

test("should change the Group node font - family", async ({ groupPropertiesPanel }) => {
await groupPropertiesPanel.setFont({ nodeName: DefaultNodeName.GROUP, newFont: "Verdana" });
test("should change the Group node font - family", async ({ nodes, groupPropertiesPanel }) => {
await nodes.select({ name: DefaultNodeName.GROUP, position: NodePosition.TOP });
await groupPropertiesPanel.setFont({ newFont: "Verdana" });

expect(await groupPropertiesPanel.getFont({ nodeName: DefaultNodeName.GROUP })).toBe("Verdana");
await nodes.select({ name: DefaultNodeName.GROUP, position: NodePosition.TOP });
expect(await groupPropertiesPanel.getFont()).toBe("Verdana");
});

test.skip("should change the Group node shape - background color", async ({ nodes, groupPropertiesPanel }) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,41 +31,42 @@ test.describe("Change Properties - Text Annotation", () => {
await textAnnotationPropertiesPanel.open();
});

test("should change the Text Annotation node Format", async ({ textAnnotationPropertiesPanel }) => {
test("should change the Text Annotation node Format", async ({ nodes, textAnnotationPropertiesPanel }) => {
await nodes.select({ name: DefaultNodeName.TEXT_ANNOTATION });
await textAnnotationPropertiesPanel.setFormat({
nodeName: DefaultNodeName.TEXT_ANNOTATION,
newFormat: "plaintext",
});

expect(await textAnnotationPropertiesPanel.getFormat({ nodeName: DefaultNodeName.TEXT_ANNOTATION })).toBe(
"plaintext"
);
await nodes.select({ name: DefaultNodeName.TEXT_ANNOTATION });
expect(await textAnnotationPropertiesPanel.getFormat()).toBe("plaintext");
});

test("should change the Text Annotation node Text", async ({ textAnnotationPropertiesPanel }) => {
test("should change the Text Annotation node Text", async ({ nodes, textAnnotationPropertiesPanel }) => {
await nodes.select({ name: DefaultNodeName.TEXT_ANNOTATION });
await textAnnotationPropertiesPanel.setText({
nodeName: DefaultNodeName.TEXT_ANNOTATION,
newText: "new text content",
});

expect(await textAnnotationPropertiesPanel.getText({ nodeName: "new text content" })).toBe("new text content");
await nodes.select({ name: "new text content" });
expect(await textAnnotationPropertiesPanel.getText()).toBe("new text content");
});

test("should change the Text Annotation node description", async ({ textAnnotationPropertiesPanel }) => {
test("should change the Text Annotation node description", async ({ nodes, textAnnotationPropertiesPanel }) => {
await nodes.select({ name: DefaultNodeName.TEXT_ANNOTATION });
await textAnnotationPropertiesPanel.setDescription({
nodeName: DefaultNodeName.TEXT_ANNOTATION,
newDescription: "New Text Annotation Description",
});

expect(await textAnnotationPropertiesPanel.getDescription({ nodeName: DefaultNodeName.TEXT_ANNOTATION })).toBe(
"New Text Annotation Description"
);
await nodes.select({ name: DefaultNodeName.TEXT_ANNOTATION });
expect(await textAnnotationPropertiesPanel.getDescription()).toBe("New Text Annotation Description");
});

test("should change the Text Annotation node font - family", async ({ textAnnotationPropertiesPanel }) => {
await textAnnotationPropertiesPanel.setFont({ nodeName: DefaultNodeName.TEXT_ANNOTATION, newFont: "Verdana" });
test("should change the Text Annotation node font - family", async ({ nodes, textAnnotationPropertiesPanel }) => {
await nodes.select({ name: DefaultNodeName.TEXT_ANNOTATION });
await textAnnotationPropertiesPanel.setFont({ newFont: "Verdana" });

expect(await textAnnotationPropertiesPanel.getFont({ nodeName: DefaultNodeName.TEXT_ANNOTATION })).toBe("Verdana");
await nodes.select({ name: DefaultNodeName.TEXT_ANNOTATION });
expect(await textAnnotationPropertiesPanel.getFont()).toBe("Verdana");
});

test.skip("should change the Text Annotation node shape - background color", async ({
Expand Down
Loading

0 comments on commit 2838c91

Please sign in to comment.