-
Notifications
You must be signed in to change notification settings - Fork 4.6k
fix: isRequired validation property for table select column #36375
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
jacquesikot
merged 20 commits into
release
from
fix/validation-and-required-property-for-table-select-column
Sep 23, 2024
Merged
Changes from 16 commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
b0963bb
fix: add regex check on phone number change
SaiCharanChetpelly31 ed41946
feat: add comment for regex in phone input widget
SaiCharanChetpelly31 beea37b
Merge branch 'release' of https://github.com/SaiCharanChetpelly31/app…
SaiCharanChetpelly31 6c823bf
add validation in derived.js and SelectCell with isEditableCellValid
jacquesikot 440ec7f
Merge branch 'release' of https://github.com/appsmithorg/appsmith int…
jacquesikot 0ff1bac
allow validation in select column property + pass hasError prop in Se…
jacquesikot eceeb49
remove overriding css
886c248
add cypress test cases
jacquesikot 9ef6228
set only isRequired validation for table select column
jacquesikot 079c0ee
Merge branch 'release' of https://github.com/appsmithorg/appsmith int…
jacquesikot 3aed3c0
rename test file for clarity
jacquesikot 01cfe05
revert spacing change in index.styled
jacquesikot 9545e07
Merge branch 'release' of https://github.com/appsmithorg/appsmith int…
jacquesikot 6bb7b5a
fix selectors in Table_select_validation_spec
jacquesikot 02d8949
abstract hideColumnByType to function + improve Table_select_validati…
jacquesikot 64f8576
Merge branch 'release' of https://github.com/appsmithorg/appsmith int…
jacquesikot 110e6fd
remove .only from test
jacquesikot 8a38ded
remove reducndant check for border color in Table_select_validation_spec
jacquesikot 17f9fbc
add const for select error and valid style
jacquesikot d2597e6
replace cy.dragAndDropToCanvas with entityExplorer.DragNDropWidget
jacquesikot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
140 changes: 140 additions & 0 deletions
140
...ess/e2e/Regression/ClientSide/Widgets/TableV2/columnTypes/Table_select_validation_spec.ts
This file contains hidden or 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,140 @@ | ||
| import commonlocators from "../../../../../../locators/commonlocators.json"; | ||
| import { | ||
| agHelper, | ||
| locators, | ||
| propPane, | ||
| table, | ||
| } from "../../../../../../support/Objects/ObjectsCore"; | ||
| import EditorNavigation, { | ||
| EntityType, | ||
| } from "../../../../../../support/Pages/EditorNavigation"; | ||
|
|
||
| const hexToRgb = (hex: string) => { | ||
| const shorthandRegex = /^#?([a-f\d])([a-f\d])([a-f\d])$/i; | ||
| hex = hex.replace(shorthandRegex, (m, r, g, b) => r + r + g + g + b + b); | ||
|
|
||
| const result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex); | ||
| return result | ||
| ? `rgb(${parseInt(result[1], 16)}, ${parseInt(result[2], 16)}, ${parseInt(result[3], 16)})` | ||
| : null; | ||
| }; | ||
|
|
||
| const validateSelectBorderColor = (color: string) => { | ||
| agHelper | ||
| .GetElement(commonlocators.singleSelectWidgetButtonControl) | ||
| .then(($el) => { | ||
| const borderDangerColor = getComputedStyle($el[0]).getPropertyValue( | ||
| color, | ||
| ); | ||
| const borderDangerColorRgb = hexToRgb(borderDangerColor); | ||
| cy.wrap($el).should("have.css", "border-color", borderDangerColorRgb); | ||
| }); | ||
| }; | ||
|
|
||
| describe( | ||
| "Table widget - Select column validation", | ||
| { tags: ["@tag.Widget", "@tag.Table", "@tag.Select"] }, | ||
| () => { | ||
| before(() => { | ||
| cy.dragAndDropToCanvas("tablewidgetv2", { x: 350, y: 500 }); | ||
| table.AddSampleTableData(); | ||
| }); | ||
| it.only("1. should prevent adding a row when a required select column has no data", () => { | ||
|
jacquesikot marked this conversation as resolved.
Outdated
|
||
| 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 | ||
| validateSelectBorderColor("--wds-color-border-danger"); | ||
|
|
||
| // 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 | ||
| validateSelectBorderColor("var(--wds-color-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 | ||
| validateSelectBorderColor("--wds-color-border-danger"); | ||
| }); | ||
| }, | ||
| ); | ||
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.