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

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
Yulia Čech 2022-02-09 17:17:30 +01:00 committed by GitHub
parent f2e9efe457
commit 67cd496daa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 32 additions and 3 deletions

View file

@ -33,6 +33,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;
clickModalConfirm: () => void;
@ -103,6 +104,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 clickModalConfirm = async () => {
const { find, component } = testBed;
@ -129,6 +136,7 @@ export const setup = async (overridingDependencies: any = {}): Promise<IndicesTe
getIncludeHiddenIndicesToggleStatus,
clickIncludeHiddenIndicesToggle,
clickDataStreamAt,
dataStreamLinkExistsAt,
clickManageContextMenuButton,
clickContextMenuOption,
clickModalConfirm,

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"