[8.0] [IM] Removed undefined data stream link (#124847) (#125110)

* [IM] Removed undefined data stream link (#124847)

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
(cherry picked from commit 67cd496daa)

# Conflicts:
#	x-pack/plugins/index_management/__jest__/client_integration/home/indices_tab.helpers.ts

* [IM] Fixed backport merge conflict error
This commit is contained in:
Yulia Čech 2022-02-10 12:34:04 +01:00 committed by GitHub
parent 83e404c6f3
commit 390f76bb15
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 32 additions and 3 deletions

View file

@ -28,6 +28,7 @@ export interface IndicesTestBed extends TestBed<TestSubjects> {
getIncludeHiddenIndicesToggleStatus: () => boolean;
clickIncludeHiddenIndicesToggle: () => void;
clickDataStreamAt: (index: number) => void;
dataStreamLinkExistsAt: (index: number) => boolean;
clickManageContextMenuButton: () => void;
clickContextMenuOption: (optionDataTestSubject: string) => void;
};
@ -97,6 +98,12 @@ export const setup = async (overridingDependencies: any = {}): Promise<IndicesTe
component.update();
};
const dataStreamLinkExistsAt = (index: number) => {
const { table } = testBed;
const { rows } = table.getMetaData('indexTable');
return findTestSubject(rows[index].reactWrapper, 'dataStreamLink').exists();
};
const findDataStreamDetailPanel = () => {
const { find } = testBed;
return find('dataStreamDetailPanel');
@ -114,6 +121,7 @@ export const setup = async (overridingDependencies: any = {}): Promise<IndicesTe
getIncludeHiddenIndicesToggleStatus,
clickIncludeHiddenIndicesToggle,
clickDataStreamAt,
dataStreamLinkExistsAt,
clickManageContextMenuButton,
clickContextMenuOption,
},

View file

@ -7,7 +7,7 @@
import { act } from 'react-dom/test-utils';
import { API_BASE_PATH } from '../../../common/constants';
import { API_BASE_PATH } from '../../../common';
import { setupEnvironment, nextTick } from '../helpers';
import { IndicesTestBed, setup } from './indices_tab.helpers';
import { createDataStreamPayload, createNonDataStreamIndex } from './data_streams_tab.helpers';
@ -100,6 +100,18 @@ describe('<IndexManagementHome />', () => {
name: 'data-stream-index',
data_stream: 'dataStream1',
},
{
health: '',
status: '',
primary: '',
replica: '',
documents: '',
documents_deleted: '',
size: '',
primary_size: '',
name: 'no-data-stream-index',
data_stream: null,
},
]);
// The detail panel should still appear even if there are no data streams.
@ -125,14 +137,23 @@ describe('<IndexManagementHome />', () => {
const {
findDataStreamDetailPanel,
findDataStreamDetailPanelTitle,
actions: { clickDataStreamAt },
actions: { clickDataStreamAt, dataStreamLinkExistsAt },
} = testBed;
expect(dataStreamLinkExistsAt(0)).toBeTruthy();
await clickDataStreamAt(0);
expect(findDataStreamDetailPanel().length).toBe(1);
expect(findDataStreamDetailPanelTitle()).toBe('dataStream1');
});
test(`doesn't show data stream link if the index doesn't have a data stream`, () => {
const {
actions: { dataStreamLinkExistsAt },
} = testBed;
expect(dataStreamLinkExistsAt(1)).toBeFalsy();
});
});
describe('index detail panel with % character in index name', () => {

View file

@ -285,7 +285,7 @@ export class IndexTable extends Component {
{renderBadges(index, filterChanged, appServices.extensionsService)}
</Fragment>
);
} else if (fieldName === 'data_stream') {
} else if (fieldName === 'data_stream' && value) {
return (
<EuiLink
data-test-subj="dataStreamLink"