ToolJet/cypress-tests/cypress/e2e/happyPath/appbuilder/commonTestcases/components/textHappyPath.cy.js

142 lines
4.4 KiB
JavaScript
Raw Normal View History

import { fake } from "Fixtures/fake";
import {
2024-02-08 08:10:08 +00:00
verifyNodeData,
openNode,
verifyValue,
deleteComponentFromInspector,
verifyfunctions,
} from "Support/utils/inspector";
import { commonWidgetSelector } from "Selectors/common";
import {
editAndVerifyWidgetName,
2024-02-08 08:10:08 +00:00
selectFromSidebarDropdown,
addValueOnInput,
selectColourFromColourPicker,
verifyStylesGeneralAccordion,
} from "Support/utils/commonWidget";
import {
2024-02-08 08:10:08 +00:00
addSupportCSAData,
selectCSA,
selectEvent,
} from "Support/utils/events";
import { randomString } from "Support/utils/editor/textInput";
2024-02-08 08:10:08 +00:00
import { buttonText } from "Texts/button";
describe("Text Input", () => {
2024-02-08 08:10:08 +00:00
const data = {};
beforeEach(() => {
2024-02-08 08:10:08 +00:00
cy.viewport(1200, 1200);
data.appName = `${fake.companyName}-text-App`;
cy.apiLogin();
2024-02-08 08:10:08 +00:00
cy.apiCreateApp(data.appName);
cy.openApp();
cy.dragAndDropWidget("Text");
});
afterEach(() => {
cy.apiDeleteApp();
});
2024-02-08 08:10:08 +00:00
it("should verify properties of text component", () => {
data.componentName = fake.widgetName;
cy.get(commonWidgetSelector.draggableWidget("text1")).should("be.visible");
editAndVerifyWidgetName(data.componentName, [
"Data",
"Events",
"Additional Actions",
"Devices",
]);
cy.get(
'[data-cy="textcomponenttextinput-input-field"]'
).clearAndTypeOnCodeMirror("Cypress testing text component");
cy.forceClickOnCanvas();
cy.get(
commonWidgetSelector.draggableWidget(data.componentName)
).verifyVisibleElement("have.text", "Cypress testing text component");
});
it("should verify styles of text component", () => {
2024-02-08 08:10:08 +00:00
cy.get(commonWidgetSelector.buttonStylesEditorSideBar).click();
selectFromSidebarDropdown("Weight", "bolder");
selectFromSidebarDropdown("Font variant", "initial");
addValueOnInput("Size", 25);
addValueOnInput("Line Height", 3);
addValueOnInput("Text Indent", 2);
addValueOnInput("Letter Spacing", 2);
addValueOnInput("Word Spacing", 2);
addValueOnInput("Border radius", 2);
data.textColor = fake.randomRgba;
data.backgroundColor = fake.randomRgba;
data.borderColor = fake.randomRgba;
data.boxShadowColor = fake.randomRgba;
data.boxShadowParam = fake.boxShadowParam;
selectColourFromColourPicker("color", data.textColor);
selectColourFromColourPicker("background", data.backgroundColor);
selectColourFromColourPicker("border", data.borderColor);
data.colourHex = fake.randomRgbaHex;
verifyStylesGeneralAccordion(
"text1",
data.boxShadowParam,
data.colourHex,
data.boxShadowColor,
4,
"#00000090"
);
});
it("should verify preview of text component", () => {});
it.only("should verify CSA", () => {
const data = {};
data.customText = randomString(12);
cy.get('[data-cy="real-canvas"]').click("topRight", { force: true });
cy.dragAndDropWidget(buttonText.defaultWidgetText, 500, 200);
selectEvent("On click", "Control Component");
selectCSA("text1", "Visibility");
cy.get('[data-cy="real-canvas"]').click("topRight", { force: true });
cy.dragAndDropWidget("Text input", 500, 50);
selectEvent("On change", "Control Component");
selectCSA("text1", "Set text", "500");
addSupportCSAData("Text", "{{components.textinput1.value");
cy.get('[data-cy="real-canvas"]').click("topLeft", { force: true });
cy.clearAndType(
commonWidgetSelector.draggableWidget("textinput1"),
data.customText
);
cy.get(commonWidgetSelector.draggableWidget("text1")).verifyVisibleElement(
"have.text",
data.customText
);
cy.get(commonWidgetSelector.draggableWidget("button1")).click();
cy.get(commonWidgetSelector.draggableWidget("textinput1")).should(
"not.be.visible"
);
});
it.only("should verify expossed values", () => {
2024-02-08 08:10:08 +00:00
cy.get(commonWidgetSelector.sidebarinspector).click();
verifyNodeData("components", "Object", "1 entry ");
openNode("components");
openNode("text1");
verifyValue("text", "String", `"Hello The👋"`);
2024-02-08 08:10:08 +00:00
verifyValue("isVisible", "Boolean", "true");
verifyValue("isLoading", "Boolean", "false");
verifyValue("isDisabled", "Boolean", "false");
verifyfunctions("clear", "Function");
verifyfunctions("setText", "Function");
verifyfunctions("visibility", "Function");
verifyfunctions("setDisable", "Function");
2024-02-08 08:10:08 +00:00
verifyfunctions("setVisibility", "Function");
verifyfunctions("setLoading", "Function");
2024-02-08 08:10:08 +00:00
});
});