Skip to content
Merged
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { demoTableDataForSelect } from "../../../../../fixtures/Table/DemoTableData";
import { featureFlagIntercept } from "../../../../../support/Objects/FeatureFlags";
import {
entityExplorer,
propPane,
Expand All @@ -8,6 +10,9 @@ import {
draggableWidgets,
agHelper,
} from "../../../../../support/Objects/ObjectsCore";
import EditorNavigation, {
EntityType,
} from "../../../../../support/Pages/EditorNavigation";

describe(
"Verify various Table_Filter combinations",
Expand Down Expand Up @@ -136,5 +141,46 @@ describe(
table.WaitForTableEmpty("v2");
table.RemoveFilterNVerify("2381224", true, true, 0, "v2");
});

it("11. Verify table search includes label and value for table with select column type", () => {
// This flag is turned on to allow the label show in the table select cell content
// when this feature is turned on fully, this flag will be removed
featureFlagIntercept({ release_table_cell_label_value_enabled: true });
deployMode.NavigateBacktoEditor();
EditorNavigation.SelectEntityByName("Table1", EntityType.Widget);
propPane.EnterJSContext("Table data", demoTableDataForSelect);

// Edit role column to select type
table.ChangeColumnType("role", "Select", "v2");
table.EditColumn("role", "v2");
agHelper.UpdateCodeInput(
locators._controlOption,
`
{{
[
{"label": "Software Engineer",
"value": 10,},
{"label": "Product Manager",
"value": 20,},
{"label": "UX Designer",
"value": 30,}
]
}}
`,
);
// Search for a label in the table
table.SearchTable("Software Engineer");
table.ReadTableRowColumnData(0, 2, "v2").then((afterSearch) => {
expect(afterSearch).to.eq("Software Engineer");
});
table.RemoveSearchTextNVerify("1", "v2");

// Search for a value in the table
table.SearchTable("20");
table.ReadTableRowColumnData(0, 2, "v2").then((afterSearch) => {
expect(afterSearch).to.eq("Product Manager");
});
table.RemoveSearchTextNVerify("1", "v2");
});
},
);
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ describe(
cy.updateCodeInput(
".t--property-control-options",
`
[
{{
Comment thread
rahulbarwal marked this conversation as resolved.
Outdated
[
{
"label": "#1",
"value": "#1"
Expand All @@ -56,6 +57,7 @@ describe(
"value": "#3"
}
]
}}
`,
);
cy.editTableSelectCell(0, 0);
Expand Down Expand Up @@ -84,12 +86,14 @@ describe(
cy.updateCodeInput(
".t--property-control-options",
`
{{
[
{
"label": "test",
"value": "test"
}
]
]
}}
`,
);
cy.wait(500);
Expand Down Expand Up @@ -175,6 +179,7 @@ describe(
cy.updateCodeInput(
".t--property-control-options",
`
{{
[
{
"label": "#1label",
Expand All @@ -188,7 +193,8 @@ describe(
"label": "#3label",
"value": "#3value"
}
]
]
}}
`,
);
cy.editTableSelectCell(0, 0);
Expand Down
46 changes: 46 additions & 0 deletions app/client/cypress/fixtures/Table/DemoTableData.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
export const demoTableDataForSelect = `
{{
[
{
role: 10,
id: 1,
name: "Alice Johnson",
email: "alice.johnson@example.com",
age: 28,
gender: 2
},
{
role: 20,
id: 2,
name: "Bob Smith",
email: "bob.smith@example.com",
age: 34,
gender: 1
},
{
role: 30,
id: 3,
name: "Charlie Brown",
email: "charlie.brown@example.com",
age: 25,
gender: 3
},
{
role: 20,
id: 4,
name: "Diana Prince",
email: "diana.prince@example.com",
age: 30,
gender: 2
},
{
role: 10,
id: 5,
name: "Evan Williams",
email: "evan.williams@example.com",
age: 27,
gender: 1
}
]
}}
`;
28 changes: 28 additions & 0 deletions app/client/src/widgets/TableWidgetV2/widget/derived.js
Original file line number Diff line number Diff line change
Expand Up @@ -587,8 +587,36 @@ export default {
const columnWithDisplayText = Object.values(props.primaryColumns).filter(
(column) => column.columnType === "url" && column.displayText,
);

/*
* For select columns with label and values, we need to include the label value
* in the search
*/
let labelValueForSelectCell = "";
const selectColumnKeys = [];
Object.entries(props.primaryColumns).forEach(([id, column]) => {
const isColumnSelectColumnType =
column?.columnType === "select" && column?.selectOptions?.length;
if (isColumnSelectColumnType) {
selectColumnKeys.push(id);
}
});
if (selectColumnKeys.length) {
selectColumnKeys.forEach((key) => {
const value = row[key];
const selectOptions =
primaryColumns[key].selectOptions[row.__originalIndex__];
const option = selectOptions.find((option) => option.value === value);

if (option) {
labelValueForSelectCell = option.label;
}
});
}

const displayedRow = {
...row,
labelValueForSelectCell,
...columnWithDisplayText.reduce((acc, column) => {
let displayText;
if (_.isArray(column.displayText)) {
Expand Down