Skip to content

Commit f0c23dc

Browse files
leeandherandrewshie-sentry
authored andcommitted
feat(alerts): Allow test notifications to include titles (#87871)
Some notifications may change their content depending on the title of the alert. This is the case for PagerDuty as per the change in #87786. For users to better understand what they can expect when using the test notification button, if they've set up an alert name we should use it, that way it'll appear in the test notification as well. If the user is setting up an issue alert for the first time, the test notification will use the label `Test Alert` (per the change here #87786 -- not included in this PR)
1 parent 399a850 commit f0c23dc

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

static/app/views/alerts/rules/issue/index.spec.tsx

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,30 @@ describe('IssueRuleEditor', function () {
193193
expect(await screen.findByLabelText('Save Rule')).toBeEnabled();
194194
expect(screen.queryByTestId('project-permission-alert')).not.toBeInTheDocument();
195195
});
196+
197+
it('allows test notifications', async () => {
198+
const {organization, project} = createWrapper();
199+
const mockTestNotification = MockApiClient.addMockResponse({
200+
url: `/projects/${organization.slug}/${project.slug}/rule-actions/`,
201+
method: 'POST',
202+
body: {},
203+
});
204+
await userEvent.click(screen.getByText('Send Test Notification'));
205+
expect(mockTestNotification).toHaveBeenCalledWith(
206+
`/projects/${organization.slug}/${project.slug}/rule-actions/`,
207+
expect.objectContaining({
208+
data: {
209+
actions: [
210+
{
211+
id: 'sentry.rules.actions.notify_event.NotifyEventAction',
212+
name: 'Send a notification (for all legacy integrations)',
213+
},
214+
],
215+
name: 'My alert rule',
216+
},
217+
})
218+
);
219+
});
196220
});
197221

198222
describe('Edit Rule', function () {

static/app/views/alerts/rules/issue/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -433,6 +433,7 @@ class IssueRuleEditor extends DeprecatedAsyncComponent<Props, State> {
433433
method: 'POST',
434434
data: {
435435
actions: rule?.actions ?? [],
436+
name: rule?.name,
436437
},
437438
})
438439
.then(() => {

0 commit comments

Comments
 (0)