From 654d7fae6d864f3ae370b89b49ff5420dd33afdb Mon Sep 17 00:00:00 2001 From: Jozef Marko Date: Thu, 28 Mar 2024 12:00:47 +0100 Subject: [PATCH] Add missing Group And text Annotation properties tests --- .../dmn-editor/tests/e2e/__fixtures__/base.ts | 5 ++ .../textAnnotationProperties.ts | 46 ++++++++++++ .../changeGroupProperties.spec.ts | 60 +++++++++++++++ .../changeTextAnnotationProperties.spec.ts | 74 +++++++++++++++++++ 4 files changed, 185 insertions(+) create mode 100644 packages/dmn-editor/tests/e2e/__fixtures__/propertiesPanel/textAnnotationProperties.ts create mode 100644 packages/dmn-editor/tests/e2e/drdArtifacts/changeGroupProperties.spec.ts create mode 100644 packages/dmn-editor/tests/e2e/drdArtifacts/changeTextAnnotationProperties.spec.ts diff --git a/packages/dmn-editor/tests/e2e/__fixtures__/base.ts b/packages/dmn-editor/tests/e2e/__fixtures__/base.ts index fbd20c10096..b220096cd8a 100644 --- a/packages/dmn-editor/tests/e2e/__fixtures__/base.ts +++ b/packages/dmn-editor/tests/e2e/__fixtures__/base.ts @@ -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; @@ -40,6 +41,7 @@ type DmnEditorFixtures = { generalProperties: GeneralProperties; decisionProperties: DecisionProperties; knowledgeSourceProperties: KnowledgeSourceProperties; + textAnnotationProperties: TextAnnotationProperties; propertiesPanel: PropertiesPanelBase; containerNodeGeneralProperties: ContainerNodeGeneralProperties; }; @@ -72,6 +74,9 @@ export const test = base.extend({ 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)); }, diff --git a/packages/dmn-editor/tests/e2e/__fixtures__/propertiesPanel/textAnnotationProperties.ts b/packages/dmn-editor/tests/e2e/__fixtures__/propertiesPanel/textAnnotationProperties.ts new file mode 100644 index 00000000000..2de3161ddb2 --- /dev/null +++ b/packages/dmn-editor/tests/e2e/__fixtures__/propertiesPanel/textAnnotationProperties.ts @@ -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(); + } +} diff --git a/packages/dmn-editor/tests/e2e/drdArtifacts/changeGroupProperties.spec.ts b/packages/dmn-editor/tests/e2e/drdArtifacts/changeGroupProperties.spec.ts new file mode 100644 index 00000000000..fdb61308762 --- /dev/null +++ b/packages/dmn-editor/tests/e2e/drdArtifacts/changeGroupProperties.spec.ts @@ -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 + }); +}); diff --git a/packages/dmn-editor/tests/e2e/drdArtifacts/changeTextAnnotationProperties.spec.ts b/packages/dmn-editor/tests/e2e/drdArtifacts/changeTextAnnotationProperties.spec.ts new file mode 100644 index 00000000000..ad2654c6656 --- /dev/null +++ b/packages/dmn-editor/tests/e2e/drdArtifacts/changeTextAnnotationProperties.spec.ts @@ -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 + }); +});