-
Notifications
You must be signed in to change notification settings - Fork 4.6k
chore: external merge request from Contributor #36878
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
Changes from 5 commits
72f3828
4d5c7e8
fbcd17f
b08abe7
be21c62
39d4e5e
946bf9c
3a7a853
6869df8
6e21427
6632e4a
315f8db
483a5cb
01e008f
12c9ff5
524b4af
d89cb67
163e7b6
ce56829
8c3eee8
b9377d9
c10dd6a
5a9f249
03ad4e0
7591aea
f40199d
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 | ||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -196,6 +196,12 @@ const sampleProcessedTableData = [ | |||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| describe("Validates getFilteredTableData Properties", () => { | ||||||||||||||||||||||||||||||||
| const inputWithDisplayText = { | ||||||||||||||||||||||||||||||||
| tableData: [ | ||||||||||||||||||||||||||||||||
| { url: "A.COM" }, | ||||||||||||||||||||||||||||||||
| { url: "B.COM" }, | ||||||||||||||||||||||||||||||||
| { url: "C.COM" }, | ||||||||||||||||||||||||||||||||
| { url: "D.COM" }, | ||||||||||||||||||||||||||||||||
| ], | ||||||||||||||||||||||||||||||||
| processedTableData: [ | ||||||||||||||||||||||||||||||||
| { url: "A.COM", __originalIndex__: 0 }, | ||||||||||||||||||||||||||||||||
| { url: "B.COM", __originalIndex__: 1 }, | ||||||||||||||||||||||||||||||||
|
|
@@ -1181,6 +1187,122 @@ describe("Validates getFilteredTableData Properties", () => { | |||||||||||||||||||||||||||||||
| expect(result).toStrictEqual(expected); | ||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| it("should filter correctly after editing a value with an applied filter", () => { | ||||||||||||||||||||||||||||||||
| const { getFilteredTableData } = derivedProperty; | ||||||||||||||||||||||||||||||||
| const input = { | ||||||||||||||||||||||||||||||||
| tableData: [ | ||||||||||||||||||||||||||||||||
| { id: 1234, name: "Jim Doe" }, | ||||||||||||||||||||||||||||||||
| { id: 123, name: "Hamza Khafaga" }, | ||||||||||||||||||||||||||||||||
| { id: 234, name: "Khadija Khafaga" }, | ||||||||||||||||||||||||||||||||
| ], | ||||||||||||||||||||||||||||||||
| processedTableData: [ | ||||||||||||||||||||||||||||||||
| { id: 1234, name: "Jim Doe", __originalIndex__: 0 }, | ||||||||||||||||||||||||||||||||
| { id: 123, name: "Hamza Anas", __originalIndex__: 1 }, | ||||||||||||||||||||||||||||||||
| { id: 234, name: "Khadija Khafaga", __originalIndex__: 2 }, | ||||||||||||||||||||||||||||||||
| ], | ||||||||||||||||||||||||||||||||
| filters: [ | ||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||
| condition: "contains", | ||||||||||||||||||||||||||||||||
| column: "name", | ||||||||||||||||||||||||||||||||
| value: "Khafaga" | ||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||
| ], | ||||||||||||||||||||||||||||||||
| sortOrder: { column: "id", order: "desc" }, | ||||||||||||||||||||||||||||||||
| columnOrder: ["name", "id"], | ||||||||||||||||||||||||||||||||
| primaryColumns: { | ||||||||||||||||||||||||||||||||
| id: { | ||||||||||||||||||||||||||||||||
| index: 1, | ||||||||||||||||||||||||||||||||
| width: 150, | ||||||||||||||||||||||||||||||||
| id: "id", | ||||||||||||||||||||||||||||||||
| alias: "id", | ||||||||||||||||||||||||||||||||
| originalId: "id", | ||||||||||||||||||||||||||||||||
| horizontalAlignment: "LEFT", | ||||||||||||||||||||||||||||||||
| verticalAlignment: "CENTER", | ||||||||||||||||||||||||||||||||
| columnType: "number", | ||||||||||||||||||||||||||||||||
| textColor: "#231F20", | ||||||||||||||||||||||||||||||||
| textSize: "PARAGRAPH", | ||||||||||||||||||||||||||||||||
| fontStyle: "REGULAR", | ||||||||||||||||||||||||||||||||
| enableFilter: true, | ||||||||||||||||||||||||||||||||
| enableSort: true, | ||||||||||||||||||||||||||||||||
| isVisible: true, | ||||||||||||||||||||||||||||||||
| isDerived: false, | ||||||||||||||||||||||||||||||||
| label: "id", | ||||||||||||||||||||||||||||||||
| isAscOrder: false | ||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||
| name: { | ||||||||||||||||||||||||||||||||
| index: 0, | ||||||||||||||||||||||||||||||||
| width: 150, | ||||||||||||||||||||||||||||||||
| id: "name", | ||||||||||||||||||||||||||||||||
| alias: "name", | ||||||||||||||||||||||||||||||||
| originalId: "name", | ||||||||||||||||||||||||||||||||
| horizontalAlignment: "LEFT", | ||||||||||||||||||||||||||||||||
| verticalAlignment: "CENTER", | ||||||||||||||||||||||||||||||||
| columnType: "text", | ||||||||||||||||||||||||||||||||
| textColor: "#231F20", | ||||||||||||||||||||||||||||||||
| textSize: "PARAGRAPH", | ||||||||||||||||||||||||||||||||
| fontStyle: "REGULAR", | ||||||||||||||||||||||||||||||||
| enableFilter: true, | ||||||||||||||||||||||||||||||||
| enableSort: true, | ||||||||||||||||||||||||||||||||
| isVisible: true, | ||||||||||||||||||||||||||||||||
| isDerived: false, | ||||||||||||||||||||||||||||||||
| label: "awesome", | ||||||||||||||||||||||||||||||||
| isAscOrder: undefined | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||
| tableColumns: [ | ||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||
| index: 0, | ||||||||||||||||||||||||||||||||
| width: 150, | ||||||||||||||||||||||||||||||||
| id: "name", | ||||||||||||||||||||||||||||||||
| horizontalAlignment: "LEFT", | ||||||||||||||||||||||||||||||||
| verticalAlignment: "CENTER", | ||||||||||||||||||||||||||||||||
| columnType: "text", | ||||||||||||||||||||||||||||||||
| textColor: "#231F20", | ||||||||||||||||||||||||||||||||
| textSize: "PARAGRAPH", | ||||||||||||||||||||||||||||||||
| fontStyle: "REGULAR", | ||||||||||||||||||||||||||||||||
| enableFilter: true, | ||||||||||||||||||||||||||||||||
| enableSort: true, | ||||||||||||||||||||||||||||||||
| isVisible: true, | ||||||||||||||||||||||||||||||||
| isDerived: false, | ||||||||||||||||||||||||||||||||
| label: "awesome", | ||||||||||||||||||||||||||||||||
| isAscOrder: undefined | ||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||
| index: 1, | ||||||||||||||||||||||||||||||||
| width: 150, | ||||||||||||||||||||||||||||||||
| id: "id", | ||||||||||||||||||||||||||||||||
| horizontalAlignment: "LEFT", | ||||||||||||||||||||||||||||||||
| verticalAlignment: "CENTER", | ||||||||||||||||||||||||||||||||
| columnType: "number", | ||||||||||||||||||||||||||||||||
| textColor: "#231F20", | ||||||||||||||||||||||||||||||||
| textSize: "PARAGRAPH", | ||||||||||||||||||||||||||||||||
| fontStyle: "REGULAR", | ||||||||||||||||||||||||||||||||
| enableFilter: true, | ||||||||||||||||||||||||||||||||
| enableSort: true, | ||||||||||||||||||||||||||||||||
| isVisible: true, | ||||||||||||||||||||||||||||||||
| isDerived: false, | ||||||||||||||||||||||||||||||||
| label: "id", | ||||||||||||||||||||||||||||||||
| isAscOrder: false | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
| ], | ||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| input.orderedTableColumns = Object.values(input.primaryColumns).sort( | ||||||||||||||||||||||||||||||||
| (a, b) => { | ||||||||||||||||||||||||||||||||
| return input.columnOrder[a.id] < input.columnOrder[b.id]; | ||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| const expected = [ | ||||||||||||||||||||||||||||||||
| { id: 234, name: "Khadija Khafaga", __originalIndex__: 2 }, | ||||||||||||||||||||||||||||||||
| { id: 123, name: "Hamza Anas", __originalIndex__: 1 }, | ||||||||||||||||||||||||||||||||
| ]; | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| let result = getFilteredTableData(input, moment, _); | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| expect(result).toStrictEqual(expected); | ||||||||||||||||||||||||||||||||
|
Comment on lines
+1377
to
+1384
Contributor
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. Please revisit the expected results in your test case After changing the name from "Hamza Khafaga" to "Hamza Anas", the row no longer meets the filter condition Apply this diff to correct the expected results: const expected = [
{ id: 234, name: "Khadija Khafaga", __originalIndex__: 2 },
- { id: 123, name: "Hamza Anas", __originalIndex__: 1 },
];📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| it("validates generated sanitized table data with valid property keys", () => { | ||||||||||||||||||||||||||||||||
| const { getProcessedTableData } = derivedProperty; | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
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.
Ensure
originalRowis defined to prevent potential errorsIt's important to verify that
originalRowis valid before using it in the condition function. Ifrow.__originalIndex__does not correspond to a valid index inprops.tableData,originalRowcould beundefined, leading to runtime errors. Consider adding a check to ensure thatoriginalRowis defined.