-
Notifications
You must be signed in to change notification settings - Fork 8k
/
nav_tabs.test.tsx
84 lines (72 loc) · 2.99 KB
/
nav_tabs.test.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
import type { TabNavigationItemProps } from '../../../../common/components/navigation/tab_navigation/types';
import { HostsTableType } from '../../store/model';
import { navTabsHostDetails } from './nav_tabs';
describe('navTabsHostDetails', () => {
const mockHostName = 'mockHostName';
test('it should skip anomalies tab if without mlUserPermission', () => {
const tabs = navTabsHostDetails({
hasMlUserPermissions: false,
isRiskyHostsEnabled: false,
hostName: mockHostName,
});
expect(tabs).toHaveProperty(HostsTableType.authentications);
expect(tabs).toHaveProperty(HostsTableType.uncommonProcesses);
expect(tabs).not.toHaveProperty(HostsTableType.anomalies);
expect(tabs).toHaveProperty(HostsTableType.events);
expect(tabs).not.toHaveProperty(HostsTableType.risk);
});
test('it should display anomalies tab if with mlUserPermission', () => {
const tabs = navTabsHostDetails({
hasMlUserPermissions: true,
isRiskyHostsEnabled: false,
hostName: mockHostName,
});
expect(tabs).toHaveProperty(HostsTableType.authentications);
expect(tabs).toHaveProperty(HostsTableType.uncommonProcesses);
expect(tabs).toHaveProperty(HostsTableType.anomalies);
expect(tabs).toHaveProperty(HostsTableType.events);
expect(tabs).not.toHaveProperty(HostsTableType.risk);
});
test('it should display risky hosts tab if when risky hosts is enabled', () => {
const tabs = navTabsHostDetails({
hasMlUserPermissions: false,
isRiskyHostsEnabled: true,
hostName: mockHostName,
});
expect(tabs).toHaveProperty(HostsTableType.authentications);
expect(tabs).toHaveProperty(HostsTableType.uncommonProcesses);
expect(tabs).not.toHaveProperty(HostsTableType.anomalies);
expect(tabs).toHaveProperty(HostsTableType.events);
expect(tabs).toHaveProperty(HostsTableType.risk);
});
test('it should display sessions tab when users are on Enterprise and above license', () => {
const tabs = navTabsHostDetails({
hasMlUserPermissions: false,
isRiskyHostsEnabled: true,
hostName: mockHostName,
isEnterprise: true,
});
const sessionsTab = Object.values<TabNavigationItemProps>(tabs).find(
(item) => item.id === HostsTableType.sessions
);
expect(sessionsTab).toBeTruthy();
});
test('it should not display sessions tab when users are not on Enterprise and above license', () => {
const tabs = navTabsHostDetails({
hasMlUserPermissions: false,
isRiskyHostsEnabled: true,
hostName: mockHostName,
isEnterprise: false,
});
const sessionsTab = Object.values<TabNavigationItemProps>(tabs).find(
(item) => item.id === HostsTableType.sessions
);
expect(sessionsTab).not.toBeTruthy();
});
});