-
Notifications
You must be signed in to change notification settings - Fork 919
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
[BUG][Discover] Check if the timestamp is already included to remove duplicate col #6983
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
fix: | ||
- [Discover] Check if the timestamp is already included to remove duplicate col ([#6983](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/6983)) |
120 changes: 120 additions & 0 deletions
120
src/plugins/discover/public/application/components/default_discover_table/helper.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import { getLegacyDisplayedColumns } from './helper'; | ||
import { IndexPattern } from '../../../opensearch_dashboards_services'; | ||
|
||
const mockGetFieldByName = jest.fn(); | ||
|
||
describe('getLegacyDisplayedColumns', () => { | ||
let indexPattern: IndexPattern; | ||
|
||
beforeEach(() => { | ||
indexPattern = ({ | ||
getFieldByName: mockGetFieldByName, | ||
timeFieldName: 'timestamp', | ||
} as unknown) as IndexPattern; | ||
mockGetFieldByName.mockReset(); | ||
}); | ||
|
||
it('should return correct column properties without time column', () => { | ||
mockGetFieldByName.mockReturnValue({ sortable: true }); | ||
const result = getLegacyDisplayedColumns(['column1'], indexPattern, true, false); | ||
expect(result).toEqual([ | ||
{ | ||
name: 'column1', | ||
displayName: 'column1', | ||
isSortable: true, | ||
isRemoveable: true, | ||
colLeftIdx: -1, | ||
colRightIdx: -1, | ||
}, | ||
]); | ||
}); | ||
|
||
it('should prepend time column if not hidden, indexPattern has timeFieldName, and columns do not include timeFieldName', () => { | ||
mockGetFieldByName.mockReturnValue({ sortable: true }); | ||
const result = getLegacyDisplayedColumns(['column1'], indexPattern, false, false); | ||
expect(result).toEqual([ | ||
{ | ||
name: 'timestamp', | ||
displayName: 'Time', | ||
isSortable: true, | ||
isRemoveable: false, | ||
colLeftIdx: -1, | ||
colRightIdx: -1, | ||
}, | ||
{ | ||
name: 'column1', | ||
displayName: 'column1', | ||
isSortable: true, | ||
isRemoveable: true, | ||
colLeftIdx: -1, | ||
colRightIdx: -1, | ||
}, | ||
]); | ||
}); | ||
|
||
it('should not prepend time column if hideTimeField is true', () => { | ||
mockGetFieldByName.mockReturnValue({ sortable: true }); | ||
const result = getLegacyDisplayedColumns(['column1'], indexPattern, true, false); | ||
expect(result).toEqual([ | ||
{ | ||
name: 'column1', | ||
displayName: 'column1', | ||
isSortable: true, | ||
isRemoveable: true, | ||
colLeftIdx: -1, | ||
colRightIdx: -1, | ||
}, | ||
]); | ||
}); | ||
|
||
it('should not prepend time column if timeFieldName is included in columns', () => { | ||
mockGetFieldByName.mockReturnValue({ sortable: true }); | ||
const result = getLegacyDisplayedColumns(['column1', 'timestamp'], indexPattern, false, false); | ||
expect(result).toEqual([ | ||
{ | ||
name: 'column1', | ||
displayName: 'column1', | ||
isSortable: true, | ||
isRemoveable: true, | ||
colLeftIdx: -1, | ||
colRightIdx: 1, | ||
}, | ||
{ | ||
name: 'timestamp', | ||
displayName: 'timestamp', | ||
isSortable: true, | ||
isRemoveable: true, | ||
colLeftIdx: 0, | ||
colRightIdx: -1, | ||
}, | ||
]); | ||
}); | ||
|
||
it('should shorten dotted string in displayName if isShortDots is true', () => { | ||
mockGetFieldByName.mockReturnValue({ sortable: true }); | ||
const result = getLegacyDisplayedColumns(['column.with.dots'], indexPattern, false, true); | ||
expect(result).toEqual([ | ||
{ | ||
name: 'timestamp', | ||
displayName: 'Time', | ||
isSortable: true, | ||
isRemoveable: false, | ||
colLeftIdx: -1, | ||
colRightIdx: -1, | ||
}, | ||
{ | ||
name: 'column.with.dots', | ||
displayName: 'c.w.dots', | ||
isSortable: true, | ||
isRemoveable: true, | ||
colLeftIdx: -1, | ||
colRightIdx: -1, | ||
}, | ||
]); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
How did this build if this wasn't imported correctly?
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.
I do see a type error when I debug the issue
I believe this is related to an old discussion #1660, which highlights that the standard build scripts in the project do not fail on or show TypeScript errors. This has led to a situation where TypeScript compilation errors (like the one I encountered) do not cause the build to fail, allowing many such errors to creep into the project unnoticed.
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.
I believe we don't have the bandwidth to address this issue right now, but we should consider implementing a way to prevent new type errors from being added. This will help ensure the problem doesn't grow larger.
CC: @AMoo-Miki @ashwin-pc
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.
Yeah typescript error right now rely on the IDE or us manually running tsc and validating the diff. I have a work in progress PR to help catch this in the CI but its not complete yet. #6586