PromucFlow_constructor/app/client/cypress/e2e/Regression/ClientSide/Widgets
Rahul Barwal 6507f90e05
fix: Incorrect updation of selctedRowIndex when primary column is set. (#36393)
## Description
<ins> Problem statement </ins>
1. Table should have a primary column set.
2. The table should be filtered(via search or client side filters)
3. there should be a selectedRow in table
a. One way to ensure is add a text widget and bind it to table's
`selectedRowIndex` property.

If you now run a query that updates the data behind the table: the
`selectedRow` is updated to (seemingly) random row and selectedRowIndex
is updated as well

<ins> Rootcause </ins>
We have a mechanism of preserving `selectedRow` when data updates
happen.
Underlying logic gets the previous selected row and tries to find it in
the new data using the primary key.
* If it finds it, it updates the selectedRowIndex to the
`__original_index__` of the found row i.e. its position in the original
data before any filters were applied.

<ins> Solution </ins>
We update the selectedRowIndex to the index in the new filtered data.

<ins> How to test </ins>
1. Create a table with a primary key
2. Add a text widget and bind it to table's `selectedRowIndex` property
3. Filter the table
4. Click on a row to select it
5. Run a query that updates the data behind the table
6. Assert that the selected row is the same and that the
selectedRowIndex is updated to the new index


Fixes #36080
_or_  
Fixes `Issue URL`
> [!WARNING]  
> _If no issue exists, please create an issue first, and check with the
maintainers if the issue is valid._

## Automation

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

### 🔍 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/10953679202>
> Commit: 1a2d64467e453229940b67b29da1ce9d0e9ac24d
> <a
href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=10953679202&attempt=1"
target="_blank">Cypress dashboard</a>.
> Tags: `@tag.Table, @tag.Binding, @tag.Sanity`
> Spec:
> <hr>Fri, 20 Sep 2024 06:30:08 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

## Summary by CodeRabbit

- **Improvements**
- Enhanced the efficiency of the TableWidgetV2 by streamlining the
method for retrieving the index of selected rows.
- Improved code readability and maintainability without altering the
overall functionality.

- **New Features**
- Introduced new test cases to validate filtering and searching
functionalities within the Table Widget V2.
- Added a JSON configuration for a data-driven table interface,
supporting sorting, filtering, and dynamic data binding.
- Introduced fixture data for testing, allowing for comprehensive
validation of table behavior under various conditions.
- Added a JavaScript object containing employee data to facilitate
filtering and display in the table.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2024-09-20 12:25:23 +05:30
..
Audio
Button chore: Added sanity and tags for blank tag specs (#36421) 2024-09-19 18:21:58 +05:30
Camera chore: change snapshot package (#35867) 2024-09-12 11:09:42 +03:00
Chart chore: Added sanity and tags for blank tag specs (#36421) 2024-09-19 18:21:58 +05:30
Checkbox test: updated tests for checkboxgroup (#35945) 2024-08-29 22:55:33 +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 fix: Fix datepicker issue with aghelper (#36325) 2024-09-16 13:33:53 +05:30
Divider test: Updated duplicate file names (#34972) 2024-07-31 10:27:33 +05:30
DocumentViewer
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 chore: Added sanity and tags for blank tag specs (#36421) 2024-09-19 18:21:58 +05:30
List fix: Fall of the error toasts wall (#35839) 2024-09-05 11:06:43 +05:30
ListV2 chore: Added sanity and tags for blank tag specs (#36421) 2024-09-19 18:21:58 +05:30
Modal feat: added modal name, lint warning for string, action selector modal (#32893) 2024-05-02 17:48:53 +05:30
Multiselect chore: Added sanity and tags for blank tag specs (#36421) 2024-09-19 18:21:58 +05:30
Others chore: fix map chart spec (#36370) 2024-09-18 11:53:42 +05:30
PhoneInput
Radio
Rating
RTE chore: Upgrade TinyMCE (#35399) 2024-08-08 20:08:09 +05:30
Select chore: Added sanity and tags for blank tag specs (#36421) 2024-09-19 18:21:58 +05:30
Sliders fix: number slider + category slider color spec fails (#32935) 2024-04-29 11:31:46 +05:30
Statbox
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: Incorrect updation of selctedRowIndex when primary column is set. (#36393) 2024-09-20 12:25:23 +05:30
Text fix: Fall of the error toasts wall (#35839) 2024-09-05 11:06:43 +05:30
TreeSelect test: replace togglebarDisable with CheckUncheck (#34069) 2024-06-10 19:55:17 +05:30
Video fix: Video2 spec flaky fix (#36166) 2024-09-09 11:55:00 +05:30
Container_spec.js
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
Disabled_Widgets_drag_validation_spec.js
Migration_Spec.js test: updated tests with aghelper table methods (#33737) 2024-05-31 14:01:06 +05:30
Tab_reset_spec.js
WidgetCanvas_spec.js
WidgetCopyPaste_spec.js chore: autoFocus widget search input on load (#32002) 2024-04-03 13:21:53 +05:30
WidgetGrouping_spec.js
Widgets_Labels_spec.js
WidgetSelection_spec.js