Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/client/cypress.env.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
"MySQL":1,
"Mongo":1,
"Edition": 0
}
}
12 changes: 8 additions & 4 deletions app/client/cypress/fixtures/Table/InlineEditingDSL.json
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,8 @@
"isDerived":false,
"label":"step",
"computedValue":"{{Table1.processedTableData.map((currentRow, currentIndex) => ( currentRow[\"step\"]))}}",
"labelColor":"#FFFFFF"
"labelColor":"#FFFFFF",
"validation": {}
},
"task":{
"index":1,
Expand All @@ -147,7 +148,8 @@
"isDerived":false,
"label":"task",
"computedValue":"{{Table1.processedTableData.map((currentRow, currentIndex) => ( currentRow[\"task\"]))}}",
"labelColor":"#FFFFFF"
"labelColor":"#FFFFFF",
"validation": {}
},
"status":{
"index":2,
Expand All @@ -167,7 +169,8 @@
"isDerived":false,
"label":"status",
"computedValue":"{{Table1.processedTableData.map((currentRow, currentIndex) => ( currentRow[\"status\"]))}}",
"labelColor":"#FFFFFF"
"labelColor":"#FFFFFF",
"validation": {}
},
"action":{
"index":3,
Expand All @@ -192,7 +195,8 @@
"labelColor":"#FFFFFF",
"buttonColor":"{{Table1.processedTableData.map((currentRow, currentIndex) => ( appsmith.theme.colors.primaryColor))}}",
"borderRadius":"{{Table1.processedTableData.map((currentRow, currentIndex) => ( appsmith.theme.borderRadius.appBorderRadius))}}",
"boxShadow":"{{Table1.processedTableData.map((currentRow, currentIndex) => ( 'none'))}}"
"boxShadow":"{{Table1.processedTableData.map((currentRow, currentIndex) => ( 'none'))}}",
"validation": {}
}
},
"tableData":[
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,320 @@
const dsl = require("../../../../../fixtures/Table/InlineEditingDSL.json");
const commonlocators = require("../../../../../locators/commonlocators.json");
const widgetsPage = require("../../../../../locators/Widgets.json");
import { ObjectsRegistry } from "../../../../../support/Objects/Registry";

const propPane = ObjectsRegistry.PropertyPane;

describe("Table widget inline editing validation functionality", () => {
beforeEach(() => {
cy.addDsl(dsl);
});

it("1. should check that validation only appears when editable enabled", () => {
cy.openPropertyPane("tablewidgetv2");
cy.editColumn("step");
cy.get(".t--property-pane-section-collapse-validation").should("not.exist");
propPane.ToggleOnOrOff("Editable", "On");
cy.get(".t--property-pane-section-collapse-validation").should("exist");
propPane.ToggleOnOrOff("Editable", "Off");
cy.get(".t--property-pane-section-collapse-validation").should("not.exist");
});

it("2. should check that validation only appears for plain text and number", () => {
cy.openPropertyPane("tablewidgetv2");
cy.editColumn("step");
propPane.ToggleOnOrOff("Editable", "On");
cy.get(".t--property-pane-section-collapse-validation").should("exist");
cy.get(commonlocators.changeColType)
.last()
.click();
cy.get(".t--dropdown-option")
.children()
.contains("Number")
.click();
cy.wait("@updateLayout");
cy.get(".t--property-pane-section-collapse-validation").should("exist");
cy.get(commonlocators.changeColType)
.last()
.click();
cy.get(".t--dropdown-option")
.children()
.contains("Plain Text")
.click();
cy.wait("@updateLayout");
cy.get(".t--property-pane-section-collapse-validation").should("exist");
cy.get(commonlocators.changeColType)
.last()
.click();
cy.get(".t--dropdown-option")
.children()
.contains("Date")
.click();
cy.wait("@updateLayout");
cy.get(".t--property-pane-section-collapse-validation").should("not.exist");
cy.get(commonlocators.changeColType)
.last()
.click();
cy.get(".t--dropdown-option")
.children()
.contains("Plain Text")
.click();
cy.wait("@updateLayout");
cy.get(".t--property-pane-section-collapse-validation").should("exist");
});

it("3. should check that regex, valid & required appear for plain text column", () => {
cy.openPropertyPane("tablewidgetv2");
cy.editColumn("step");
propPane.ToggleOnOrOff("Editable", "On");
cy.get(".t--property-pane-section-collapse-validation").should("exist");
["regex", "valid", "errormessage", "required"].forEach((property) => {
cy.get(`.t--property-control-${property}`).should("exist");
});
});

it("4. should check that min, max, regex, valid & required appear for number column", () => {
cy.openPropertyPane("tablewidgetv2");
cy.editColumn("step");
propPane.ToggleOnOrOff("Editable", "On");
cy.get(commonlocators.changeColType)
.last()
.click();
cy.get(".t--dropdown-option")
.children()
.contains("Number")
.click();
cy.wait("@updateLayout");
cy.get(".t--property-pane-section-collapse-validation").should("exist");
["min", "max", "regex", "valid", "errormessage", "required"].forEach(
(property) => {
cy.get(`.t--property-control-${property}`).should("exist");
},
);
});

describe("5. should check validation property for plain text column", () => {
it("a. Regex", () => {
cy.openPropertyPane("tablewidgetv2");
cy.editColumn("step");
propPane.ToggleOnOrOff("Editable", "On");
propPane.UpdatePropertyFieldValue("Regex", "^#1$");
cy.editTableCell(0, 0);
cy.wait(500);
cy.get(`.t--inlined-cell-editor-has-error`).should("not.exist");
cy.enterTableCellValue(0, 0, "22");
cy.wait(500);
cy.get(`.t--inlined-cell-editor-has-error`).should("exist");
cy.enterTableCellValue(0, 0, "#1");
cy.wait(500);
cy.get(`.t--inlined-cell-editor-has-error`).should("not.exist");
});

it("b. Valid", () => {
cy.openPropertyPane("tablewidgetv2");
cy.editColumn("step");
propPane.ToggleOnOrOff("Editable", "On");
propPane.UpdatePropertyFieldValue("Valid", "{{editedValue === '#1'}}");
cy.editTableCell(0, 0);
cy.wait(500);
cy.get(`.t--inlined-cell-editor-has-error`).should("not.exist");
cy.enterTableCellValue(0, 0, "22");
cy.wait(500);
cy.get(`.t--inlined-cell-editor-has-error`).should("exist");
cy.enterTableCellValue(0, 0, "#1");
cy.wait(500);
cy.get(`.t--inlined-cell-editor-has-error`).should("not.exist");
});

it("c. Required", () => {
cy.openPropertyPane("tablewidgetv2");
cy.editColumn("step");
propPane.ToggleOnOrOff("Editable", "On");
propPane.ToggleOnOrOff("Required", "On");
cy.editTableCell(0, 0);
cy.wait(500);
cy.get(`.t--inlined-cell-editor-has-error`).should("exist");
cy.enterTableCellValue(0, 0, "22");
cy.wait(500);
cy.get(`.t--inlined-cell-editor-has-error`).should("not.exist");
cy.enterTableCellValue(0, 0, "#1");
cy.wait(500);
cy.get(`.t--inlined-cell-editor-has-error`).should("not.exist");
cy.enterTableCellValue(0, 0, "");
cy.wait(500);
cy.get(`.t--inlined-cell-editor-has-error`).should("exist");
});
});

describe("6. should check validation property for number column", () => {
it("a. Min", () => {
cy.openPropertyPane("tablewidgetv2");
cy.editColumn("step");
propPane.ToggleOnOrOff("Editable", "On");

cy.get(commonlocators.changeColType)
.last()
.click();
cy.get(".t--dropdown-option")
.children()
.contains("Number")
.click();
cy.wait("@updateLayout");

propPane.UpdatePropertyFieldValue("Min", "5");

cy.editTableCell(0, 0);
cy.wait(500);
cy.get(`.t--inlined-cell-editor-has-error`).should("not.exist");
cy.enterTableCellValue(0, 0, "6");
cy.wait(500);
cy.get(`.t--inlined-cell-editor-has-error`).should("not.exist");
cy.enterTableCellValue(0, 0, "7");
cy.wait(500);
cy.get(`.t--inlined-cell-editor-has-error`).should("not.exist");
cy.enterTableCellValue(0, 0, "4");
cy.wait(500);
cy.get(`.t--inlined-cell-editor-has-error`).should("exist");
cy.enterTableCellValue(0, 0, "3");
cy.wait(500);
cy.get(`.t--inlined-cell-editor-has-error`).should("exist");
cy.enterTableCellValue(0, 0, "8");
cy.wait(500);
cy.get(`.t--inlined-cell-editor-has-error`).should("not.exist");
});

it("b. Max", () => {
cy.openPropertyPane("tablewidgetv2");
cy.editColumn("step");
propPane.ToggleOnOrOff("Editable", "On");

cy.get(commonlocators.changeColType)
.last()
.click();
cy.get(".t--dropdown-option")
.children()
.contains("Number")
.click();
cy.wait("@updateLayout");

propPane.UpdatePropertyFieldValue("Max", "5");

cy.editTableCell(0, 0);
cy.wait(500);
cy.get(`.t--inlined-cell-editor-has-error`).should("not.exist");
cy.enterTableCellValue(0, 0, "6");
cy.wait(500);
cy.get(`.t--inlined-cell-editor-has-error`).should("exist");
cy.enterTableCellValue(0, 0, "7");
cy.wait(500);
cy.get(`.t--inlined-cell-editor-has-error`).should("exist");
cy.enterTableCellValue(0, 0, "4");
cy.wait(500);
cy.get(`.t--inlined-cell-editor-has-error`).should("not.exist");
cy.enterTableCellValue(0, 0, "3");
cy.wait(500);
cy.get(`.t--inlined-cell-editor-has-error`).should("not.exist");
cy.enterTableCellValue(0, 0, "8");
cy.wait(500);
cy.get(`.t--inlined-cell-editor-has-error`).should("exist");
});
});

it("7. should check the error message property", () => {
cy.openPropertyPane("tablewidgetv2");
cy.editColumn("step");
propPane.ToggleOnOrOff("Editable", "On");
propPane.UpdatePropertyFieldValue("Valid", "{{editedValue === '#1'}}");
propPane.UpdatePropertyFieldValue("Error Message", "You got error mate!!");
cy.editTableCell(0, 0);
cy.wait(1000);
cy.enterTableCellValue(0, 0, "123");
cy.wait(500);
cy.get(".bp3-overlay.error-tooltip .bp3-popover-content").should(
"contain",
"You got error mate!!",
);
});

describe("8. should check the editable cell actions when there is a validation error", () => {
it("a. save should only work when there is no error", () => {
cy.openPropertyPane("tablewidgetv2");
cy.editColumn("step");
propPane.ToggleOnOrOff("Editable", "On");
cy.get(
".t--property-control-onsubmit .t--open-dropdown-Select-Action",
).click();
cy.selectShowMsg();
cy.addSuccessMessage("Saved!!", ".t--property-control-onsubmit");
propPane.UpdatePropertyFieldValue("Valid", "{{editedValue === '#1'}}");
cy.editTableCell(0, 0);
cy.enterTableCellValue(0, 0, "123");
cy.get(`.t--inlined-cell-editor`).should("exist");
cy.get(`.t--inlined-cell-editor-has-error`).should("exist");
cy.saveTableCellValue(0, 0);
cy.wait(500);
cy.get(`.t--inlined-cell-editor`).should("exist");
cy.get(`.t--inlined-cell-editor-has-error`).should("exist");
cy.get(widgetsPage.toastAction).should("not.exist");
cy.enterTableCellValue(0, 0, "#1");
cy.saveTableCellValue(0, 0);
cy.get(`.t--inlined-cell-editor`).should("not.exist");
cy.get(`.t--inlined-cell-editor-has-error`).should("not.exist");
cy.get(widgetsPage.toastAction).should("be.visible");
cy.get(widgetsPage.toastActionText)
.last()
.invoke("text")
.then((text) => {
expect(text).to.equal("Saved!!");
});
});

it("b. discard should only work when there is no error", () => {
cy.openPropertyPane("tablewidgetv2");
cy.editColumn("step");
propPane.ToggleOnOrOff("Editable", "On");
propPane.UpdatePropertyFieldValue("Valid", "{{editedValue === '#1'}}");
cy.editTableCell(0, 0);
cy.enterTableCellValue(0, 0, "123");
cy.get(`.t--inlined-cell-editor`).should("exist");
cy.get(`.t--inlined-cell-editor-has-error`).should("exist");
cy.discardTableCellValue(0, 0);
cy.wait(500);
cy.get(`.t--inlined-cell-editor`).should("not.exist");
cy.get(`.t--inlined-cell-editor-has-error`).should("not.exist");
cy.readTableV2data(0, 0).then((val) => {
expect(val).to.equal("");
});

cy.editTableCell(0, 0);
cy.enterTableCellValue(0, 0, "#1");
cy.get(`.t--inlined-cell-editor`).should("exist");
cy.get(`.t--inlined-cell-editor-has-error`).should("not.exist");
cy.discardTableCellValue(0, 0);
cy.wait(500);
cy.get(`.t--inlined-cell-editor`).should("not.exist");
cy.get(`.t--inlined-cell-editor-has-error`).should("not.exist");
cy.readTableV2data(0, 0).then((val) => {
expect(val).to.equal("");
});
});
});

it("should check that save/discard button is disabled when there is a validation error", () => {
cy.openPropertyPane("tablewidgetv2");
cy.editColumn("step");
propPane.ToggleOnOrOff("Editable", "On");
propPane.UpdatePropertyFieldValue("Valid", "{{editedValue === '#1'}}");
cy.editTableCell(0, 0);
cy.enterTableCellValue(0, 0, "123");
cy.openPropertyPane("tablewidgetv2");
cy.get(`[data-colindex="${4}"][data-rowindex="${0}"] button`).should(
"be.disabled",
);
cy.enterTableCellValue(0, 0, "#1");
cy.openPropertyPane("tablewidgetv2");
cy.get(`[data-colindex="${4}"][data-rowindex="${0}"] button`).should(
"not.be.disabled",
);
});
});
12 changes: 9 additions & 3 deletions app/client/cypress/support/widgetCommands.js
Original file line number Diff line number Diff line change
Expand Up @@ -1471,9 +1471,15 @@ Cypress.Commands.add("makeColumnEditable", (column) => {
Cypress.Commands.add("enterTableCellValue", (x, y, text) => {
cy.get(
`[data-colindex="${x}"][data-rowindex="${y}"] .t--inlined-cell-editor input.bp3-input`,
)
.clear()
.type(text);
).clear();

if (text) {
cy.get(
`[data-colindex="${x}"][data-rowindex="${y}"] .t--inlined-cell-editor input.bp3-input`,
)
.focus()
.type(text);
}
});

Cypress.Commands.add("discardTableCellValue", (x, y) => {
Expand Down
Loading