From cdfe00b1f649179eefdad8abdf64e5a7898d766d Mon Sep 17 00:00:00 2001 From: Veena S <151116685+veenas1@users.noreply.github.com> Date: Sat, 6 Jan 2024 05:25:33 +0530 Subject: [PATCH] #1644 Add button for VirtualizedTable Rows in Expression Builder (#1645) --- .../controls/expression-test.js | 56 ++++++--- .../locales/common-properties/locales/en.json | 1 + .../virtualized-table/virtualized-table.jsx | 2 +- .../common-properties/constants/constants.js | 1 + .../expression-select-field-function.jsx | 114 +++++++++++++----- .../expression/expressionInfo-parser.js | 1 - .../properties/expression-editor-cmds.js | 8 +- 7 files changed, 130 insertions(+), 53 deletions(-) diff --git a/canvas_modules/common-canvas/__tests__/common-properties/controls/expression-test.js b/canvas_modules/common-canvas/__tests__/common-properties/controls/expression-test.js index 3eb812bd14..246e51623d 100644 --- a/canvas_modules/common-canvas/__tests__/common-properties/controls/expression-test.js +++ b/canvas_modules/common-canvas/__tests__/common-properties/controls/expression-test.js @@ -127,6 +127,10 @@ function getCopy(value) { return JSON.parse(JSON.stringify(value)); } +function getAddButtonsList(rows) { + return rows.find("Button.expression-add-field-button"); +} + var controller = new Controller(); const buttonHandler = sinon.spy(); function reset() { @@ -414,7 +418,7 @@ describe("expression-builder renders correctly", () => { // Verify values in "Return" column match with "return_type_label". Default to "return_type". const expectedReturnType = functionInfo.locReturnType ? functionInfo.locReturnType : functionInfo.return_type; const actualReturnType = row.find(".ReactVirtualized__Table__rowColumn") - .at(1) + .at(2) // consider Add column .text(); expect(expectedReturnType).to.eql(actualReturnType); }); @@ -435,7 +439,7 @@ describe("expression-builder renders correctly", () => { // Verify values in "Return" column match with "return_type_label". Default to "return_type". const expectedReturnType = functionInfo.locReturnType ? functionInfo.locReturnType : functionInfo.return_type; const actualReturnType = row.find(".ReactVirtualized__Table__rowColumn") - .at(1) + .at(2) .text(); expect(expectedReturnType).to.eql(actualReturnType); }); @@ -455,8 +459,8 @@ describe("expression-builder renders correctly", () => { // Verify custom header label const header = valuesTable.find("div[data-role='properties-header-row']"); const headerLabel = header.find(".properties-vt-label-tip-icon"); - expect(headerLabel).to.have.length(1); - expect(header.text()).to.equal(harnessMessages[MESSAGE_KEYS.EXPRESSION_VALUE_COLUMN]); + expect(headerLabel).to.have.length(2); // include Add column + expect(header.text()).to.equal("Add" + harnessMessages[MESSAGE_KEYS.EXPRESSION_VALUE_COLUMN]); // Verify info icon const headerInfoIcon = header.find(".properties-vt-info-icon-tip"); @@ -501,7 +505,8 @@ describe("expression-builder select from tables correctly", () => { ); const fieldTable = wrapper.find("div.properties-field-table-container"); - tableUtils.dblClickTableRows(fieldTable, [0]); + const addButtons = getAddButtonsList(tableUtils.getTableRows(fieldTable)); + addButtons.at(0).simulate("click"); expect(controller.getPropertyValue(propertyId)).to.equal(" Age"); }); @@ -517,7 +522,8 @@ describe("expression-builder select from tables correctly", () => { ); const valueTable = wrapper.find("div.properties-value-table-container"); - tableUtils.dblClickTableRows(valueTable, [0]); + const addButtons = getAddButtonsList(tableUtils.getTableRows(valueTable)); + addButtons.at(0).simulate("click"); expect(controller.getPropertyValue(propertyId)).to.equal(" 21"); }); @@ -537,7 +543,8 @@ describe("expression-builder select from tables correctly", () => { tableUtils.clickTableRows(fieldTable, [1]); // select a string value from value table. const valueTable = wrapper.find("div.properties-value-table-container"); - tableUtils.dblClickTableRows(valueTable, [1]); + const addButtons = getAddButtonsList(tableUtils.getTableRows(valueTable)); + addButtons.at(1).simulate("click"); expect(controller.getPropertyValue(propertyId)).to.equal(" \"female\""); }); @@ -554,7 +561,8 @@ describe("expression-builder select from tables correctly", () => { ); wrapper.find("button.expresson-builder-function-tab").simulate("click"); const functionTable = wrapper.find("div.properties-functions-table-container"); - tableUtils.dblClickTableRows(functionTable, [0]); + const addButtons = getAddButtonsList(tableUtils.getTableRows(functionTable)); + addButtons.at(0).simulate("click"); expect(controller.getPropertyValue(propertyId)).to.equal(" to_integer(?)"); }); @@ -747,11 +755,13 @@ describe("expression builder generates and accesses field dropdown correctly", ( expect(wrapper.find("div.properties-expression-field-select span").text()).to.equal("Globals"); const fieldTable = wrapper.find("div.properties-field-table-container"); const valueTable = wrapper.find("div.properties-value-table-container"); - tableUtils.dblClickTableRows(fieldTable, [0]); + const addFieldButtons = getAddButtonsList(tableUtils.getTableRows(fieldTable)); + addFieldButtons.at(0).simulate("click"); // expect selecting a field enters the correct value expect(controller.getPropertyValue(propertyId)).to.equal(" @GLOBAL_MEAN('AGE')"); tableUtils.clickTableRows(fieldTable, [1]); - tableUtils.dblClickTableRows(valueTable, [0]); + const addValueButtons = getAddButtonsList(tableUtils.getTableRows(valueTable)); + addValueButtons.at(0).simulate("click"); expect(controller.getPropertyValue(propertyId)).to.equal(" @GLOBAL_MEAN('AGE') 8863"); // test mrs dropDown = wrapper.find("div.properties-expression-field-select button"); @@ -759,10 +769,10 @@ describe("expression builder generates and accesses field dropdown correctly", ( dropDownList = wrapper.find("div.bx--list-box__menu .bx--list-box__menu-item"); dropDownList.at(3).simulate("click"); expect(wrapper.find("div.properties-expression-field-select span").text()).to.equal("Multi Response Set"); - tableUtils.dblClickTableRows(fieldTable, [0]); + addFieldButtons.at(0).simulate("click"); expect(controller.getPropertyValue(propertyId)).to.equal(" @GLOBAL_MEAN('AGE') 8863 numberSet"); tableUtils.clickTableRows(fieldTable, [1]); - tableUtils.dblClickTableRows(valueTable, [0]); + addValueButtons.at(0).simulate("click"); expect(controller.getPropertyValue(propertyId)).to.equal(" @GLOBAL_MEAN('AGE') 8863 numberSet 1"); }); }); @@ -946,7 +956,10 @@ describe("expression builder correctly runs Recently Used dropdown options", () var dropDownList = wrapper.find("div.bx--list-box__menu .bx--list-box__menu-item"); dropDownList.at(1).simulate("click"); expect(wrapper.find("div.properties-expression-field-select span").text()).to.equal("Recently Used"); - expect(wrapper.find("div.properties-field-table-container .properties-vt-column").text()).to.equal("Item"); + expect(wrapper.find("div.properties-field-table-container .properties-vt-column").at(0) + .text()).to.equal("Add"); + expect(wrapper.find("div.properties-field-table-container .properties-vt-column").at(1) + .text()).to.equal("Item"); fieldRows = tableUtils.getTableRows(wrapper.find("div.properties-field-table-container")); expect(fieldRows).to.have.length(0); // back to Fields @@ -956,8 +969,9 @@ describe("expression builder correctly runs Recently Used dropdown options", () dropDownList.at(0).simulate("click"); fieldRows = tableUtils.getTableRows(wrapper.find("div.properties-field-table-container")); // add two rows to Recently Used - fieldRows.at(0).simulate("dblclick"); - fieldRows.at(1).simulate("dblclick"); + const addButtons = getAddButtonsList(fieldRows); + addButtons.at(0).simulate("click"); + addButtons.at(1).simulate("click"); // back to Recently used dropDown = wrapper.find("div.properties-expression-field-select .bx--list-box__field"); dropDown.simulate("click"); @@ -979,7 +993,7 @@ describe("expression builder correctly runs Recently Used dropdown options", () dropDownList.at(0).simulate("click"); fieldRows = tableUtils.getTableRows(wrapper.find("div.properties-field-table-container")); // add Age again, moving it to the top of Recently Used - fieldRows.at(0).simulate("dblclick"); + addButtons.at(0).simulate("click"); // back to Recently Used dropDown = wrapper.find("div.properties-expression-field-select .bx--list-box__field"); dropDown.simulate("click"); @@ -1016,6 +1030,8 @@ describe("expression builder correctly runs Recently Used dropdown options", () dropDownList.at(1).simulate("click"); expect(wrapper.find("div.properties-expression-function-select span").text()).to.equal("Recently Used"); expect(wrapper.find("div.properties-functions-table-container .properties-vt-column").at(0) + .text()).to.equal("Add"); + expect(wrapper.find("div.properties-functions-table-container .properties-vt-column").at(1) .text()).to.equal("Function"); funcRows = tableUtils.getTableRows(wrapper.find("div.properties-functions-table-container")); expect(funcRows).to.have.length(0); @@ -1026,8 +1042,9 @@ describe("expression builder correctly runs Recently Used dropdown options", () dropDownList.at(0).simulate("click"); funcRows = tableUtils.getTableRows(wrapper.find("div.properties-functions-table-container")); // add two rows to Recently Used - funcRows.at(0).simulate("dblclick"); - funcRows.at(1).simulate("dblclick"); + const addFuncButtons = getAddButtonsList(funcRows); + addFuncButtons.at(0).simulate("click"); + addFuncButtons.at(1).simulate("click"); // back to Recently used dropDown = wrapper.find("div.properties-expression-function-select .bx--list-box__field"); dropDown.simulate("click"); @@ -1045,7 +1062,8 @@ describe("expression builder correctly runs Recently Used dropdown options", () dropDownList.at(0).simulate("click"); funcRows = tableUtils.getTableRows(wrapper.find("div.properties-functions-table-container")); // add to_integer again, moving it to the top of Recently Used - funcRows.at(0).simulate("dblclick"); + const addButtons = getAddButtonsList(funcRows); + addButtons.at(0).simulate("click"); // back to Recently Used dropDown = wrapper.find("div.properties-expression-function-select .bx--list-box__field"); dropDown.simulate("click"); diff --git a/canvas_modules/common-canvas/locales/common-properties/locales/en.json b/canvas_modules/common-canvas/locales/common-properties/locales/en.json index 549365de5b..c8119c99ea 100644 --- a/canvas_modules/common-canvas/locales/common-properties/locales/en.json +++ b/canvas_modules/common-canvas/locales/common-properties/locales/en.json @@ -56,6 +56,7 @@ "expression.values.empty.table.label": "No values found", "expression.functions.table.label": "Functions table", "expression.fields.dropdown": "Fields", + "expression.add.column": "Add", "expression.fields.title": "Fields", "expression.values.title": "Values", "expression.field.column": "Field", diff --git a/canvas_modules/common-canvas/src/common-properties/components/virtualized-table/virtualized-table.jsx b/canvas_modules/common-canvas/src/common-properties/components/virtualized-table/virtualized-table.jsx index d150df56a1..3ecd6dc60a 100644 --- a/canvas_modules/common-canvas/src/common-properties/components/virtualized-table/virtualized-table.jsx +++ b/canvas_modules/common-canvas/src/common-properties/components/virtualized-table/virtualized-table.jsx @@ -380,7 +380,7 @@ class VirtualizedTable extends React.Component { } if (this.props.selectable) { - const rowSelected = this.isRowSelected(rowData.originalRowIndex); + const rowSelected = this.props.sortDirection ? this.isRowSelected(rowData.index) : this.isRowSelected(rowData.originalRowIndex); // use current row index when Sorted selectedRow = this.props.selectable && rowSelected; if (this.props.rowSelection !== ROW_SELECTION.SINGLE) { const translatedRowCheckboxLabel = this.props.intl.formatMessage( diff --git a/canvas_modules/common-canvas/src/common-properties/constants/constants.js b/canvas_modules/common-canvas/src/common-properties/constants/constants.js index 71a9afa45b..76cb759e1c 100644 --- a/canvas_modules/common-canvas/src/common-properties/constants/constants.js +++ b/canvas_modules/common-canvas/src/common-properties/constants/constants.js @@ -73,6 +73,7 @@ export const MESSAGE_KEYS = { EXPRESSION_FIELDS_TITLE: "expression.fields.title", EXPRESSION_VALUES_TITLE: "expression.values.title", EXPRESSION_FIELD_COLUMN: "expression.field.column", + EXPRESSION_ADD_COLUMN: "expression.add.column", EXPRESSION_FIELD_COLUMN_DESCRIPTION: "expression.field.column.description", EXPRESSION_STORAGE_COLUMN: "expression.storage.column", EXPRESSION_VALUE_COLUMN: "expression.value.column", diff --git a/canvas_modules/common-canvas/src/common-properties/controls/expression/expression-builder/expression-select-field-function.jsx b/canvas_modules/common-canvas/src/common-properties/controls/expression/expression-builder/expression-select-field-function.jsx index 28bb763c5b..78a1bac865 100644 --- a/canvas_modules/common-canvas/src/common-properties/controls/expression/expression-builder/expression-select-field-function.jsx +++ b/canvas_modules/common-canvas/src/common-properties/controls/expression/expression-builder/expression-select-field-function.jsx @@ -16,6 +16,8 @@ import React from "react"; import PropTypes from "prop-types"; +import { Add16 } from "@carbon/icons-react"; +import { Button } from "carbon-components-react"; import { Switch, ContentSwitcher, Dropdown } from "carbon-components-react"; import FlexibleTable from "./../../../components/flexible-table/flexible-table"; import TruncatedContentTooltip from "./../../../components/truncated-content-tooltip"; @@ -38,6 +40,9 @@ export default class ExpressionSelectFieldOrFunction extends React.Component { id: this.recentUseCat, locLabel: this.recentUseCat, field_columns: { + add_column_info: { + locLabel: formatMessage(this.reactIntl, MESSAGE_KEYS.EXPRESSION_ADD_COLUMN) + }, field_column_info: { locLabel: formatMessage(this.reactIntl, MESSAGE_KEYS.EXPRESSION_RECENTLY_USED_COLUMN) }, @@ -71,11 +76,11 @@ export default class ExpressionSelectFieldOrFunction extends React.Component { this.language = props.language; this.onFieldTableClick = this.onFieldTableClick.bind(this); - this.onFieldTableDblClick = this.onFieldTableDblClick.bind(this); + this.onAddFieldClick = this.onAddFieldClick.bind(this); this.onFunctionTableClick = this.onFunctionTableClick.bind(this); - this.onFunctionTableDblClick = this.onFunctionTableDblClick.bind(this); + this.onAddFunctionClick = this.onAddFunctionClick.bind(this); this.onValueTableClick = this.onValueTableClick.bind(this); - this.onValueTableDblClick = this.onValueTableDblClick.bind(this); + this.onAddValueClick = this.onAddValueClick.bind(this); this.sortTableRows = this.sortTableRows.bind(this); this.shouldQuoteField = this.shouldQuoteField.bind(this); @@ -120,7 +125,7 @@ export default class ExpressionSelectFieldOrFunction extends React.Component { } - onFieldTableDblClick(evt, rowKey, index) { + onAddFieldClick(rowKey) { const field = this.state.currentFieldDataset[rowKey]; let value = field.id; if (this.state.fieldCategory !== this.recentUseCat) { @@ -145,7 +150,7 @@ export default class ExpressionSelectFieldOrFunction extends React.Component { }); } - onValueTableDblClick(evt, rowKey, index) { + onAddValueClick(rowKey) { if (this.props.onChange) { const field = this.state.currentFieldDataset[this.state.fieldSelected]; const quote = "\""; @@ -174,7 +179,7 @@ export default class ExpressionSelectFieldOrFunction extends React.Component { }); } - onFunctionTableDblClick(evt, rowKey, index) { + onAddFunctionClick(rowKey) { let field; if (this.state.functionCategory === this.recentUseCat) { field = this.props.controller.getExpressionRecentlyUsed()[rowKey]; @@ -265,7 +270,40 @@ export default class ExpressionSelectFieldOrFunction extends React.Component { return contentObject; } + createAddButtonContent(index, tableType) { + const addValueButtonContent = ( + + ); + return addValueButtonContent; + } + + handleAddButtonClick(index, tableType) { + switch (tableType) { + case "value": { + this.onAddValueClick(index); + break; + } + case "field": { + this.onAddFieldClick(index); + break; + } + case "function": { + this.onAddFunctionClick(index); + break; + } + default: + } + } + _makeDatasetFields(dataset, fieldDataset) { + const addNewColumn = formatMessage(this.reactIntl, MESSAGE_KEYS.EXPRESSION_ADD_COLUMN); const fieldColumn = formatMessage(this.reactIntl, MESSAGE_KEYS.EXPRESSION_FIELD_COLUMN); const fieldColumnDesc = formatMessage(this.reactIntl, MESSAGE_KEYS.EXPRESSION_FIELD_COLUMN_DESCRIPTION); const storageColumn = formatMessage(this.reactIntl, MESSAGE_KEYS.EXPRESSION_STORAGE_COLUMN); @@ -274,6 +312,9 @@ export default class ExpressionSelectFieldOrFunction extends React.Component { id: "fields", locLabel: dropdownLabel, field_columns: { + add_column_info: { + locLabel: addNewColumn + }, field_column_info: { locLabel: fieldColumn, descLabel: fieldColumnDesc @@ -377,17 +418,31 @@ export default class ExpressionSelectFieldOrFunction extends React.Component { } if (categoryInfo) { - fieldHeaders.push({ - key: "fieldName", - label: categoryInfo.field_columns.field_column_info.locLabel, - description: categoryInfo.field_columns.field_column_info.descLabel, - resizable: true - }); - valueHeader.push({ - key: "values", - label: categoryInfo.field_columns.value_column_info.locLabel, - description: categoryInfo.field_columns.value_column_info.descLabel - }); + fieldHeaders.push( + { + key: "addColumn", + label: formatMessage(this.reactIntl, MESSAGE_KEYS.EXPRESSION_ADD_COLUMN), + width: "50px", + staticWidth: true + }, + { + key: "fieldName", + label: categoryInfo.field_columns.field_column_info.locLabel, + description: categoryInfo.field_columns.field_column_info.descLabel, + resizable: true + }); + valueHeader.push( + { + key: "addColumn", + label: formatMessage(this.reactIntl, MESSAGE_KEYS.EXPRESSION_ADD_COLUMN), + width: "50px", + staticWidth: true + }, + { + key: "values", + label: categoryInfo.field_columns.value_column_info.locLabel, + description: categoryInfo.field_columns.value_column_info.descLabel + }); if (categoryInfo.field_columns.additional_column_info) { for (let i = 0; i < categoryInfo.field_columns.additional_column_info.length; i++) { sortable.push(categoryInfo.field_columns.additional_column_info[i].id); @@ -404,8 +459,9 @@ export default class ExpressionSelectFieldOrFunction extends React.Component { const field = tableContents.field_value_groups[index]; const fieldColumns = []; if (!this.state.fieldFilterText || this.state.fieldFilterText.length === 0 || - (field.id.toLowerCase().indexOf(this.state.fieldFilterText.toLowerCase()) > -1)) { - fieldColumns.push({ column: "fieldName", content: this.createContentObject(field.id), value: field.id }); + (field.id.toLowerCase().indexOf(this.state.fieldFilterText.toLowerCase()) > -1)) { + fieldColumns.push({ column: "addColumn", content: this.createAddButtonContent(index, "field"), value: field.id }, + { column: "fieldName", content: this.createContentObject(field.id), value: field.id }); if (field.additional_column_entries) { this._makeAdditionalColumnsContent(field, fieldColumns); } @@ -453,7 +509,6 @@ export default class ExpressionSelectFieldOrFunction extends React.Component { rowSelection={ROW_SELECTION.SINGLE} updateRowSelections={this.onFieldTableClick} selectedRows={[selectedField]} - onRowDoubleClick={this.onFieldTableDblClick} onSort={this.setSortColumn.bind(this, "fieldTable")} light={this.props.controller.getLight()} emptyTablePlaceholder={emptyFieldsLabel} @@ -471,7 +526,6 @@ export default class ExpressionSelectFieldOrFunction extends React.Component { rowSelection={ROW_SELECTION.SINGLE} updateRowSelections={this.onValueTableClick} selectedRows={[selectedValue]} - onRowDoubleClick={this.onValueTableDblClick} onSort={this.setSortColumn.bind(this, "valuesTable")} light={this.props.controller.getLight()} emptyTablePlaceholder={emptyValuesLabel} @@ -504,9 +558,11 @@ export default class ExpressionSelectFieldOrFunction extends React.Component { _addValueRow(content, index, valuesTableData) { if (!this.state.valueFilterText || this.state.valueFilterText.length === 0 || - (String(content).toLowerCase() - .indexOf(this.state.valueFilterText.toLowerCase()) > -1)) { - const valueColumns = [{ column: "values", content: this.createContentObject(content), value: content }]; + (String(content).toLowerCase() + .indexOf(this.state.valueFilterText.toLowerCase()) > -1)) { + const valueColumns = [ + { column: "addColumn", content: this.createAddButtonContent(index, "value"), value: content }, + { column: "values", content: this.createContentObject(content), value: content }]; valuesTableData.push({ columns: valueColumns, rowKey: index }); } } @@ -597,10 +653,12 @@ export default class ExpressionSelectFieldOrFunction extends React.Component { MESSAGE_KEYS.EXPRESSION_FUNCTION_COLUMN); const returnColumn = formatMessage(this.reactIntl, MESSAGE_KEYS.EXPRESSION_RETURN_COLUMN); + const addNewColumn = formatMessage(this.reactIntl, + MESSAGE_KEYS.EXPRESSION_ADD_COLUMN); - - headers.push({ key: "function", label: functionColumn, width: 73, resizable: true }); - headers.push({ key: "return", label: returnColumn, width: 27 }); + headers.push({ key: "addColumn", label: addNewColumn, width: "50px", staticWidth: true }); + headers.push({ key: "function", label: functionColumn, width: 50, resizable: true }); + headers.push({ key: "return", label: returnColumn, width: 30 }); const table = this._buildFunctionTable(this.state.functionCategory); let data = table.rows; @@ -627,7 +685,6 @@ export default class ExpressionSelectFieldOrFunction extends React.Component { rowSelection={ROW_SELECTION.SINGLE} updateRowSelections={this.onFunctionTableClick} selectedRows={[selectedFunction]} - onRowDoubleClick={this.onFunctionTableDblClick} onSort={this.setSortColumn.bind(this, "functionTable")} light={this.props.controller.getLight()} emptyTablePlaceholder={functionsEmptyLabel} @@ -650,6 +707,7 @@ export default class ExpressionSelectFieldOrFunction extends React.Component { if (!this.state.functionFilterText || this.state.functionFilterText.length === 0 || (catFunction.locLabel.toLowerCase().indexOf(this.state.functionFilterText.toLowerCase()) > -1)) { const returnType = catFunction.locReturnType ? catFunction.locReturnType : catFunction.return_type; + columns.push({ column: "addColumn", content: this.createAddButtonContent(index, "function"), value: catFunction.id }); columns.push({ column: "function", content: this.createContentObject(catFunction.locLabel), value: catFunction.locLabel }); columns.push({ column: "return", content: this.createContentObject(returnType), value: returnType }); table.rows.push({ columns: columns, rowKey: index }); diff --git a/canvas_modules/common-canvas/src/common-properties/controls/expression/expressionInfo-parser.js b/canvas_modules/common-canvas/src/common-properties/controls/expression/expressionInfo-parser.js index 4b666050a7..07831207d8 100644 --- a/canvas_modules/common-canvas/src/common-properties/controls/expression/expressionInfo-parser.js +++ b/canvas_modules/common-canvas/src/common-properties/controls/expression/expressionInfo-parser.js @@ -57,7 +57,6 @@ function setExpressionInfo(inExpressionInfo) { if (inExpressionInfo.fields.field_categories) { inExpressionInfo.fields.field_categories.forEach((fieldCat) => { fieldCat.locLabel = l10nProvider.l10nLabel(fieldCat, fieldCat.id); - fieldCat.field_columns.field_column_info.locLabel = l10nProvider.l10nLabel(fieldCat.field_columns.field_column_info, fieldCat.id + ".field_column_info"); fieldCat.field_columns.value_column_info.locLabel = l10nProvider.l10nLabel(fieldCat.field_columns.value_column_info, fieldCat.id + ".value_column_info"); diff --git a/canvas_modules/harness/cypress/support/properties/expression-editor-cmds.js b/canvas_modules/harness/cypress/support/properties/expression-editor-cmds.js index 255f925bed..abd80c22e6 100644 --- a/canvas_modules/harness/cypress/support/properties/expression-editor-cmds.js +++ b/canvas_modules/harness/cypress/support/properties/expression-editor-cmds.js @@ -70,9 +70,9 @@ Cypress.Commands.add("selectFieldFromPropertyInSubPanel", (fieldName, propertyId .find("div[data-role='properties-data-row']") .find(".properties-expr-table-cell") .then((tableCells) => { - const cell = getCellMatch(tableCells, fieldName); + const cell = getAddCellMatch(tableCells, fieldName); expect(cell).to.not.equal(null); - cy.wrap(cell).dblclick({ force: true }); + cy.wrap(cell).click({ force: true }); // Single click on Add button }); }); @@ -87,10 +87,10 @@ Cypress.Commands.add("triggerBlurInExpressionBuilder", () => { .click({ force: true }); }); -function getCellMatch(tableCells, fieldName) { +function getAddCellMatch(tableCells, fieldName) { for (let idx = 0; idx < tableCells.length; idx++) { if (tableCells[idx].textContent === fieldName) { - return (tableCells[idx]); + return (tableCells[idx - 1]); // Add column will be at First index, before the field col } } return null;