forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ResponseOps][Maintenance Window] Add and improve E2E tests for the m…
…aintenance window table (elastic#156611) ## Summary Adds functional tests for the maintenance windows table. Should test: - Cancel a maintenance window - Archiving/Unarchiving a maintenance window - Cancelling and archiving a maintenance window - Searching/filtering Issue linked - elastic#155902 (cherry picked from commit 3fef5e5)
- Loading branch information
Showing
11 changed files
with
345 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
x-pack/test/functional/page_objects/maintenance_windows_page.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
* 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 { FtrProviderContext } from '../ftr_provider_context'; | ||
|
||
const ENTER_KEY = '\uE007'; | ||
|
||
export function MaintenanceWindowsPageProvider({ getService }: FtrProviderContext) { | ||
const find = getService('find'); | ||
|
||
return { | ||
async getMaintenanceWindowsList() { | ||
const table = await find.byCssSelector('[data-test-subj="maintenance-windows-table"] table'); | ||
const $ = await table.parseDomContent(); | ||
return $.findTestSubjects('list-item') | ||
.toArray() | ||
.map((row) => { | ||
return { | ||
status: $(row) | ||
.findTestSubject('maintenance-windows-column-status') | ||
.find('.euiTableCellContent') | ||
.text(), | ||
}; | ||
}); | ||
}, | ||
async searchMaintenanceWindows(searchText: string) { | ||
const searchBox = await find.byCssSelector( | ||
'.euiFieldSearch:not(.euiSelectableTemplateSitewide__search)' | ||
); | ||
await searchBox.click(); | ||
await searchBox.clearValue(); | ||
await searchBox.type(searchText); | ||
await searchBox.pressKeys(ENTER_KEY); | ||
await find.byCssSelector( | ||
'.euiBasicTable[data-test-subj="maintenance-windows-table"]:not(.euiBasicTable-loading)' | ||
); | ||
}, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
x-pack/test/functional_with_es_ssl/apps/triggers_actions_ui/maintenance_windows/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/* | ||
* 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 { FtrProviderContext } from '../../../ftr_provider_context'; | ||
|
||
export default ({ loadTestFile }: FtrProviderContext) => { | ||
describe('Maintenance Windows', function () { | ||
loadTestFile(require.resolve('./maintenance_windows_table')); | ||
}); | ||
}; |
216 changes: 216 additions & 0 deletions
216
...nal_with_es_ssl/apps/triggers_actions_ui/maintenance_windows/maintenance_windows_table.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,216 @@ | ||
/* | ||
* 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 expect from '@kbn/expect'; | ||
import { FtrProviderContext } from '../../../ftr_provider_context'; | ||
import { ObjectRemover } from '../../../lib/object_remover'; | ||
import { generateUniqueKey } from '../../../lib/get_test_data'; | ||
import { createMaintenanceWindow, createObjectRemover } from './utils'; | ||
|
||
export default ({ getPageObjects, getService }: FtrProviderContext) => { | ||
const testSubjects = getService('testSubjects'); | ||
const pageObjects = getPageObjects(['common', 'maintenanceWindows', 'header']); | ||
const retry = getService('retry'); | ||
|
||
let objectRemover: ObjectRemover; | ||
const browser = getService('browser'); | ||
|
||
describe('Maintenance windows table', function () { | ||
before(async () => { | ||
objectRemover = await createObjectRemover({ getService }); | ||
}); | ||
|
||
beforeEach(async () => { | ||
await pageObjects.common.navigateToApp('maintenanceWindows'); | ||
}); | ||
|
||
after(async () => { | ||
await objectRemover.removeAll(); | ||
}); | ||
|
||
it('should should cancel a running maintenance window', async () => { | ||
const name = generateUniqueKey(); | ||
const createdMaintenanceWindow = await createMaintenanceWindow({ | ||
name, | ||
getService, | ||
}); | ||
objectRemover.add(createdMaintenanceWindow.id, 'rules/maintenance_window', 'alerting', true); | ||
await browser.refresh(); | ||
|
||
await pageObjects.maintenanceWindows.searchMaintenanceWindows(name); | ||
|
||
let list = await pageObjects.maintenanceWindows.getMaintenanceWindowsList(); | ||
expect(list.length).to.eql(1); | ||
expect(list[0].status).to.eql('Running'); | ||
|
||
await testSubjects.click('table-actions-popover'); | ||
await testSubjects.click('table-actions-cancel'); | ||
await testSubjects.click('confirmModalConfirmButton'); | ||
|
||
await retry.try(async () => { | ||
const toastTitle = await pageObjects.common.closeToast(); | ||
expect(toastTitle).to.eql(`Cancelled running maintenance window '${name}'`); | ||
}); | ||
|
||
await pageObjects.maintenanceWindows.searchMaintenanceWindows(name); | ||
|
||
list = await pageObjects.maintenanceWindows.getMaintenanceWindowsList(); | ||
expect(list.length).to.eql(1); | ||
expect(list[0].status).to.not.eql('Running'); | ||
}); | ||
|
||
it('should should archive finished maintenance window', async () => { | ||
const name = generateUniqueKey(); | ||
const createdMaintenanceWindow = await createMaintenanceWindow({ | ||
name, | ||
startDate: new Date('05-01-2023'), | ||
notRecurring: true, | ||
getService, | ||
}); | ||
objectRemover.add(createdMaintenanceWindow.id, 'rules/maintenance_window', 'alerting', true); | ||
await browser.refresh(); | ||
|
||
await pageObjects.maintenanceWindows.searchMaintenanceWindows(name); | ||
|
||
let list = await pageObjects.maintenanceWindows.getMaintenanceWindowsList(); | ||
expect(list.length).to.eql(1); | ||
expect(list[0].status).to.eql('Finished'); | ||
|
||
await testSubjects.click('table-actions-popover'); | ||
await testSubjects.click('table-actions-archive'); | ||
await testSubjects.click('confirmModalConfirmButton'); | ||
|
||
await retry.try(async () => { | ||
const toastTitle = await pageObjects.common.closeToast(); | ||
expect(toastTitle).to.eql(`Archived maintenance window '${name}'`); | ||
}); | ||
|
||
await pageObjects.maintenanceWindows.searchMaintenanceWindows(name); | ||
|
||
list = await pageObjects.maintenanceWindows.getMaintenanceWindowsList(); | ||
expect(list.length).to.eql(1); | ||
expect(list[0].status).to.eql('Archived'); | ||
}); | ||
|
||
it('should should cancel and archive a running maintenance window', async () => { | ||
const name = generateUniqueKey(); | ||
const createdMaintenanceWindow = await createMaintenanceWindow({ | ||
name, | ||
getService, | ||
}); | ||
objectRemover.add(createdMaintenanceWindow.id, 'rules/maintenance_window', 'alerting', true); | ||
await browser.refresh(); | ||
|
||
await pageObjects.maintenanceWindows.searchMaintenanceWindows(name); | ||
|
||
let list = await pageObjects.maintenanceWindows.getMaintenanceWindowsList(); | ||
expect(list.length).to.eql(1); | ||
expect(list[0].status).to.eql('Running'); | ||
|
||
await testSubjects.click('table-actions-popover'); | ||
await testSubjects.click('table-actions-cancel-and-archive'); | ||
await testSubjects.click('confirmModalConfirmButton'); | ||
|
||
await retry.try(async () => { | ||
const toastTitle = await pageObjects.common.closeToast(); | ||
expect(toastTitle).to.eql(`Cancelled and archived running maintenance window '${name}'`); | ||
}); | ||
|
||
await pageObjects.maintenanceWindows.searchMaintenanceWindows(name); | ||
|
||
list = await pageObjects.maintenanceWindows.getMaintenanceWindowsList(); | ||
expect(list.length).to.eql(1); | ||
expect(list[0].status).to.eql('Archived'); | ||
}); | ||
|
||
it('should should unarchive a maintenance window', async () => { | ||
const name = generateUniqueKey(); | ||
const createdMaintenanceWindow = await createMaintenanceWindow({ | ||
name, | ||
startDate: new Date('05-01-2023'), | ||
notRecurring: true, | ||
getService, | ||
}); | ||
objectRemover.add(createdMaintenanceWindow.id, 'rules/maintenance_window', 'alerting', true); | ||
await browser.refresh(); | ||
|
||
await pageObjects.maintenanceWindows.searchMaintenanceWindows(name); | ||
|
||
let list = await pageObjects.maintenanceWindows.getMaintenanceWindowsList(); | ||
expect(list.length).to.eql(1); | ||
expect(list[0].status).to.eql('Finished'); | ||
|
||
await testSubjects.click('table-actions-popover'); | ||
await testSubjects.click('table-actions-archive'); | ||
await testSubjects.click('confirmModalConfirmButton'); | ||
|
||
await retry.try(async () => { | ||
const toastTitle = await pageObjects.common.closeToast(); | ||
expect(toastTitle).to.eql(`Archived maintenance window '${name}'`); | ||
}); | ||
|
||
await pageObjects.maintenanceWindows.searchMaintenanceWindows(name); | ||
|
||
list = await pageObjects.maintenanceWindows.getMaintenanceWindowsList(); | ||
expect(list.length).to.eql(1); | ||
expect(list[0].status).to.eql('Archived'); | ||
|
||
await testSubjects.click('table-actions-popover'); | ||
await testSubjects.click('table-actions-unarchive'); | ||
await testSubjects.click('confirmModalConfirmButton'); | ||
|
||
await retry.try(async () => { | ||
const toastTitle = await pageObjects.common.closeToast(); | ||
expect(toastTitle).to.eql(`Unarchived maintenance window '${name}'`); | ||
}); | ||
|
||
await pageObjects.maintenanceWindows.searchMaintenanceWindows(name); | ||
|
||
list = await pageObjects.maintenanceWindows.getMaintenanceWindowsList(); | ||
expect(list.length).to.eql(1); | ||
expect(list[0].status).to.eql('Finished'); | ||
}); | ||
|
||
it('should filter maintenance windows by the status', async () => { | ||
const running = await createMaintenanceWindow({ | ||
name: 'running-mw', | ||
getService, | ||
}); | ||
objectRemover.add(running.id, 'rules/maintenance_window', 'alerting', true); | ||
const finished = await createMaintenanceWindow({ | ||
name: 'finished-mw', | ||
startDate: new Date('05-01-2023'), | ||
notRecurring: true, | ||
getService, | ||
}); | ||
objectRemover.add(finished.id, 'rules/maintenance_window', 'alerting', true); | ||
|
||
const date = new Date(); | ||
date.setDate(date.getDate() + 1); | ||
const upcoming = await createMaintenanceWindow({ | ||
name: 'upcoming-mw', | ||
startDate: date, | ||
getService, | ||
}); | ||
objectRemover.add(upcoming.id, 'rules/maintenance_window', 'alerting', true); | ||
await browser.refresh(); | ||
|
||
await pageObjects.maintenanceWindows.searchMaintenanceWindows('mw'); | ||
|
||
const list = await pageObjects.maintenanceWindows.getMaintenanceWindowsList(); | ||
expect(list.length).to.eql(3); | ||
|
||
await testSubjects.click('status-filter-button'); | ||
await testSubjects.click('status-filter-upcoming'); // select Upcoming status filter | ||
await retry.try(async () => { | ||
const upcomingList = await pageObjects.maintenanceWindows.getMaintenanceWindowsList(); | ||
expect(upcomingList.length).to.equal(1); | ||
expect(upcomingList[0].status).to.equal('Upcoming'); | ||
}); | ||
}); | ||
}); | ||
}; |
52 changes: 52 additions & 0 deletions
52
x-pack/test/functional_with_es_ssl/apps/triggers_actions_ui/maintenance_windows/utils.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/* | ||
* 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 { ObjectRemover } from '../../../lib/object_remover'; | ||
import { FtrProviderContext } from '../../../ftr_provider_context'; | ||
|
||
export const createObjectRemover = async ({ | ||
getService, | ||
}: { | ||
getService: FtrProviderContext['getService']; | ||
}) => { | ||
const supertest = getService('supertest'); | ||
const objectRemover = new ObjectRemover(supertest); | ||
|
||
return objectRemover; | ||
}; | ||
|
||
export const createMaintenanceWindow = async ({ | ||
name, | ||
startDate, | ||
notRecurring, | ||
getService, | ||
}: { | ||
name: string; | ||
startDate?: Date; | ||
notRecurring?: boolean; | ||
getService: FtrProviderContext['getService']; | ||
}) => { | ||
const supertest = getService('supertest'); | ||
const dtstart = startDate ? startDate : new Date(); | ||
const createParams = { | ||
title: name, | ||
duration: 60 * 60 * 1000, | ||
r_rule: { | ||
dtstart: dtstart.toISOString(), | ||
tzid: 'UTC', | ||
...(notRecurring ? { freq: 1, count: 1 } : { freq: 2 }), | ||
}, | ||
}; | ||
|
||
const { body } = await supertest | ||
.post(`/internal/alerting/rules/maintenance_window`) | ||
.set('kbn-xsrf', 'foo') | ||
.send(createParams) | ||
.expect(200); | ||
|
||
return body; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.