Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Alerting] License Errors on Alert List View #89920

Merged
merged 28 commits into from
Feb 10, 2021
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
f82f5b3
Adding tooltips to alert list and modal for license upgrade
ymao1 Jan 29, 2021
c3e350b
Merge branch 'master' of https://github.com/elastic/kibana into alert…
ymao1 Feb 1, 2021
c817594
Fixing typings
ymao1 Feb 1, 2021
4546870
Merge branch 'master' of https://github.com/elastic/kibana into alert…
ymao1 Feb 1, 2021
9e3055c
Custom License Error status. Moving modal to alerts list page
ymao1 Feb 1, 2021
09af8f1
Adding unit test
ymao1 Feb 2, 2021
bcde1da
Cleanup
ymao1 Feb 2, 2021
0c2ad1b
Merge branch 'master' of https://github.com/elastic/kibana into alert…
ymao1 Feb 2, 2021
5188f14
Unit tests
ymao1 Feb 2, 2021
bd42c6f
Merge branch 'master' of https://github.com/elastic/kibana into alert…
ymao1 Feb 2, 2021
e5acc75
Removing tooltip from alert name
ymao1 Feb 2, 2021
e985bd8
Merge branch 'master' of https://github.com/elastic/kibana into alert…
ymao1 Feb 4, 2021
aa05bb5
License
ymao1 Feb 4, 2021
a31895c
Merge branch 'master' of https://github.com/elastic/kibana into alert…
ymao1 Feb 5, 2021
95f6333
PR fixes
ymao1 Feb 5, 2021
391ad6e
Merge branch 'master' into alerting/licensing-ux
kibanamachine Feb 8, 2021
e84d0ae
Merge branch 'master' of https://github.com/elastic/kibana into alert…
ymao1 Feb 9, 2021
6f85e7d
Merge branch 'alerting/licensing-ux' of https://github.com/ymao1/kiba…
ymao1 Feb 9, 2021
4a134a7
Updating modal wording
ymao1 Feb 9, 2021
50910cd
Merge branch 'master' into alerting/licensing-ux
kibanamachine Feb 9, 2021
dadd4f2
Merge branch 'master' of https://github.com/elastic/kibana into alert…
ymao1 Feb 9, 2021
9a1fccc
Updating license state error message
ymao1 Feb 10, 2021
48db829
Merge branch 'alerting/licensing-ux' of https://github.com/ymao1/kiba…
ymao1 Feb 10, 2021
a1df060
Merge branch 'master' into alerting/licensing-ux
kibanamachine Feb 10, 2021
f836c28
Merge branch 'master' of https://github.com/elastic/kibana into alert…
ymao1 Feb 10, 2021
ab2bb14
i18n fix
ymao1 Feb 10, 2021
5c8aa76
Fixing functional test
ymao1 Feb 10, 2021
44fedc4
Merge branch 'master' of https://github.com/elastic/kibana into alert…
ymao1 Feb 10, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -125,116 +125,148 @@ describe('alerts_list component empty', () => {

wrapper.find('button[data-test-subj="createFirstAlertButton"]').simulate('click');

// When the AlertAdd component is rendered, it waits for the healthcheck to resolve
await new Promise((resolve) => {
setTimeout(resolve, 1000);
await act(async () => {
// When the AlertAdd component is rendered, it waits for the healthcheck to resolve
await new Promise((resolve) => {
setTimeout(resolve, 1000);
pmuellr marked this conversation as resolved.
Show resolved Hide resolved
});

await nextTick();
wrapper.update();
});
wrapper.update();

expect(wrapper.find('AlertAdd').exists()).toEqual(true);
});
});

describe('alerts_list component with items', () => {
let wrapper: ReactWrapper<any>;

const mockedAlertsData = [
pmuellr marked this conversation as resolved.
Show resolved Hide resolved
{
id: '1',
name: 'test alert',
tags: ['tag1'],
enabled: true,
alertTypeId: 'test_alert_type',
schedule: { interval: '5d' },
actions: [],
params: { name: 'test alert type name' },
scheduledTaskId: null,
createdBy: null,
updatedBy: null,
apiKeyOwner: null,
throttle: '1m',
muteAll: false,
mutedInstanceIds: [],
executionStatus: {
status: 'active',
lastExecutionDate: new Date('2020-08-20T19:23:38Z'),
error: null,
},
},
{
id: '2',
name: 'test alert ok',
tags: ['tag1'],
enabled: true,
alertTypeId: 'test_alert_type',
schedule: { interval: '5d' },
actions: [],
params: { name: 'test alert type name' },
scheduledTaskId: null,
createdBy: null,
updatedBy: null,
apiKeyOwner: null,
throttle: '1m',
muteAll: false,
mutedInstanceIds: [],
executionStatus: {
status: 'ok',
lastExecutionDate: new Date('2020-08-20T19:23:38Z'),
error: null,
},
},
{
id: '3',
name: 'test alert pending',
tags: ['tag1'],
enabled: true,
alertTypeId: 'test_alert_type',
schedule: { interval: '5d' },
actions: [],
params: { name: 'test alert type name' },
scheduledTaskId: null,
createdBy: null,
updatedBy: null,
apiKeyOwner: null,
throttle: '1m',
muteAll: false,
mutedInstanceIds: [],
executionStatus: {
status: 'pending',
lastExecutionDate: new Date('2020-08-20T19:23:38Z'),
error: null,
},
},
{
id: '4',
name: 'test alert error',
tags: ['tag1'],
enabled: true,
alertTypeId: 'test_alert_type',
schedule: { interval: '5d' },
actions: [{ id: 'test', group: 'alert', params: { message: 'test' } }],
params: { name: 'test alert type name' },
scheduledTaskId: null,
createdBy: null,
updatedBy: null,
apiKeyOwner: null,
throttle: '1m',
muteAll: false,
mutedInstanceIds: [],
executionStatus: {
status: 'error',
lastExecutionDate: new Date('2020-08-20T19:23:38Z'),
error: {
reason: AlertExecutionStatusErrorReasons.Unknown,
message: 'test',
},
},
},
{
id: '5',
name: 'test alert license error',
tags: ['tag1'],
enabled: true,
alertTypeId: 'test_alert_type',
schedule: { interval: '5d' },
actions: [{ id: 'test', group: 'alert', params: { message: 'test' } }],
params: { name: 'test alert type name' },
scheduledTaskId: null,
createdBy: null,
updatedBy: null,
apiKeyOwner: null,
throttle: '1m',
muteAll: false,
mutedInstanceIds: [],
executionStatus: {
status: 'error',
lastExecutionDate: new Date('2020-08-20T19:23:38Z'),
error: {
reason: AlertExecutionStatusErrorReasons.License,
message: 'test',
},
},
},
];

async function setup() {
loadAlerts.mockResolvedValue({
page: 1,
perPage: 10000,
total: 4,
data: [
{
id: '1',
name: 'test alert',
tags: ['tag1'],
enabled: true,
alertTypeId: 'test_alert_type',
schedule: { interval: '5d' },
actions: [],
params: { name: 'test alert type name' },
scheduledTaskId: null,
createdBy: null,
updatedBy: null,
apiKeyOwner: null,
throttle: '1m',
muteAll: false,
mutedInstanceIds: [],
executionStatus: {
status: 'active',
lastExecutionDate: new Date('2020-08-20T19:23:38Z'),
error: null,
},
},
{
id: '2',
name: 'test alert ok',
tags: ['tag1'],
enabled: true,
alertTypeId: 'test_alert_type',
schedule: { interval: '5d' },
actions: [],
params: { name: 'test alert type name' },
scheduledTaskId: null,
createdBy: null,
updatedBy: null,
apiKeyOwner: null,
throttle: '1m',
muteAll: false,
mutedInstanceIds: [],
executionStatus: {
status: 'ok',
lastExecutionDate: new Date('2020-08-20T19:23:38Z'),
error: null,
},
},
{
id: '3',
name: 'test alert pending',
tags: ['tag1'],
enabled: true,
alertTypeId: 'test_alert_type',
schedule: { interval: '5d' },
actions: [],
params: { name: 'test alert type name' },
scheduledTaskId: null,
createdBy: null,
updatedBy: null,
apiKeyOwner: null,
throttle: '1m',
muteAll: false,
mutedInstanceIds: [],
executionStatus: {
status: 'pending',
lastExecutionDate: new Date('2020-08-20T19:23:38Z'),
error: null,
},
},
{
id: '4',
name: 'test alert error',
tags: ['tag1'],
enabled: true,
alertTypeId: 'test_alert_type',
schedule: { interval: '5d' },
actions: [{ id: 'test', group: 'alert', params: { message: 'test' } }],
params: { name: 'test alert type name' },
scheduledTaskId: null,
createdBy: null,
updatedBy: null,
apiKeyOwner: null,
throttle: '1m',
muteAll: false,
mutedInstanceIds: [],
executionStatus: {
status: 'error',
lastExecutionDate: new Date('2020-08-20T19:23:38Z'),
error: {
reason: AlertExecutionStatusErrorReasons.Unknown,
message: 'test',
},
},
},
],
data: mockedAlertsData,
});
loadActionTypes.mockResolvedValue([
{
Expand Down Expand Up @@ -269,21 +301,66 @@ describe('alerts_list component with items', () => {
it('renders table of alerts', async () => {
await setup();
expect(wrapper.find('EuiBasicTable')).toHaveLength(1);
expect(wrapper.find('EuiTableRow')).toHaveLength(4);
expect(wrapper.find('[data-test-subj="alertsTableCell-status"]').length).toBeGreaterThan(0);
expect(wrapper.find('[data-test-subj="alertStatus-active"]').length).toBeGreaterThan(0);
expect(wrapper.find('[data-test-subj="alertStatus-error"]').length).toBeGreaterThan(0);
expect(wrapper.find('[data-test-subj="alertStatus-ok"]').length).toBeGreaterThan(0);
expect(wrapper.find('[data-test-subj="alertStatus-pending"]').length).toBeGreaterThan(0);
expect(wrapper.find('[data-test-subj="alertStatus-unknown"]').length).toBe(0);
expect(wrapper.find('EuiTableRow')).toHaveLength(mockedAlertsData.length);
expect(wrapper.find('EuiTableRowCell[data-test-subj="alertsTableCell-status"]').length).toEqual(
mockedAlertsData.length
);
expect(wrapper.find('EuiHealth[data-test-subj="alertStatus-active"]').length).toEqual(1);
expect(wrapper.find('EuiHealth[data-test-subj="alertStatus-ok"]').length).toEqual(1);
expect(wrapper.find('EuiHealth[data-test-subj="alertStatus-pending"]').length).toEqual(1);
expect(wrapper.find('EuiHealth[data-test-subj="alertStatus-unknown"]').length).toEqual(0);

expect(wrapper.find('EuiHealth[data-test-subj="alertStatus-error"]').length).toEqual(2);
expect(wrapper.find('[data-test-subj="alertStatus-error-tooltip"]').length).toEqual(2);
expect(
wrapper.find('EuiButtonEmpty[data-test-subj="alertStatus-error-license-fix"]').length
).toEqual(1);

expect(wrapper.find('[data-test-subj="refreshAlertsButton"]').exists()).toBeTruthy();

expect(wrapper.find('EuiHealth[data-test-subj="alertStatus-error"]').first().text()).toEqual(
'Error'
);
expect(wrapper.find('EuiHealth[data-test-subj="alertStatus-error"]').last().text()).toEqual(
'License Error'
);
});

it('loads alerts when refresh button is clicked', async () => {
await setup();
wrapper.find('[data-test-subj="refreshAlertsButton"]').first().simulate('click');

await act(async () => {
await nextTick();
wrapper.update();
});

expect(loadAlerts).toHaveBeenCalled();
});

it('renders license errors and manage license modal on click', async () => {
global.open = jest.fn();
await setup();
expect(wrapper.find('ManageLicenseModal').exists()).toBeFalsy();
expect(
wrapper.find('EuiButtonEmpty[data-test-subj="alertStatus-error-license-fix"]').length
).toEqual(1);
wrapper
.find('EuiButtonEmpty[data-test-subj="alertStatus-error-license-fix"]')
.simulate('click');

await act(async () => {
await nextTick();
wrapper.update();
});

expect(wrapper.find('ManageLicenseModal').exists()).toBeTruthy();
expect(wrapper.find('EuiButton[data-test-subj="confirmModalConfirmButton"]').text()).toEqual(
'Manage license'
);
wrapper.find('EuiButton[data-test-subj="confirmModalConfirmButton"]').simulate('click');
expect(global.open).toHaveBeenCalled();
});
});

describe('alerts_list component empty with show only capability', () => {
Expand All @@ -306,7 +383,9 @@ describe('alerts_list component empty with show only capability', () => {
name: 'Test2',
},
]);
loadAlertTypes.mockResolvedValue([{ id: 'test_alert_type', name: 'some alert type' }]);
loadAlertTypes.mockResolvedValue([
{ id: 'test_alert_type', name: 'some alert type', authorizedConsumers: {} },
]);
loadAllActions.mockResolvedValue([]);
// eslint-disable-next-line react-hooks/rules-of-hooks
useKibanaMock().services.alertTypeRegistry = alertTypeRegistry;
Expand Down
Loading