-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
fix: display label instead of value in select column of table widget #34224
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,228 @@ | ||
import { | ||
entityExplorer, | ||
propPane, | ||
agHelper, | ||
draggableWidgets, | ||
table, | ||
locators, | ||
} from "../../../../../../support/Objects/ObjectsCore"; | ||
import { | ||
getWidgetSelector, | ||
WIDGET, | ||
} from "../../../../../../locators/WidgetLocators"; | ||
|
||
const tableData = `[ | ||
{ | ||
"id": 2, | ||
"name": "saicharan", | ||
"gender": "M" | ||
}, | ||
{ | ||
"id": 3, | ||
"name": "Raju", | ||
"gender": "M" | ||
}, | ||
{ | ||
"id": 4, | ||
"name": "Rajesh", | ||
"gender": "M" | ||
}, | ||
{ | ||
"id": 5, | ||
"name": "Lahari", | ||
"gender": "F" | ||
}, | ||
{ | ||
"id": 6, | ||
"name": "Sneha", | ||
"gender": "F" | ||
}, | ||
{ | ||
"id": 7, | ||
"name": "Varshini", | ||
"gender": "F" | ||
}, | ||
{ | ||
"id": 8, | ||
"name": "Vidmahi", | ||
"gender": "F" | ||
}, | ||
{ | ||
"id": 9, | ||
"name": "nikhil", | ||
"gender": "M" | ||
} | ||
]`; | ||
const updatedTableData = `[ | ||
{ | ||
"id": 2, | ||
"name": "saicharan", | ||
"gender": "27" | ||
}, | ||
{ | ||
"id": 3, | ||
"name": "Raju", | ||
"gender": "M" | ||
}, | ||
{ | ||
"id": 4, | ||
"name": "Rajesh", | ||
"gender": "M" | ||
}, | ||
{ | ||
"id": 5, | ||
"name": "Lahari", | ||
"gender": "F" | ||
}, | ||
{ | ||
"id": 6, | ||
"name": "Sneha", | ||
"gender": "F" | ||
}, | ||
{ | ||
"id": 7, | ||
"name": "Varshini", | ||
"gender": "F" | ||
}, | ||
{ | ||
"id": 8, | ||
"name": "Vidmahi", | ||
"gender": "F" | ||
}, | ||
{ | ||
"id": 9, | ||
"name": "nikhil", | ||
"gender": "M" | ||
} | ||
]`; | ||
|
||
describe( | ||
"Table widget v2: select column displayAs property test", | ||
{ tags: ["@tag.Widget", "@tag.Table"] }, | ||
() => { | ||
before(() => { | ||
entityExplorer.DragDropWidgetNVerify(draggableWidgets.TABLE, 300, 300); | ||
propPane.EnterJSContext("Table data", tableData); | ||
}); | ||
|
||
it("Check if property displayAs, helperText are visible", function () { | ||
table.ChangeColumnType("gender", "Select", "v2"); | ||
table.EditColumn("gender", "v2"); | ||
agHelper.GetNAssertContains( | ||
locators._helperText, | ||
"Each computed value here represents default value/display value", | ||
); | ||
agHelper.AssertElementExist(propPane._propertyControl("displayas")); | ||
}); | ||
it("Check that select options value and label are being present on table when displayAs = value or label", function () { | ||
propPane.UpdatePropertyFieldValue( | ||
"Options", | ||
`[ | ||
{ | ||
"label":"female", | ||
"value":"F" | ||
}, | ||
{ | ||
"label":"male", | ||
"value":"M" | ||
} | ||
]`, | ||
); | ||
propPane.SelectPropertiesDropDown("Display as", "Value"); | ||
table.ReadTableRowColumnData(0, 2, "v2").then(($cellData) => { | ||
expect($cellData).to.eq("M"); | ||
}); | ||
table.ReadTableRowColumnData(4, 2, "v2").then(($cellData) => { | ||
expect($cellData).to.eq("F"); | ||
}); | ||
|
||
propPane.SelectPropertiesDropDown("Display as", "Label"); | ||
|
||
table.ReadTableRowColumnData(0, 2, "v2").then(($cellData) => { | ||
expect($cellData).to.eq("male"); | ||
}); | ||
table.ReadTableRowColumnData(4, 2, "v2").then(($cellData) => { | ||
expect($cellData).to.eq("female"); | ||
}); | ||
}); | ||
it("Check computed value appearance in table and validation error in select options", function () { | ||
let propPaneBack = "[data-testid='t--property-pane-back-btn']"; | ||
|
||
agHelper.SelectDropdownList("Column type", "Plain text"); | ||
propPane.TogglePropertyState("Editable", "On"); | ||
table.EditTableCell(0, 2, "27"); | ||
// Click on the save button | ||
agHelper.GetNClickByContains( | ||
table._tableRowColumnData(0, 3, "v2"), | ||
"Save", | ||
); | ||
cy.get(propPaneBack).click({ force: true }); | ||
propPane.EnterJSContext("Table data", updatedTableData); | ||
table.ChangeColumnTypeWithoutNavigatingBackToPropertyPane( | ||
"gender", | ||
"Select", | ||
"v2", | ||
); | ||
|
||
table.ReadTableRowColumnData(0, 2, "v2").then(($cellData) => { | ||
expect($cellData).to.eq(""); | ||
}); | ||
|
||
propPane.SelectPropertiesDropDown("Display as", "Value"); | ||
|
||
table.ReadTableRowColumnData(0, 2, "v2").then(($cellData) => { | ||
expect($cellData).to.eq("27"); | ||
}); | ||
|
||
agHelper | ||
.GetElement(`${propPane._propertyControl("options")}`) | ||
.then(($elem: any) => { | ||
agHelper.TypeIntoTextArea($elem, " "); | ||
}); | ||
|
||
agHelper.VerifyEvaluatedErrorMessage( | ||
"Computed Value at row: [1] is not present in the select options.", | ||
); | ||
}); | ||
it("Check that while editing cell's value is changed to label or value of select options based on displayAs property", () => { | ||
entityExplorer.DragDropWidgetNVerify(draggableWidgets.TEXT, 300, 600); | ||
propPane.TypeTextIntoField( | ||
"Text", | ||
"{{Table1.primaryColumns.gender.computedValue}}", | ||
); | ||
|
||
// Click on edit icon of select cell | ||
agHelper.HoverElement(table._tableRow(1, 2, "v2")); | ||
agHelper.GetNClick( | ||
table._tableRow(1, 2, "v2") + " " + table._editCellIconDiv, | ||
0, | ||
true, | ||
); | ||
|
||
agHelper.ContainsNClick("male", 0); | ||
table.ReadTableRowColumnData(1, 2, "v2").then(($cellData) => { | ||
expect($cellData).to.eq("M"); | ||
}); | ||
agHelper.GetText(getWidgetSelector(WIDGET.TEXT)).then((value) => { | ||
expect(value).to.equal( | ||
'[ "27", "M", "M", "F", "F", "F", "F", "M"]', | ||
); | ||
}); | ||
|
||
// open table property pane: | ||
agHelper.GetNClick(getWidgetSelector(WIDGET.TABLE), 0, true); | ||
propPane.SelectPropertiesDropDown("Display as", "Label"); | ||
|
||
agHelper.HoverElement(table._tableRow(1, 2, "v2")); | ||
agHelper.GetNClick( | ||
table._tableRow(1, 2, "v2") + " " + table._editCellIconDiv, | ||
0, | ||
true, | ||
); | ||
agHelper.ContainsNClick("male", 0); | ||
table.ReadTableRowColumnData(1, 2, "v2").then(($cellData) => { | ||
expect($cellData).to.eq("male"); | ||
}); | ||
}); | ||
}, | ||
); |
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -554,6 +554,16 @@ export class Table { | |||||||||||||||||||||||||||||||||||||||||
if (tableVersion == "v2") this.propPane.NavigateBackToPropertyPane(); | ||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||
public ChangeColumnTypeWithoutNavigatingBackToPropertyPane( | ||||||||||||||||||||||||||||||||||||||||||
columnName: string, | ||||||||||||||||||||||||||||||||||||||||||
newDataType: columnTypeValues, | ||||||||||||||||||||||||||||||||||||||||||
tableVersion: "v1" | "v2" = "v1", | ||||||||||||||||||||||||||||||||||||||||||
) { | ||||||||||||||||||||||||||||||||||||||||||
this.EditColumn(columnName, tableVersion); | ||||||||||||||||||||||||||||||||||||||||||
this.propPane.SelectPropertiesDropDown("Column type", newDataType); | ||||||||||||||||||||||||||||||||||||||||||
this.assertHelper.AssertNetworkStatus("@updateLayout"); | ||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+557
to
+565
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ensure Proper Error Handling for Network RequestsThe Consider adding error handling for the network request to improve the robustness of this method. Here's a suggested modification: 557 public ChangeColumnTypeWithoutNavigatingBackToPropertyPane(
558 columnName: string,
559 newDataType: columnTypeValues,
560 tableVersion: "v1" | "v2" = "v1",
561 ) {
562 this.EditColumn(columnName, tableVersion);
563 this.propPane.SelectPropertiesDropDown("Column type", newDataType);
564- this.assertHelper.AssertNetworkStatus("@updateLayout");
564+ this.assertHelper.AssertNetworkStatus("@updateLayout").catch((error) => {
564+ console.error("Network request failed", error);
564+ });
565 } This modification uses Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||
public AssertURLColumnNavigation( | ||||||||||||||||||||||||||||||||||||||||||
row: number, | ||||||||||||||||||||||||||||||||||||||||||
col: number, | ||||||||||||||||||||||||||||||||||||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -183,6 +183,7 @@ export interface SelectCellProperties { | |
placeholderText?: string; | ||
resetFilterTextOnClose?: boolean; | ||
selectOptions?: DropdownOption[]; | ||
selectDisplayAs?: string; | ||
} | ||
|
||
export interface ImageCellProperties { | ||
|
@@ -385,6 +386,7 @@ export interface ColumnProperties | |
menuItemsSource?: MenuItemsSource; | ||
configureMenuItems?: ConfigureMenuItems; | ||
sourceData?: Array<Record<string, unknown>>; | ||
selectDisplayAs?: SelectCellProperties["selectDisplayAs"]; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ensure consistency in property type declaration. The - selectDisplayAs?: SelectCellProperties["selectDisplayAs"];
+ selectDisplayAs?: string;
|
||
} | ||
|
||
export const ConditionFunctions: { | ||
|
@@ -571,3 +573,8 @@ export const noOfItemsToDisplay = 4; | |
|
||
// 12px for the (noOfItemsToDisplay+ 1) item to let the user know there are more items to scroll | ||
export const extraSpace = 12; | ||
|
||
export enum SelectOptionAccessor { | ||
LABEL = "label", | ||
VALUE = "value", | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider converting these function expressions to arrow functions to enhance readability and align with modern JavaScript practices.
Also applies to: 117-147, 148-186
Tools
Biome