Skip to content

Commit

Permalink
Add missing Group And text Annotation properties tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jomarko committed Mar 28, 2024
1 parent 53d0923 commit ac293fe
Show file tree
Hide file tree
Showing 4 changed files with 185 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 @@ -29,6 +29,7 @@ import { PropertiesPanelBase } from "./propertiesPanel/propertiesPanelBase";
import { ContainerNodeGeneralProperties } from "./propertiesPanel/containerNodeGeneralProperties";
import { DecisionProperties } from "./propertiesPanel/decisionProperties";
import { KnowledgeSourceProperties } from "./propertiesPanel/knowledgeSourceProperties";
import { TextAnnotationProperties } from "./propertiesPanel/textAnnotationProperties";

type DmnEditorFixtures = {
diagram: Diagram;
Expand All @@ -40,6 +41,7 @@ type DmnEditorFixtures = {
generalProperties: GeneralProperties;
decisionProperties: DecisionProperties;
knowledgeSourceProperties: KnowledgeSourceProperties;
textAnnotationProperties: TextAnnotationProperties;
propertiesPanel: PropertiesPanelBase;
containerNodeGeneralProperties: ContainerNodeGeneralProperties;
};
Expand Down Expand Up @@ -72,6 +74,9 @@ export const test = base.extend<DmnEditorFixtures>({
knowledgeSourceProperties: async ({ diagram, nodes, page }, use) => {
await use(new KnowledgeSourceProperties(diagram, nodes, page));
},
textAnnotationProperties: async ({ diagram, nodes, page }, use) => {
await use(new TextAnnotationProperties(diagram, nodes, page));
},
propertiesPanel: async ({ diagram, nodes, page }, use) => {
await use(new PropertiesPanelBase(diagram, nodes, page));
},
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* 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 { PropertiesPanelBase } from "./propertiesPanelBase";

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

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

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

public async getNodeText(args: { nodeName: string }) {
await this.selectNodeByClickToAppropriatePosition({ nodeName: args.nodeName });
return await this.panel().getByPlaceholder("Enter text...").inputValue();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/*
* 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";

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

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

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

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

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

expect(await containerNodeGeneralProperties.getNodeDescription({ nodeName: DefaultNodeName.GROUP })).toBe(
"New Group Description"
);
});

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

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

test.skip("should change the Group node shape - background color", async ({ nodes, propertiesPanel }) => {
// blocked https://github.com/microsoft/playwright/issues/19929#issuecomment-1377035969
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
/*
* 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, NodeType } from "../__fixtures__/nodes";

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

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

test("should change the Text Annotation node Format", async ({ textAnnotationProperties }) => {
await textAnnotationProperties.changeNodeFormat({
nodeName: DefaultNodeName.TEXT_ANNOTATION,
newFormat: "plaintext",
});

expect(await textAnnotationProperties.getNodeFormat({ nodeName: DefaultNodeName.TEXT_ANNOTATION })).toBe(
"plaintext"
);
});

test("should change the Text Annotation node Text", async ({ textAnnotationProperties }) => {
await textAnnotationProperties.changeNodeText({
nodeName: DefaultNodeName.TEXT_ANNOTATION,
newText: "new text content",
});

expect(await textAnnotationProperties.getNodeText({ nodeName: "new text content" })).toBe("new text content");
});

test("should change the Text Annotation node description", async ({ generalProperties }) => {
await generalProperties.changeNodeDescription({
nodeName: DefaultNodeName.TEXT_ANNOTATION,
newDescription: "New Text Annotation Description",
});

expect(await generalProperties.getNodeDescription({ nodeName: DefaultNodeName.TEXT_ANNOTATION })).toBe(
"New Text Annotation Description"
);
});

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

expect(await generalProperties.getNodeFont({ nodeName: DefaultNodeName.TEXT_ANNOTATION })).toBe("Verdana");
});

test.skip("should change the Text Annotation node shape - background color", async ({ nodes, propertiesPanel }) => {
// blocked https://github.com/microsoft/playwright/issues/19929#issuecomment-1377035969
});
});

0 comments on commit ac293fe

Please sign in to comment.