PromucFlow_constructor/app/client/cypress/e2e/Regression/ClientSide/Widgets
Jacques Ikot 9f387d5763
fix: Correct Select Widget Mapping for Dynamic Label and Value Keys (#35862)
## Description
**Problem**
When the Select widget's labelKey or valueKey properties are switched to
JS mode, passing a function that returns a string as the key causes the
dropdown options to break. Instead of correctly mapping the labels and
values, the options are incorrectly returned as an array of the key
itself.

**Root Cause**
The issue lies in the `getOptions` function in derived.js. The logic
that computes the select options based on the labelKey and valueKey was
not handling cases where these properties are functions that return
arrays. Instead of mapping through the source data and returning the
corresponding values for each key, the function was mistakenly returning
the entire array.

**Solution**
The `getOptions` function in derived.js has been updated to correctly
handle cases where labelKey or valueKey are arrays. The function now
maps through the sourceData and computes the correct labels and values
based on the provided properties, ensuring that the dropdown options are
displayed as expected.



Fixes #35269

## Automation

/ok-to-test tags="@tag.Sanity, @tag.Select, @tag.Widget, @tag.Binding"

### 🔍 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/10560970428>
> Commit: 118badee07c47fe72f727f8ab248c29685f6f7a1
> <a
href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=10560970428&attempt=1"
target="_blank">Cypress dashboard</a>.
> Tags: `@tag.Sanity, @tag.Select, @tag.Widget, @tag.Binding`
> Spec:
> <hr>Mon, 26 Aug 2024 15:24:26 UTC
<!-- end of auto-generated comment: Cypress test results  -->


## Communication
Should the DevRel and Marketing teams inform users about this change?
- [ ] Yes
- [ ] No


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit


- **New Features**
- Enhanced test coverage for the Select widget by adding new test cases
to validate the correct functioning of JavaScript functions in the label
and value keys.
- Improved processing of `optionLabel` and `optionValue` properties for
the Select widget, ensuring accurate mapping to `sourceData`.
- Introduced a new helper function to streamline the validation of label
and value keys in the Select widget tests.

- **Bug Fixes**
- Corrected the handling of multiple options in the Select widget to
enhance data mapping accuracy and functionality.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2024-08-27 07:54:44 +01:00
..
Audio feat: enabled editor pane sidebar (#29882) 2024-01-12 20:13:58 +05:30
Button test:replace assertPageSave with AssertAutoSave (#33972) 2024-06-06 13:11:03 +05:30
Camera test: Update case base duplicate file name (#35672) 2024-08-20 10:48:52 +05:30
Chart chore: Removing widgets related feature flags for the features that are GA (#33229) 2024-05-07 15:26:48 +05:30
Checkbox chore: Reorganise IDE Panels (#35114) 2024-07-31 21:23:35 +05:30
CodeScanner test: replace togglebarDisable with CheckUncheck (#34069) 2024-06-10 19:55:17 +05:30
CurrencyInput test: removed toggleBar command and replaced with ts helper (#33835) 2024-06-06 15:25:08 +05:30
Custom fix: Disable custom widgets for airgapped environments (#34540) 2024-06-27 13:47:32 +05:30
Datepicker chore: fix flaky datepicker spec. (#35726) 2024-08-19 09:16:48 +05:30
Divider test: Updated duplicate file names (#34972) 2024-07-31 10:27:33 +05:30
DocumentViewer test: Cypress - added @tag.Checkbox, @tag.Scanner, @tag.Datepicker, @tag.DocumentViewer, @tag.CurrencyInput, @tag.Dropdown (#29687) 2023-12-18 16:59:48 +05:30
Dropdown test: replace togglebarDisable with CheckUncheck (#34069) 2024-06-10 19:55:17 +05:30
Filepicker fix: file picker widgets removing files causing abnormal content (#31646) 2024-03-11 18:13:12 +05:30
Form test: replace togglebarDisable with CheckUncheck (#34069) 2024-06-10 19:55:17 +05:30
Iframe feat: New IDE Top Navbar (#31594) 2024-03-12 14:02:58 +05:30
Image test: replace togglebarDisable with CheckUncheck (#34069) 2024-06-10 19:55:17 +05:30
Input test: Updated file name for remove duplicate (#34821) 2024-07-12 10:07:17 +05:30
JSONForm test: replace togglebarDisable with CheckUncheck (#34069) 2024-06-10 19:55:17 +05:30
List feat: enabled editor pane sidebar (#29882) 2024-01-12 20:13:58 +05:30
ListV2 fix: drag and drop issue in list widget (#35622) 2024-08-12 17:24:19 +05:30
Modal feat: added modal name, lint warning for string, action selector modal (#32893) 2024-05-02 17:48:53 +05:30
Multiselect test: Updated file name for remove duplicate (#34821) 2024-07-12 10:07:17 +05:30
Others test: Update case base duplicate file name (#35672) 2024-08-20 10:48:52 +05:30
PhoneInput feat: enabled editor pane sidebar (#29882) 2024-01-12 20:13:58 +05:30
Radio test: Cypress - remove width tests (#30577) 2024-01-24 13:05:49 +05:30
Rating test: Cypress - added tags - @tag.Radio, @tag.Rating, @tag.TextEditor, @tag.PhoneInput, @tag.IconButton, @tag.Maps, @tag.MenuButton, @tag.Progress, @tag.Statbox (#29693) 2023-12-18 17:25:28 +05:30
RTE chore: Upgrade TinyMCE (#35399) 2024-08-08 20:08:09 +05:30
Select fix: Correct Select Widget Mapping for Dynamic Label and Value Keys (#35862) 2024-08-27 07:54:44 +01:00
Sliders fix: number slider + category slider color spec fails (#32935) 2024-04-29 11:31:46 +05:30
Statbox feat: enabled editor pane sidebar (#29882) 2024-01-12 20:13:58 +05:30
Switch fix: Wrong evaluated value after binding checkbox group widget with… (#33906) 2024-07-17 10:54:03 +05:30
Tab test: Updated duplicate file names (#34972) 2024-07-31 10:27:33 +05:30
TableV1 test: replace togglebarDisable with CheckUncheck (#34069) 2024-06-10 19:55:17 +05:30
TableV2 fix: Ensure Select Column Displays Data When Options Are Not Set (#35817) 2024-08-23 10:10:27 +01:00
Text feat: enabled editor pane sidebar (#29882) 2024-01-12 20:13:58 +05:30
TreeSelect test: replace togglebarDisable with CheckUncheck (#34069) 2024-06-10 19:55:17 +05:30
Video feat: enabled editor pane sidebar (#29882) 2024-01-12 20:13:58 +05:30
Container_spec.js test: Cypress - @tag.Video, @tag.Container, @tag.Switch, @tag.Slider, @tag.Tab, @tag.Table, @tag.Select (#29698) 2023-12-18 17:05:27 +05:30
ContainerTest2_spec.ts chore: Block Selections when Canvas is in Side by Side mode (#31587) 2024-03-13 11:53:49 +05:30
deprecatedWidgets_spec.js test: Cypress - @tag.Video, @tag.Container, @tag.Switch, @tag.Slider, @tag.Tab, @tag.Table, @tag.Select (#29698) 2023-12-18 17:05:27 +05:30
Disabled_Widgets_drag_validation_spec.js test: Cypress - @tag.Video, @tag.Container, @tag.Switch, @tag.Slider, @tag.Tab, @tag.Table, @tag.Select (#29698) 2023-12-18 17:05:27 +05:30
Migration_Spec.js test: updated tests with aghelper table methods (#33737) 2024-05-31 14:01:06 +05:30
Tab_reset_spec.js test: Cypress - @tag.Video, @tag.Container, @tag.Switch, @tag.Slider, @tag.Tab, @tag.Table, @tag.Select (#29698) 2023-12-18 17:05:27 +05:30
WidgetCanvas_spec.js test: Cypress - @tag.Video, @tag.Container, @tag.Switch, @tag.Slider, @tag.Tab, @tag.Table, @tag.Select (#29698) 2023-12-18 17:05:27 +05:30
WidgetCopyPaste_spec.js chore: autoFocus widget search input on load (#32002) 2024-04-03 13:21:53 +05:30
WidgetGrouping_spec.js test: Cypress - @tag.Video, @tag.Container, @tag.Switch, @tag.Slider, @tag.Tab, @tag.Table, @tag.Select (#29698) 2023-12-18 17:05:27 +05:30
Widgets_Labels_spec.js feat: Homepage experience v2 changes (#29282) 2024-01-25 19:11:48 +05:30
WidgetSelection_spec.js feat: enabled editor pane sidebar (#29882) 2024-01-12 20:13:58 +05:30