forked from appsmithorg/appsmith
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: isRequired validation property for table select column (appsmith…
…org#36375) ## Description **Problem** The select column of the table widget does not have a validation property within its property pane to allow users add an isRequired validation to the table select column. **Solution** Added a Validation section to the table select column's property pane, which includes an isRequired toggle. When enabled, this feature will trigger a visual indication (error border colour) around the select widget if a required field is left unselected during "Add new row" or inline editing. Fixes appsmithorg#30091 ## Automation /ok-to-test tags="@tag.Widget, @tag.Table, @tag.Binding, @tag.Sanity, @tag.Select" ### 🔍 Cypress test results <!-- This is an auto-generated comment: Cypress test results --> > [!TIP] > 🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉 > Workflow run: <https://github.com/appsmithorg/appsmith/actions/runs/10957896180> > Commit: d2597e6 > <a href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=10957896180&attempt=1" target="_blank">Cypress dashboard</a>. > Tags: `@tag.Widget, @tag.Table, @tag.Binding, @tag.Sanity, @tag.Select` > Spec: > <hr>Fri, 20 Sep 2024 12:23:29 UTC <!-- end of auto-generated comment: Cypress test results --> ## Communication Should the DevRel and Marketing teams inform users about this change? - [ ] Yes - [x] No <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Introduced end-to-end tests for Select column validation in Table widgets. - Enhanced validation logic to support Select column types in the Table widget. - Added visual feedback for required Select fields during row addition and inline editing. - Improved locator for single-select widget button control to enhance UI interaction. - **Bug Fixes** - Improved error handling and visual representation for invalid editable Select cells. - **Documentation** - Updated validation configuration to include Select column types for better usability. - **Refactor** - Enhanced code clarity for styled components related to Select fields. - Modified method to improve versatility in handling table interactions. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Sai Charan <[email protected]> Co-authored-by: Pawan Kumar <[email protected]>
- Loading branch information
Showing
8 changed files
with
163 additions
and
24 deletions.
There are no files selected for viewing
128 changes: 128 additions & 0 deletions
128
...ess/e2e/Regression/ClientSide/Widgets/TableV2/columnTypes/Table_select_validation_spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
import commonlocators from "../../../../../../locators/commonlocators.json"; | ||
import { | ||
agHelper, | ||
entityExplorer, | ||
locators, | ||
propPane, | ||
table, | ||
} from "../../../../../../support/Objects/ObjectsCore"; | ||
import EditorNavigation, { | ||
EntityType, | ||
} from "../../../../../../support/Pages/EditorNavigation"; | ||
|
||
const TABLE_SELECT_WIDGET_ERROR_BORDER = "rgb(217, 25, 33)"; | ||
const TABLE_SELECT_WIDGET_VALID_BORDER = "rgb(85, 61, 233)"; | ||
|
||
describe( | ||
"Table widget - Select column validation", | ||
{ tags: ["@tag.Widget", "@tag.Table", "@tag.Select"] }, | ||
() => { | ||
before(() => { | ||
entityExplorer.DragNDropWidget("tablewidgetv2", 350, 500); | ||
table.AddSampleTableData(); | ||
}); | ||
it("1. should prevent adding a row when a required select column has no data", () => { | ||
EditorNavigation.SelectEntityByName("Table1", EntityType.Widget); | ||
|
||
// Allow adding a row in table | ||
propPane.TogglePropertyState("Allow adding a row", "On"); | ||
|
||
// Edit step column to select type | ||
table.ChangeColumnType("step", "Select", "v2"); | ||
table.EditColumn("step", "v2"); | ||
|
||
// Add data to select options | ||
agHelper.UpdateCodeInput( | ||
locators._controlOption, | ||
` | ||
[ | ||
{ | ||
"label": "#1", | ||
"value": "#1" | ||
}, | ||
{ | ||
"label": "#2", | ||
"value": "#2" | ||
}, | ||
{ | ||
"label": "#3", | ||
"value": "#3" | ||
} | ||
] | ||
`, | ||
); | ||
|
||
// Set step column to editable | ||
propPane.TogglePropertyState("Editable", "On"); | ||
|
||
// Set step column to required | ||
propPane.TogglePropertyState("Required", "On"); | ||
|
||
// Click add a new row | ||
table.AddNewRow(); | ||
|
||
// Expect the save row button to be disabled | ||
agHelper.GetElement(table._saveNewRow).should("be.disabled"); | ||
|
||
// Expect select to have an error color | ||
agHelper | ||
.GetElement(commonlocators.singleSelectWidgetButtonControl) | ||
.should("have.css", "border-color", TABLE_SELECT_WIDGET_ERROR_BORDER); | ||
|
||
// Select a valid option from the select table cell | ||
agHelper.GetNClick(commonlocators.singleSelectWidgetButtonControl); | ||
agHelper | ||
.GetElement(commonlocators.singleSelectWidgetMenuItem) | ||
.contains("#1") | ||
.click(); | ||
|
||
// Expect the save row option to be enabled | ||
agHelper.GetElement(table._saveNewRow).should("be.enabled"); | ||
|
||
// Expect button to have a valid color | ||
agHelper | ||
.GetElement(commonlocators.singleSelectWidgetButtonControl) | ||
.should("have.css", "border-color", TABLE_SELECT_WIDGET_VALID_BORDER); | ||
|
||
// Discard save new row | ||
agHelper.GetElement(table._discardRow).click({ force: true }); | ||
}); | ||
|
||
it("2. should display an error when inline editing a required select cell in a table with no data", () => { | ||
// Update table data to create emtpy cell in step column | ||
propPane.NavigateBackToPropertyPane(); | ||
propPane.UpdatePropertyFieldValue( | ||
"Table data", | ||
` | ||
[ | ||
{ | ||
"task": "Drop a table", | ||
"status": "✅", | ||
"action": "" | ||
}, | ||
{ | ||
"step": "#2", | ||
"task": "Create a query fetch_users with the Mock DB", | ||
"status": "--", | ||
"action": "" | ||
}, | ||
{ | ||
"step": "#3", | ||
"task": "Bind the query using => fetch_users.data", | ||
"status": "--", | ||
"action": "" | ||
} | ||
] | ||
`, | ||
); | ||
|
||
// Click the first cell in the step column | ||
table.ClickOnEditIcon(0, 0, true); | ||
|
||
// Exect the select to have an error color | ||
agHelper | ||
.GetElement(commonlocators.singleSelectWidgetButtonControl) | ||
.should("have.css", "border-color", TABLE_SELECT_WIDGET_ERROR_BORDER); | ||
}); | ||
}, | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters