-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(feedback): Remove duplicate assignment request (#83669)
- Loading branch information
1 parent
fdca387
commit 9c1efc8
Showing
5 changed files
with
117 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
93 changes: 93 additions & 0 deletions
93
static/app/components/feedback/feedbackItem/feedbackAssignedTo.spec.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
import {EventFixture} from 'sentry-fixture/event'; | ||
import {FeedbackIssueFixture} from 'sentry-fixture/feedbackIssue'; | ||
import {MemberFixture} from 'sentry-fixture/member'; | ||
import {OrganizationFixture} from 'sentry-fixture/organization'; | ||
import {ProjectFixture} from 'sentry-fixture/project'; | ||
import {UserFixture} from 'sentry-fixture/user'; | ||
|
||
import {render, screen, userEvent, waitFor} from 'sentry-test/reactTestingLibrary'; | ||
|
||
import MemberListStore from 'sentry/stores/memberListStore'; | ||
import type {Group} from 'sentry/types/group'; | ||
|
||
import FeedbackAssignedTo from './feedbackAssignedTo'; | ||
|
||
describe('FeedbackAssignedTo', () => { | ||
const user = UserFixture(); | ||
const organization = OrganizationFixture(); | ||
const feedbackIssue = FeedbackIssueFixture({}) as unknown as Group; | ||
const feedbackEvent = EventFixture(); | ||
const project = ProjectFixture(); | ||
|
||
beforeEach(() => { | ||
MemberListStore.reset(); | ||
|
||
MockApiClient.addMockResponse({ | ||
url: `/organizations/${organization.slug}/users/`, | ||
body: [MemberFixture({user})], | ||
}); | ||
MockApiClient.addMockResponse({ | ||
url: `/projects/${organization.slug}/${project.slug}/events/${feedbackEvent.id}/owners/`, | ||
body: { | ||
owners: [], | ||
rules: [], | ||
}, | ||
}); | ||
}); | ||
|
||
it('should assign to user', async () => { | ||
const assignMock = MockApiClient.addMockResponse({ | ||
method: 'PUT', | ||
url: `/organizations/${organization.slug}/issues/${feedbackIssue.id}/`, | ||
body: {...feedbackIssue, assignedTo: {id: user.id, type: 'user', name: user.name}}, | ||
}); | ||
|
||
render( | ||
<FeedbackAssignedTo feedbackIssue={feedbackIssue} feedbackEvent={feedbackEvent} /> | ||
); | ||
|
||
await userEvent.click(await screen.findByLabelText('Modify issue assignee')); | ||
await userEvent.click(screen.getByText(`${user.name} (You)`)); | ||
|
||
await waitFor(() => | ||
expect(assignMock).toHaveBeenLastCalledWith( | ||
`/organizations/${organization.slug}/issues/${feedbackIssue.id}/`, | ||
expect.objectContaining({ | ||
data: {assignedTo: `user:${user.id}`, assignedBy: 'assignee_selector'}, | ||
}) | ||
) | ||
); | ||
expect(assignMock).toHaveBeenCalledTimes(1); | ||
}); | ||
|
||
it('should clear assignee', async () => { | ||
const assignMock = MockApiClient.addMockResponse({ | ||
method: 'PUT', | ||
url: `/organizations/${organization.slug}/issues/${feedbackIssue.id}/`, | ||
body: {...feedbackIssue, assignedTo: null}, | ||
}); | ||
|
||
render( | ||
<FeedbackAssignedTo | ||
feedbackIssue={{ | ||
...feedbackIssue, | ||
assignedTo: {id: user.id, type: 'user', name: user.name}, | ||
}} | ||
feedbackEvent={feedbackEvent} | ||
/> | ||
); | ||
|
||
await userEvent.click(await screen.findByLabelText('Modify issue assignee')); | ||
await userEvent.click(await screen.findByRole('button', {name: 'Clear'})); | ||
|
||
await waitFor(() => | ||
expect(assignMock).toHaveBeenLastCalledWith( | ||
`/organizations/${organization.slug}/issues/${feedbackIssue.id}/`, | ||
expect.objectContaining({ | ||
data: {assignedBy: 'assignee_selector', assignedTo: ''}, | ||
}) | ||
) | ||
); | ||
expect(assignMock).toHaveBeenCalledTimes(1); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters