Skip to content

Commit

Permalink
draft decisionPropertiesPanel.spec.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
jomarko committed Mar 20, 2024
1 parent ff23ad6 commit 269d395
Show file tree
Hide file tree
Showing 3 changed files with 149 additions and 0 deletions.
5 changes: 5 additions & 0 deletions packages/dmn-editor/tests/e2e/__fixtures__/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import { Nodes } from "./nodes";
import { Editor } from "./editor";
import { Edges } from "./edges";
import { JsonModel } from "./jsonModel";
import { PropertiesPanel } from "./propertiesPanel";

type DmnEditorFixtures = {
diagram: Diagram;
Expand All @@ -32,6 +33,7 @@ type DmnEditorFixtures = {
jsonModel: JsonModel;
nodes: Nodes;
palette: Palette;
propertiesPanel: PropertiesPanel;
};

export const test = base.extend<DmnEditorFixtures>({
Expand All @@ -53,6 +55,9 @@ export const test = base.extend<DmnEditorFixtures>({
palette: async ({ page, diagram, nodes }, use) => {
await use(new Palette(page, diagram, nodes));
},
propertiesPanel: async ({ page }, use) => {
await use(new PropertiesPanel(page));
},
});

export { expect } from "@playwright/test";
64 changes: 64 additions & 0 deletions packages/dmn-editor/tests/e2e/__fixtures__/propertiesPanel.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/*
* 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 { Page } from "@playwright/test";
import { DataType } from "./jsonModel";

export class PropertiesPanel {
constructor(public page: Page) {}

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

public async changeNodeName(args: { newName: string }) {
await this.page.getByPlaceholder("Enter a name...").fill(args.newName);
await this.page.keyboard.press("Enter");
}

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

public async changeNodeDescription(args: { newDescription: string }) {
await this.page.getByPlaceholder("Enter a description...").fill(args.newDescription);
await this.page.keyboard.press("Enter");
}

public async changeNodeQuestion(args: { newQuestion: string }) {
await this.page.getByPlaceholder("Enter a question...").fill(args.newQuestion);
await this.page.keyboard.press("Enter");
}

public async changeNodeAllowedAnswers(args: { newAllowedAnswers: string }) {
await this.page.getByPlaceholder("Enter allowed answers...").fill(args.newAllowedAnswers);
await this.page.keyboard.press("Enter");
}

public async addDocumentationLink(args: { linkText: string; linkHref: string }) {
await this.page.getByTitle("Add documentation link").click();
await this.page
.locator(".kie-dmn-editor--documentation-link--row")
.getByPlaceholder("Enter a title...")
.fill(args.linkText);
await this.page.locator(".kie-dmn-editor--documentation-link--row").getByPlaceholder("http://").fill(args.linkHref);
await this.page.keyboard.press("Enter");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
/*
* 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 { DataType } from "../__fixtures__/jsonModel";
import { DefaultNodeName, NodeType } from "../__fixtures__/nodes";

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

test.describe.only("Change Properties - Decision", () => {
test.beforeEach(async ({ palette, nodes, propertiesPanel }) => {
await palette.dragNewNode({ type: NodeType.DECISION, targetPosition: { x: 100, y: 100 } });
await nodes.select({ name: DefaultNodeName.DECISION });
await propertiesPanel.open();
});

test("should change the Decision node name", async ({ nodes, propertiesPanel }) => {
await propertiesPanel.changeNodeName({ newName: "Renamed Decision" });

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

test("should change the Decision node data type", async ({ nodes, propertiesPanel }) => {
await propertiesPanel.changeNodeDataType({ newDataType: DataType.Number });

await nodes.hover({ name: DefaultNodeName.DECISION });
await expect(nodes.get({ name: DefaultNodeName.DECISION }).getByPlaceholder("Select a data type...")).toHaveValue(
DataType.Number
);
});

test("should change the Decision node description", async ({ nodes, propertiesPanel }) => {
await propertiesPanel.changeNodeDescription({ newDescription: "New Decision Description" });

// assert uisng jsonModel? assert using reopening properties panel? assert using screenshot?
});

test("should change the Decision node question", async ({ nodes, propertiesPanel }) => {
await propertiesPanel.changeNodeQuestion({ newQuestion: "New Decision Question" });

// assert uisng jsonModel? assert using reopening properties panel? assert using screenshot?
});

test("should change the Decision node answers", async ({ nodes, propertiesPanel }) => {
await propertiesPanel.changeNodeAllowedAnswers({ newAllowedAnswers: "New Allowed Answers" });

// assert uisng jsonModel? assert using reopening properties panel? assert using screenshot?
});

test("should change the Decision node documentation links", async ({ nodes, propertiesPanel }) => {
await propertiesPanel.addDocumentationLink({ linkText: "Link Texts", linkHref: "http://link.test.com" });

// assert uisng jsonModel? assert using reopening properties panel? assert using screenshot?
});

test("should change the Decision node font", async ({ nodes, propertiesPanel }) => {
// TODO
});
test("should change the Decision node shape", async ({ nodes, propertiesPanel }) => {
// TODO
});
});

0 comments on commit 269d395

Please sign in to comment.