Fix search sessions management UI displays wrong warning (#107556)

This commit is contained in:
Anton Dosov 2021-08-09 13:43:07 +02:00 committed by GitHub
parent 10efecf585
commit bc8530e591
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 74 additions and 3 deletions

View file

@ -134,7 +134,7 @@ describe('Background Search Session Management Table', () => {
expect(table.find('tbody td').map((node) => node.text())).toMatchInlineSnapshot(`
Array [
"App",
"Namevery background search ",
"Namevery background search ",
"# Searches0",
"StatusExpired",
"Created2 Dec, 2020, 00:19:32",

View file

@ -161,6 +161,70 @@ describe('Search Sessions Management table column factory', () => {
expect(name.text()).toBe('Cool mock session');
});
describe('old version warning', () => {
const currentKibanaVersion = '7.14.0';
const olderKibanaVersion = '7.13.0';
let hasRenderedVersionWarning: (partialSession: Partial<UISession>) => boolean;
beforeEach(() => {
const [, nameColumn] = getColumns(
mockCoreStart,
mockPluginsSetup,
api,
mockConfig,
tz,
handleAction,
currentKibanaVersion
) as Array<EuiTableFieldDataColumnType<UISession>>;
hasRenderedVersionWarning = (partialSession: Partial<UISession>): boolean => {
const session: UISession = {
...mockSession,
...partialSession,
};
const node = mount(
nameColumn.render!(session.name, session) as ReactElement
).getDOMNode();
return !!node.querySelector('[data-test-subj="versionIncompatibleWarningTestSubj"]');
};
});
test("don't render warning for the same version when can restore", () => {
expect(
hasRenderedVersionWarning({
version: currentKibanaVersion,
status: SearchSessionStatus.COMPLETE,
})
).toBe(false);
});
test("don't render warning for the same version when can't restore", () => {
expect(
hasRenderedVersionWarning({
version: currentKibanaVersion,
status: SearchSessionStatus.EXPIRED,
})
).toBe(false);
});
test('render a warning for a different version when can restore', () => {
expect(
hasRenderedVersionWarning({
version: olderKibanaVersion,
status: SearchSessionStatus.COMPLETE,
})
).toBe(true);
});
test("don't render a warning for a different version when can't restore", () => {
expect(
hasRenderedVersionWarning({
version: olderKibanaVersion,
status: SearchSessionStatus.EXPIRED,
})
).toBe(false);
});
});
});
// Num of searches column

View file

@ -103,12 +103,18 @@ export const getColumns = (
/>
</>
);
// show version warning only if:
// 1. the session was created in a different version of Kibana
// AND
// 2. if still can restore this session: it has IN_PROGRESS or COMPLETE status.
const versionIncompatibleWarning =
isRestorable && version === kibanaVersion ? null : (
isRestorable && version !== kibanaVersion ? (
<>
{' '}
<EuiIconTip
type="alert"
iconProps={{ 'data-test-subj': 'versionIncompatibleWarningTestSubj' }}
content={
<FormattedMessage
id="xpack.data.mgmt.searchSessions.table.versionIncompatibleWarning"
@ -117,7 +123,8 @@ export const getColumns = (
}
/>
</>
);
) : null;
return (
<RedirectAppLinks application={core.application}>
{/* eslint-disable-next-line @elastic/eui/href-or-on-click */}