mirror of
https://github.com/ToolJet/ToolJet
synced 2026-05-05 06:18:34 +00:00
* init textinput revamp * updated styles panel * bugfix * updates * fix :: accordion * fix :: styling * add box shadow , additional property,tooltip * fix conditional render for styles * feat :: fixed order of each property and styles * feat :: styling input * bugfix * feat :: add option to add icon * add option to add icon * adding option to toggle visibility * updated password input with new design * chnaging component location * bugfix * style fixes * fix :: added loader * updated :: few detailing * few bugfixes * fix :: for form widget label * fixes * added option to add icon color * including label field for password input * fix for label * fix * test fix backward compatibility for height * updates * revert * adding key for distinguishing older and newer widgets * testing * test * test * update * update * migration testing * limit vertical resizing in textinput * testing * throw test * test * adding check for label length * fixing edge cases * removing resize * backward compatibility height * backward compatibility * number input review fixes * added exposed items * fixing csa * ui fixes * fix height compatibility * feat :: csa for all inputs and exposed variables * backward compatibility fixes and validation fixes * fixes :: textinput positioning of loader and icon * fix :: password input * cleanup and fixes * fixes * cleanup * fixes * review fixes * review fixes * typo fix * fix padding * review fixes styles component panel * fix naming * fix padding * fix :: icons position * updates * cleanup * updates events , csa * backward compatibility * clean * feat :: change validation from properties * ui fixes * icon name * removed 'px' text from tooltip * fixes placeholder * few updates :: removing label in form * ui in form * update :: number input validation behaviour * testing fixes * added side handlers * removing unwanted fx * disabling fx for padding field * ordering change * fix * label issue + restricted side handler * fix :: box shadow bug * on change event doesnt propagate exposed vars correctly * adding debounce for slider value change * fix :: for modal ooen bug during onfocus event * test slider * Add common utils * Modify helpers * Add text input spec * Add utils for field validation * Minor spec updates * Fix for password basic automation cases --------- Co-authored-by: stepinfwd <[email protected]>
452 lines
14 KiB
JavaScript
452 lines
14 KiB
JavaScript
import { fake } from "Fixtures/fake";
|
|
import { commonSelectors, commonWidgetSelector } from "Selectors/common";
|
|
import {
|
|
addDefaultEventHandler,
|
|
closeAccordions,
|
|
editAndVerifyWidgetName,
|
|
openAccordion,
|
|
openEditorSidebar,
|
|
randomNumber,
|
|
verifyAndModifyParameter,
|
|
verifyBoxShadowCss,
|
|
verifyComponentValueFromInspector,
|
|
verifyLayout,
|
|
verifyPropertiesGeneralAccordion,
|
|
verifyStylesGeneralAccordion,
|
|
verifyTooltip,
|
|
} from "Support/utils/commonWidget";
|
|
import {
|
|
addAllInputFieldColors,
|
|
addAndVerifyAdditionalActions,
|
|
addValidations,
|
|
verifyInputFieldColors,
|
|
} from "Support/utils/editor/inputFieldUtils";
|
|
import {
|
|
addSupportCSAData,
|
|
selectCSA,
|
|
selectEvent,
|
|
} from "Support/utils/events";
|
|
import {
|
|
randomString,
|
|
verifyControlComponentAction,
|
|
} from "Support/utils/textInput";
|
|
import { buttonText } from "Texts/button";
|
|
import { commonWidgetText, customValidation, widgetValue } from "Texts/common";
|
|
import { textInputText } from "Texts/textInput";
|
|
|
|
describe("Text Input", () => {
|
|
beforeEach(() => {
|
|
cy.apiLogin();
|
|
cy.apiCreateApp(`${fake.companyName}-Textinput-App`);
|
|
cy.openApp();
|
|
cy.dragAndDropWidget("Text Input", 500, 500);
|
|
});
|
|
afterEach(() => {
|
|
cy.apiDeleteApp();
|
|
});
|
|
|
|
it("should verify the properties of the text input widget", () => {
|
|
const data = {};
|
|
data.widgetName = fake.widgetName;
|
|
data.tooltipText = fake.randomSentence;
|
|
data.minimumLength = randomNumber(1, 4);
|
|
data.maximumLength = randomNumber(8, 10);
|
|
data.customText = randomString(12);
|
|
|
|
openEditorSidebar(textInputText.defaultWidgetName);
|
|
closeAccordions([
|
|
"Properties",
|
|
"Validation",
|
|
"Additional Actions",
|
|
"Devices",
|
|
"Events",
|
|
]);
|
|
editAndVerifyWidgetName(data.widgetName, [
|
|
"Properties",
|
|
"Validation",
|
|
"Additional Actions",
|
|
"Devices",
|
|
"Events",
|
|
]);
|
|
openAccordion(commonWidgetText.accordionProperties, [
|
|
"Properties",
|
|
"Validation",
|
|
"Additional Actions",
|
|
"Devices",
|
|
"Events",
|
|
]);
|
|
verifyAndModifyParameter(
|
|
commonWidgetText.labelDefaultValue,
|
|
data.customText
|
|
);
|
|
cy.forceClickOnCanvas();
|
|
cy.get(
|
|
commonWidgetSelector.draggableWidget(data.widgetName)
|
|
).verifyVisibleElement("have.value", data.customText);
|
|
|
|
verifyComponentValueFromInspector(data.widgetName, data.customText);
|
|
cy.forceClickOnCanvas();
|
|
cy.get(commonWidgetSelector.draggableWidget(data.widgetName)).clear();
|
|
|
|
data.customText = fake.randomSentence;
|
|
openEditorSidebar(data.widgetName);
|
|
openAccordion(commonWidgetText.accordionProperties, [
|
|
"Properties",
|
|
"Validation",
|
|
"Additional Actions",
|
|
"Devices",
|
|
"Events",
|
|
]);
|
|
verifyAndModifyParameter(
|
|
commonWidgetText.labelPlaceHolder,
|
|
data.customText
|
|
);
|
|
cy.forceClickOnCanvas();
|
|
cy.get(commonWidgetSelector.draggableWidget(data.widgetName))
|
|
.invoke("attr", "placeholder")
|
|
.should("contain", data.customText);
|
|
|
|
openEditorSidebar(data.widgetName);
|
|
openAccordion(commonWidgetText.accordionEvents, ["Validation", "Devices"]);
|
|
addDefaultEventHandler(widgetValue(data.widgetName));
|
|
cy.get(commonWidgetSelector.eventSelection).type("On Enter Pressed{Enter}");
|
|
|
|
cy.clearAndType(
|
|
commonWidgetSelector.draggableWidget(data.widgetName),
|
|
`${data.customText}{Enter}`
|
|
);
|
|
cy.verifyToastMessage(commonSelectors.toastMessage, data.customText);
|
|
cy.forceClickOnCanvas();
|
|
|
|
cy.get(commonWidgetSelector.draggableWidget(data.widgetName)).clear();
|
|
|
|
addValidations(data.widgetName, data);
|
|
|
|
cy.clearAndType(
|
|
commonWidgetSelector.draggableWidget(data.widgetName),
|
|
data.customText
|
|
);
|
|
cy.forceClickOnCanvas();
|
|
cy.get(
|
|
commonWidgetSelector.validationFeedbackMessage(data.widgetName)
|
|
).verifyVisibleElement("have.text", commonWidgetText.regexValidationError);
|
|
|
|
cy.get(commonWidgetSelector.draggableWidget(data.widgetName)).clear();
|
|
cy.get(
|
|
commonWidgetSelector.parameterInputField(commonWidgetText.labelRegex)
|
|
).clearCodeMirror();
|
|
|
|
cy.forceClickOnCanvas();
|
|
cy.get(
|
|
commonWidgetSelector.validationFeedbackMessage(data.widgetName)
|
|
).verifyVisibleElement(
|
|
"have.text",
|
|
commonWidgetText.minLengthValidationError(data.minimumLength)
|
|
);
|
|
|
|
cy.get(commonWidgetSelector.draggableWidget(data.widgetName)).clear();
|
|
cy.get(
|
|
commonWidgetSelector.parameterInputField(commonWidgetText.labelMinLength)
|
|
).clearCodeMirror();
|
|
|
|
cy.forceClickOnCanvas();
|
|
cy.clearAndType(
|
|
commonWidgetSelector.draggableWidget(data.widgetName),
|
|
data.customText
|
|
);
|
|
cy.get(
|
|
commonWidgetSelector.validationFeedbackMessage(data.widgetName)
|
|
).verifyVisibleElement(
|
|
"have.text",
|
|
commonWidgetText.maxLengthValidationError(data.maximumLength)
|
|
);
|
|
cy.forceClickOnCanvas();
|
|
cy.get(commonWidgetSelector.draggableWidget(data.widgetName)).clear();
|
|
cy.get(
|
|
commonWidgetSelector.validationFeedbackMessage(data.widgetName)
|
|
).verifyVisibleElement("have.text", data.customText);
|
|
|
|
cy.get(
|
|
commonWidgetSelector.accordion(commonWidgetText.accordionProperties)
|
|
).click();
|
|
cy.get(
|
|
commonWidgetSelector.accordion(commonWidgetText.accordionValidation)
|
|
).click();
|
|
addAndVerifyAdditionalActions(data.widgetName, data.tooltipText);
|
|
|
|
openEditorSidebar(data.widgetName);
|
|
cy.get(
|
|
commonWidgetSelector.accordion(commonWidgetText.accordionProperties)
|
|
).click();
|
|
cy.get(
|
|
commonWidgetSelector.accordion(commonWidgetText.accordionValidation)
|
|
).click();
|
|
verifyLayout(data.widgetName, "Devices");
|
|
|
|
cy.get(commonWidgetSelector.changeLayoutToDesktopButton).click();
|
|
cy.get(
|
|
commonWidgetSelector.parameterTogglebutton(
|
|
commonWidgetText.parameterShowOnDesktop
|
|
)
|
|
).click();
|
|
|
|
cy.get(commonWidgetSelector.widgetDocumentationLink).should(
|
|
"have.text",
|
|
textInputText.textInputDocumentationLink
|
|
);
|
|
data.customText = fake.firstName;
|
|
verifyControlComponentAction(data.widgetName, data.customText);
|
|
});
|
|
it.only("should verify the styles of the text input widget", () => {
|
|
const data = {};
|
|
data.appName = `${fake.companyName}-App`;
|
|
data.colourHex = fake.randomRgbaHex;
|
|
data.boxShadowColor = fake.randomRgba;
|
|
data.boxShadowParam = fake.boxShadowParam;
|
|
data.bgColor = fake.randomRgba;
|
|
data.borderColor = fake.randomRgba;
|
|
data.textColor = fake.randomRgba;
|
|
data.errorTextColor = fake.randomRgba;
|
|
data.iconColor = fake.randomRgba;
|
|
|
|
openEditorSidebar(textInputText.defaultWidgetName);
|
|
cy.get(commonWidgetSelector.buttonStylesEditorSideBar).click();
|
|
addAllInputFieldColors(data);
|
|
|
|
cy.clearAndType('[data-cy="border-radius-input"]', "20");
|
|
cy.get('[data-cy="icon-visibility-button"]').click();
|
|
|
|
cy.get(commonWidgetSelector.buttonCloseEditorSideBar).click();
|
|
cy.get(
|
|
commonWidgetSelector.draggableWidget(textInputText.defaultWidgetName)
|
|
).should("have.css", "border-radius", "20px");
|
|
|
|
verifyInputFieldColors("textinput1", data);
|
|
|
|
verifyStylesGeneralAccordion(
|
|
textInputText.defaultWidgetName,
|
|
data.boxShadowParam,
|
|
data.colourHex,
|
|
data.boxShadowColor,
|
|
4
|
|
);
|
|
});
|
|
|
|
it("should verify the app preview", () => {
|
|
const data = {};
|
|
data.appName = `${fake.companyName}-App`;
|
|
data.widgetName = fake.widgetName;
|
|
data.tooltipText = fake.randomSentence;
|
|
data.maxLengthErrText = fake.randomSentence;
|
|
data.colourHex = fake.randomRgbaHex;
|
|
data.boxShadowColor = fake.randomRgba;
|
|
data.boxShadowParam = fake.boxShadowParam;
|
|
data.minimumLength = randomNumber(1, 4);
|
|
data.maximumLength = randomNumber(8, 10);
|
|
data.customText = randomString(12);
|
|
data.maxLengthText = randomString(data.maximumLength);
|
|
|
|
openEditorSidebar(textInputText.defaultWidgetName);
|
|
verifyAndModifyParameter(
|
|
commonWidgetText.labelDefaultValue,
|
|
data.customText
|
|
);
|
|
|
|
verifyAndModifyParameter(
|
|
commonWidgetText.labelPlaceHolder,
|
|
data.customText
|
|
);
|
|
|
|
openAccordion(commonWidgetText.accordionEvents, ["Validation", "Devices"]);
|
|
addDefaultEventHandler(widgetValue(textInputText.defaultWidgetName));
|
|
cy.get(commonWidgetSelector.eventSelection).type("On Enter Pressed{Enter}");
|
|
|
|
openAccordion(commonWidgetText.accordionValidation);
|
|
verifyAndModifyParameter(
|
|
commonWidgetText.labelRegex,
|
|
commonWidgetText.regularExpression
|
|
);
|
|
verifyAndModifyParameter(
|
|
commonWidgetText.labelMinLength,
|
|
data.minimumLength
|
|
);
|
|
verifyAndModifyParameter(
|
|
commonWidgetText.labelMaxLength,
|
|
data.maximumLength
|
|
);
|
|
verifyAndModifyParameter(
|
|
commonWidgetText.labelcustomValidadtion,
|
|
customValidation(textInputText.defaultWidgetName, data.customText)
|
|
);
|
|
verifyPropertiesGeneralAccordion(
|
|
textInputText.defaultWidgetName,
|
|
data.tooltipText
|
|
);
|
|
|
|
verifyControlComponentAction(
|
|
textInputText.defaultWidgetName,
|
|
data.customText
|
|
);
|
|
|
|
openEditorSidebar(textInputText.defaultWidgetName);
|
|
cy.get(commonWidgetSelector.buttonStylesEditorSideBar).click();
|
|
|
|
verifyAndModifyParameter(
|
|
commonWidgetText.parameterBorderRadius,
|
|
commonWidgetText.borderRadiusInput
|
|
);
|
|
verifyStylesGeneralAccordion(
|
|
textInputText.defaultWidgetName,
|
|
data.boxShadowParam,
|
|
data.colourHex,
|
|
data.boxShadowColor,
|
|
4
|
|
);
|
|
|
|
cy.waitForAutoSave();
|
|
cy.openInCurrentTab(commonWidgetSelector.previewButton);
|
|
|
|
cy.get(
|
|
commonWidgetSelector.draggableWidget(textInputText.defaultWidgetName)
|
|
).verifyVisibleElement("have.value", data.customText);
|
|
cy.get(
|
|
commonWidgetSelector.draggableWidget(textInputText.defaultWidgetName)
|
|
)
|
|
.invoke("attr", "placeholder")
|
|
.should("contain", data.customText);
|
|
|
|
cy.get(
|
|
commonWidgetSelector.draggableWidget(textInputText.defaultWidgetName)
|
|
)
|
|
.type(`{selectAll}{backspace}{enter}`)
|
|
.type(data.customText);
|
|
cy.forceClickOnCanvas();
|
|
cy.get(
|
|
commonWidgetSelector.validationFeedbackMessage(
|
|
textInputText.defaultWidgetName
|
|
)
|
|
).verifyVisibleElement("have.text", commonWidgetText.regexValidationError);
|
|
cy.get(
|
|
commonWidgetSelector.draggableWidget(textInputText.defaultWidgetName)
|
|
).clear();
|
|
cy.get(
|
|
commonWidgetSelector.validationFeedbackMessage(
|
|
textInputText.defaultWidgetName
|
|
)
|
|
).verifyVisibleElement(
|
|
"have.text",
|
|
commonWidgetText.minLengthValidationError(data.minimumLength)
|
|
);
|
|
|
|
cy.clearAndType(
|
|
commonWidgetSelector.draggableWidget(textInputText.defaultWidgetName),
|
|
data.customText.toUpperCase()
|
|
);
|
|
cy.get(
|
|
commonWidgetSelector.validationFeedbackMessage(
|
|
textInputText.defaultWidgetName
|
|
)
|
|
).verifyVisibleElement(
|
|
"have.text",
|
|
commonWidgetText.maxLengthValidationError(data.maximumLength)
|
|
);
|
|
|
|
cy.clearAndType(
|
|
commonWidgetSelector.draggableWidget(textInputText.defaultWidgetName),
|
|
`${data.maxLengthText.toUpperCase()}{Enter}`
|
|
);
|
|
cy.verifyToastMessage(
|
|
commonSelectors.toastMessage,
|
|
data.maxLengthText.toUpperCase()
|
|
);
|
|
cy.get(
|
|
commonWidgetSelector.draggableWidget(buttonText.defaultWidgetName)
|
|
).should("have.text", data.maxLengthText.toUpperCase());
|
|
|
|
cy.get(
|
|
commonWidgetSelector.draggableWidget(textInputText.defaultWidgetName)
|
|
).should("have.css", "border-radius", "20px");
|
|
|
|
verifyBoxShadowCss(
|
|
textInputText.defaultWidgetName,
|
|
data.boxShadowColor,
|
|
data.boxShadowParam
|
|
);
|
|
|
|
verifyTooltip(
|
|
commonWidgetSelector.draggableWidget(textInputText.defaultWidgetName),
|
|
data.tooltipText
|
|
);
|
|
});
|
|
|
|
it("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("textinput1", "Visibility");
|
|
|
|
cy.get('[data-cy="real-canvas"]').click("topRight", { force: true });
|
|
cy.dragAndDropWidget("Text input", 50, 50);
|
|
selectEvent("On change", "Control Component");
|
|
selectCSA("textinput1", "Set text", "500");
|
|
addSupportCSAData("text", "{{components.textinput2.value");
|
|
|
|
cy.get('[data-cy="real-canvas"]').click("topRight", { force: true });
|
|
cy.dragAndDropWidget(buttonText.defaultWidgetText, 50, 200);
|
|
selectEvent("On click", "Control Component");
|
|
selectCSA("textinput1", "Clear", "500");
|
|
|
|
cy.get('[data-cy="real-canvas"]').click("topRight", { force: true });
|
|
cy.dragAndDropWidget(buttonText.defaultWidgetText, 50, 400);
|
|
selectEvent("On click", "Control Component");
|
|
selectCSA("textinput1", "Disable", "500");
|
|
cy.get('[data-cy="Value-toggle-button"]').click();
|
|
|
|
cy.get('[data-cy="real-canvas"]').click("topRight", { force: true });
|
|
cy.dragAndDropWidget(buttonText.defaultWidgetText, 300, 50);
|
|
selectEvent("On click", "Control Component");
|
|
selectCSA("textinput1", "Set blur", "500");
|
|
|
|
cy.get('[data-cy="real-canvas"]').click("topRight", { force: true });
|
|
cy.dragAndDropWidget(buttonText.defaultWidgetText, 300, 200);
|
|
selectEvent("On click", "Control Component");
|
|
selectCSA("textinput1", "Set focus");
|
|
|
|
cy.clearAndType(
|
|
commonWidgetSelector.draggableWidget("textinput2"),
|
|
data.customText
|
|
);
|
|
cy.get(
|
|
commonWidgetSelector.draggableWidget("textinput1")
|
|
).verifyVisibleElement("have.value", data.customText);
|
|
|
|
cy.get(commonWidgetSelector.draggableWidget("button2")).click();
|
|
cy.get(
|
|
commonWidgetSelector.draggableWidget("textinput1")
|
|
).verifyVisibleElement("have.value", "");
|
|
|
|
cy.get(commonWidgetSelector.draggableWidget("button5")).click();
|
|
cy.realType(data.customText);
|
|
cy.get(
|
|
commonWidgetSelector.draggableWidget("textinput1")
|
|
).verifyVisibleElement("have.value", data.customText);
|
|
cy.get(commonWidgetSelector.draggableWidget("button4")).click();
|
|
cy.realType("not working");
|
|
cy.get(
|
|
commonWidgetSelector.draggableWidget("textinput1")
|
|
).verifyVisibleElement("have.value", data.customText);
|
|
|
|
cy.get(commonWidgetSelector.draggableWidget("button3")).click();
|
|
cy.get(commonWidgetSelector.draggableWidget("textinput1"))
|
|
.parent()
|
|
.should("have.attr", "data-disabled", "true");
|
|
|
|
cy.get(commonWidgetSelector.draggableWidget("button1")).click();
|
|
cy.get(commonWidgetSelector.draggableWidget("textinput1")).should(
|
|
"not.be.visible"
|
|
);
|
|
});
|
|
});
|