diff --git a/CHANGELOG.md b/CHANGELOG.md index 4621c54b..9b1fe8a6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Unify naming of Grafana Cloud / Cloud OnCall / Grafana Cloud OnCall so that it's always Grafana Cloud OnCall ([#3279](https://github.com/grafana/oncall/pull/3279)) +### Fixed + +- Fix escalation policy importance going back to default by @vadimkerr ([#3282](https://github.com/grafana/oncall/pull/3282)) + ## v1.3.54 (2023-11-06) ### Added diff --git a/grafana-plugin/e2e-tests/escalationChains/escalationPolicy.test.ts b/grafana-plugin/e2e-tests/escalationChains/escalationPolicy.test.ts new file mode 100644 index 00000000..44679b11 --- /dev/null +++ b/grafana-plugin/e2e-tests/escalationChains/escalationPolicy.test.ts @@ -0,0 +1,19 @@ +import {expect, test} from "../fixtures"; +import {generateRandomValue} from "../utils/forms"; +import {createEscalationChain, EscalationStep, selectEscalationStepValue} from "../utils/escalationChain"; + +test('escalation policy does not go back to "Default" after adding users to notify', async ({ adminRolePage }) => { + const { page, userName } = adminRolePage; + const escalationChainName = generateRandomValue(); + + // create important escalation step + await createEscalationChain(page, escalationChainName, EscalationStep.NotifyUsers, null, true); + // add user to notify + await selectEscalationStepValue(page, EscalationStep.NotifyUsers, userName); + + // reload and check if important is still selected + await page.reload(); + await page.waitForLoadState('networkidle'); + + expect(await page.locator('text=Important').isVisible()).toBe(true); +}); diff --git a/grafana-plugin/e2e-tests/utils/escalationChain.ts b/grafana-plugin/e2e-tests/utils/escalationChain.ts index a0f908e4..c24c5afb 100644 --- a/grafana-plugin/e2e-tests/utils/escalationChain.ts +++ b/grafana-plugin/e2e-tests/utils/escalationChain.ts @@ -17,7 +17,8 @@ export const createEscalationChain = async ( page: Page, escalationChainName: string, escalationStep?: EscalationStep, - escalationStepValue?: string + escalationStepValue?: string, + important?: boolean ): Promise => { // go to the escalation chains page await goToOnCallPage(page, 'escalations'); @@ -40,18 +41,32 @@ export const createEscalationChain = async ( await clickButton({ page, buttonText: 'Create' }); await expect(page.getByTestId('escalation-chain-name')).toHaveText(escalationChainName); - if (!escalationStep || !escalationStepValue) { - return; + if (escalationStep) { + // add an escalation step + await selectDropdownValue({ + page, selectType: 'grafanaSelect', placeholderText: 'Add escalation step...', value: escalationStep, + }); + + // toggle important + if (important) { + await selectDropdownValue({ + page, + selectType: 'grafanaSelect', + placeholderText: "Default", + value: "Important", + }); + } + + // select the escalation step value (e.g. user or schedule) + if (escalationStepValue) {await selectEscalationStepValue(page, escalationStep, escalationStepValue);} } +}; - // add an escalation step - await selectDropdownValue({ - page, - selectType: 'grafanaSelect', - placeholderText: 'Add escalation step...', - value: escalationStep, - }); - +export const selectEscalationStepValue = async ( + page: Page, + escalationStep: EscalationStep, + escalationStepValue: string +): Promise => { await selectDropdownValue({ page, selectType: 'grafanaSelect', diff --git a/grafana-plugin/src/models/escalation_policy/escalation_policy.helpers.ts b/grafana-plugin/src/models/escalation_policy/escalation_policy.helpers.ts index e8cb6b53..95fe7445 100644 --- a/grafana-plugin/src/models/escalation_policy/escalation_policy.helpers.ts +++ b/grafana-plugin/src/models/escalation_policy/escalation_policy.helpers.ts @@ -3,5 +3,5 @@ import { pick } from 'lodash-es'; import { EscalationPolicy } from './escalation_policy.types'; export function prepareEscalationPolicy(value: EscalationPolicy) { - return pick(value, ['step']); + return pick(value, ['step', 'important']); }