diff --git a/x-pack/plugins/triggers_actions_ui/public/application/sections/action_connector_form/action_form.tsx b/x-pack/plugins/triggers_actions_ui/public/application/sections/action_connector_form/action_form.tsx index 6d91e1837b8300..0eccda49276eb2 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/sections/action_connector_form/action_form.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/sections/action_connector_form/action_form.tsx @@ -581,7 +581,9 @@ export const ActionForm = ({ // TODO: fix in https://github.com/elastic/kibana/issues/155993 // actionTypes with subtypes need to be updated in case they switched to a // subtype that is not the default one - actions[0].actionTypeId = savedAction.actionTypeId; + activeActionItem.indices.forEach((index: number) => { + actions[index].actionTypeId = savedAction.actionTypeId; + }); connectors.push(savedAction); const indicesToUpdate = activeActionItem.indices || []; indicesToUpdate.forEach((index: number) => setActionIdByIndex(savedAction.id, index)); diff --git a/x-pack/test/functional_with_es_ssl/apps/triggers_actions_ui/alert_create_flyout.ts b/x-pack/test/functional_with_es_ssl/apps/triggers_actions_ui/alert_create_flyout.ts index 5d11dd17695d0f..126e3b82658726 100644 --- a/x-pack/test/functional_with_es_ssl/apps/triggers_actions_ui/alert_create_flyout.ts +++ b/x-pack/test/functional_with_es_ssl/apps/triggers_actions_ui/alert_create_flyout.ts @@ -360,5 +360,53 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { await discardNewRuleCreation(); }); + + it('should not do a type override when adding a second action', async () => { + // create a new rule + const ruleName = generateUniqueKey(); + await rules.common.defineIndexThresholdAlert(ruleName); + + // add server log action + await testSubjects.click('.server-log-alerting-ActionTypeSelectOption'); + expect( + await find.existsByCssSelector( + '[data-test-subj="comboBoxSearchInput"][value="Serverlog#xyz"]' + ) + ).to.eql(true); + expect( + await find.existsByCssSelector( + '[data-test-subj="comboBoxSearchInput"][value="webhook-test"]' + ) + ).to.eql(false); + + // click on add new action + await testSubjects.click('addAlertActionButton'); + await find.existsByCssSelector('[data-test-subj="Serverlog#xyz"]'); + + // create webhook connector + await testSubjects.click('.webhook-alerting-ActionTypeSelectOption'); + await testSubjects.click('createActionConnectorButton-1'); + await testSubjects.setValue('nameInput', 'webhook-test'); + await testSubjects.setValue('webhookUrlText', 'https://test.test'); + await testSubjects.setValue('webhookUserInput', 'fakeuser'); + await testSubjects.setValue('webhookPasswordInput', 'fakepassword'); + await testSubjects.click('saveActionButtonModal'); + + // checking the new one first to avoid flakiness. If the value is checked before the new one is added + // it might return a false positive + expect( + await find.existsByCssSelector( + '[data-test-subj="comboBoxSearchInput"][value="webhook-test"]' + ) + ).to.eql(true); + // If it was overridden, the value would change to be empty + expect( + await find.existsByCssSelector( + '[data-test-subj="comboBoxSearchInput"][value="Serverlog#xyz"]' + ) + ).to.eql(true); + + await deleteConnectorByName('webhook-test'); + }); }); };