mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
Fix search sessions management UI displays wrong warning (#107556)
This commit is contained in:
parent
10efecf585
commit
bc8530e591
3 changed files with 74 additions and 3 deletions
|
@ -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",
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 */}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue