-
Notifications
You must be signed in to change notification settings - Fork 905
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix toggle column action in the discover page (#8905)
* Update DocViewerTab if columns is changed * Add unit test for DocViewerTab prop 'columns' changed * Add changeset file * Changeset file for PR #8905 created/updated * Use the new license header --------- Signed-off-by: Tony Lee <[email protected]> Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com> Co-authored-by: Miki <[email protected]> (cherry picked from commit faa6b54) Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
- Loading branch information
1 parent
cf68965
commit c4418f6
Showing
3 changed files
with
37 additions
and
0 deletions.
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: | ||
- Fix toggle column action in the discover page ([#8905](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/8905)) |
34 changes: 34 additions & 0 deletions
34
src/plugins/discover/public/application/components/doc_viewer/doc_viewer_tab.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,34 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import React from 'react'; | ||
import { mount } from 'enzyme'; | ||
import { DocViewerTab, DocViewerTabProps } from './doc_viewer_tab'; | ||
import { DocViewRenderProps } from '../../doc_views/doc_views_types'; | ||
|
||
test('DocViewerTab updated when getting new renderProps', () => { | ||
const MockComp = ({ columns }: DocViewRenderProps) => ( | ||
<div data-test-subj="test-div">{columns![0]}</div> | ||
); | ||
|
||
const mockProps: DocViewerTabProps = { | ||
id: 1, | ||
title: 'Test1', | ||
component: MockComp, | ||
renderProps: { | ||
hit: { _id: '1' }, | ||
columns: ['test1'], | ||
}, | ||
}; | ||
|
||
const wrapper = mount(<DocViewerTab {...mockProps} />); | ||
|
||
const div = wrapper.find({ 'data-test-subj': 'test-div' }); | ||
expect(div.text()).toEqual('test1'); | ||
|
||
mockProps.renderProps = { hit: { _id: '1' }, columns: ['test2'] }; | ||
wrapper.setProps(mockProps); | ||
expect(div.text()).toEqual('test2'); | ||
}); |
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