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

[MGMTEX] Fix action data override when adding a second action #181604

Merged
merged 2 commits into from
Apr 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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 @@ -639,7 +639,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));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -340,5 +340,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');
});
});
};