Skip to content

Commit 3e39cd4

Browse files
priscilawebdevJesse-Box
authored andcommitted
fix(project-creation): Discord and MSTeams notifications should send channel id instead of name (#103146)
Contributes to https://linear.app/getsentry/issue/TET-1369/user-confusion-when-project-creation-fails-but-succeeds
1 parent fb0cd95 commit 3e39cd4

File tree

2 files changed

+47
-9
lines changed

2 files changed

+47
-9
lines changed

static/app/views/projectInstall/messagingIntegrationAlertRule.spec.tsx

Lines changed: 36 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -149,12 +149,12 @@ describe('MessagingIntegrationAlertRule', () => {
149149
/>
150150
);
151151
await selectEvent.openMenu(screen.getByLabelText('channel'));
152-
expect(await screen.findByText('#alerts')).toBeInTheDocument();
153-
expect(screen.getByText('#general')).toBeInTheDocument();
154-
await selectEvent.select(screen.getByLabelText('channel'), '#alerts');
152+
expect(await screen.findByText('#general (1)')).toBeInTheDocument();
153+
expect(screen.getByText('#alerts (2)')).toBeInTheDocument();
154+
await selectEvent.select(screen.getByLabelText('channel'), /#alerts/);
155155
expect(mockSetChannel).toHaveBeenCalledWith({
156-
label: '#alerts',
157-
value: '#alerts',
156+
label: '#alerts (2)',
157+
value: '2',
158158
new: false,
159159
});
160160
});
@@ -357,4 +357,35 @@ describe('MessagingIntegrationAlertRule', () => {
357357

358358
spy.mockRestore();
359359
});
360+
361+
it('displays and sends channel id for microsoft teams', async () => {
362+
MockApiClient.addMockResponse({
363+
url: `/organizations/${organization.slug}/integrations/${msteamsIntegrations[0]!.id}/channels/`,
364+
body: {
365+
nextCursor: null,
366+
results: [
367+
{id: '1', name: 'general', display: '#general', type: 'text'},
368+
{id: '2', name: 'alerts', display: '#alerts', type: 'text'},
369+
],
370+
},
371+
});
372+
render(
373+
<MessagingIntegrationAlertRule
374+
{...{
375+
...notificationProps,
376+
integration: msteamsIntegrations[0],
377+
provider: 'msteams',
378+
}}
379+
/>
380+
);
381+
await selectEvent.openMenu(screen.getByLabelText('channel'));
382+
expect(await screen.findByText('#general (1)')).toBeInTheDocument();
383+
expect(screen.getByText('#alerts (2)')).toBeInTheDocument();
384+
await selectEvent.select(screen.getByLabelText('channel'), /#alerts/);
385+
expect(mockSetChannel).toHaveBeenCalledWith({
386+
label: '#alerts (2)',
387+
value: '2',
388+
new: false,
389+
});
390+
});
360391
});

static/app/views/projectInstall/messagingIntegrationAlertRule.tsx

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,10 +115,17 @@ export default function MessagingIntegrationAlertRule({
115115
providerDetails[provider as keyof typeof providerDetails]?.placeholder
116116
}
117117
isSearchable
118-
options={channels?.results.map(ch => ({
119-
label: ch.display,
120-
value: ch.display,
121-
}))}
118+
options={channels?.results.map(ch =>
119+
provider === 'slack'
120+
? {
121+
label: ch.display,
122+
value: ch.display,
123+
}
124+
: {
125+
label: `${ch.display} (${ch.id})`,
126+
value: ch.id,
127+
}
128+
)}
122129
isLoading={isPending || validateChannel.isFetching}
123130
disabled={!integration}
124131
value={channel ? {label: channel.label, value: channel.value} : undefined}

0 commit comments

Comments
 (0)