Fixed Failing test for alerts list disable/mute operations. (#97057)
* Fixed Failing test for alerts list disable/mute operations. * fixed tests * removed awating check for switch status changed * replaced api methos with ui call * fixed merge * reopen and close actions item menu * fixed mute * Update collapsed_item_actions.tsx Remove changes * removed retry * add retry * replaced try with try for time * inceased retry Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
parent
26315aa751
commit
846aed54d9
|
@ -50,12 +50,25 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
|
|||
return createdAction;
|
||||
}
|
||||
|
||||
async function muteAlert(alertId: string) {
|
||||
const { body: alert } = await supertest
|
||||
.post(`/api/alerting/rule/${alertId}/_mute_all`)
|
||||
.set('kbn-xsrf', 'foo');
|
||||
return alert;
|
||||
}
|
||||
|
||||
async function disableAlert(alertId: string) {
|
||||
const { body: alert } = await supertest
|
||||
.post(`/api/alerting/rule/${alertId}/_disable`)
|
||||
.set('kbn-xsrf', 'foo');
|
||||
return alert;
|
||||
}
|
||||
|
||||
async function refreshAlertsList() {
|
||||
await testSubjects.click('rulesTab');
|
||||
}
|
||||
|
||||
// FLAKY: https://github.com/elastic/kibana/issues/95591
|
||||
describe.skip('alerts list', function () {
|
||||
describe('alerts list', function () {
|
||||
before(async () => {
|
||||
await pageObjects.common.navigateToApp('triggersActions');
|
||||
await testSubjects.click('rulesTab');
|
||||
|
@ -138,25 +151,13 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
|
|||
|
||||
it('should re-enable single alert', async () => {
|
||||
const createdAlert = await createAlert();
|
||||
await disableAlert(createdAlert.id);
|
||||
await refreshAlertsList();
|
||||
await pageObjects.triggersActionsUI.searchAlerts(createdAlert.name);
|
||||
|
||||
await testSubjects.click('collapsedItemActions');
|
||||
|
||||
await pageObjects.triggersActionsUI.toggleSwitch('disableSwitch');
|
||||
|
||||
await pageObjects.triggersActionsUI.ensureRuleActionToggleApplied(
|
||||
createdAlert.name,
|
||||
'disableSwitch',
|
||||
'true'
|
||||
);
|
||||
|
||||
await pageObjects.triggersActionsUI.searchAlerts(createdAlert.name);
|
||||
|
||||
await testSubjects.click('collapsedItemActions');
|
||||
|
||||
await pageObjects.triggersActionsUI.toggleSwitch('disableSwitch');
|
||||
|
||||
await pageObjects.triggersActionsUI.ensureRuleActionToggleApplied(
|
||||
createdAlert.name,
|
||||
'disableSwitch',
|
||||
|
@ -172,7 +173,6 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
|
|||
await testSubjects.click('collapsedItemActions');
|
||||
|
||||
await pageObjects.triggersActionsUI.toggleSwitch('muteSwitch');
|
||||
|
||||
await pageObjects.triggersActionsUI.ensureRuleActionToggleApplied(
|
||||
createdAlert.name,
|
||||
'muteSwitch',
|
||||
|
@ -182,25 +182,14 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
|
|||
|
||||
it('should unmute single alert', async () => {
|
||||
const createdAlert = await createAlert();
|
||||
await muteAlert(createdAlert.id);
|
||||
await refreshAlertsList();
|
||||
await pageObjects.triggersActionsUI.searchAlerts(createdAlert.name);
|
||||
|
||||
await testSubjects.click('collapsedItemActions');
|
||||
|
||||
await pageObjects.triggersActionsUI.toggleSwitch('muteSwitch');
|
||||
|
||||
await pageObjects.triggersActionsUI.ensureRuleActionToggleApplied(
|
||||
createdAlert.name,
|
||||
'muteSwitch',
|
||||
'true'
|
||||
);
|
||||
|
||||
await pageObjects.triggersActionsUI.searchAlerts(createdAlert.name);
|
||||
|
||||
await testSubjects.click('collapsedItemActions');
|
||||
|
||||
await pageObjects.triggersActionsUI.toggleSwitch('muteSwitch');
|
||||
|
||||
await pageObjects.triggersActionsUI.ensureRuleActionToggleApplied(
|
||||
createdAlert.name,
|
||||
'muteSwitch',
|
||||
|
|
|
@ -146,13 +146,7 @@ export function TriggersActionsPageProvider({ getService }: FtrProviderContext)
|
|||
},
|
||||
async toggleSwitch(testSubject: string) {
|
||||
const switchBtn = await testSubjects.find(testSubject);
|
||||
const valueBefore = await switchBtn.getAttribute('aria-checked');
|
||||
await switchBtn.click();
|
||||
await retry.try(async () => {
|
||||
const switchBtnAfter = await testSubjects.find(testSubject);
|
||||
const valueAfter = await switchBtnAfter.getAttribute('aria-checked');
|
||||
expect(valueAfter).not.to.eql(valueBefore);
|
||||
});
|
||||
},
|
||||
async clickCreateAlertButton() {
|
||||
const createBtn = await find.byCssSelector(
|
||||
|
@ -194,9 +188,10 @@ export function TriggersActionsPageProvider({ getService }: FtrProviderContext)
|
|||
switchName: string,
|
||||
shouldBeCheckedAsString: string
|
||||
) {
|
||||
await retry.try(async () => {
|
||||
await retry.tryForTime(30000, async () => {
|
||||
await this.searchAlerts(ruleName);
|
||||
await testSubjects.click('collapsedItemActions');
|
||||
|
||||
const switchControl = await testSubjects.find(switchName);
|
||||
const isChecked = await switchControl.getAttribute('aria-checked');
|
||||
expect(isChecked).to.eql(shouldBeCheckedAsString);
|
||||
|
|
Loading…
Reference in a new issue