Skip to content

Commit 2d0700d

Browse files
authored
test(issues): Migrate issue detail tests from deprecatedRouterMocks to initialRouterConfig (#102725)
1 parent 8661b45 commit 2d0700d

File tree

5 files changed

+62
-58
lines changed

5 files changed

+62
-58
lines changed

static/app/views/issueDetails/groupActivity.spec.tsx

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import {OrganizationFixture} from 'sentry-fixture/organization';
33
import {ProjectFixture} from 'sentry-fixture/project';
44
import {ReleaseFixture} from 'sentry-fixture/release';
55
import {RepositoryFixture} from 'sentry-fixture/repository';
6-
import {RouterFixture} from 'sentry-fixture/routerFixture';
76
import {TeamFixture} from 'sentry-fixture/team';
87
import {UserFixture} from 'sentry-fixture/user';
98

@@ -13,6 +12,7 @@ import {
1312
screen,
1413
userEvent,
1514
waitFor,
15+
type RouterConfig,
1616
} from 'sentry-test/reactTestingLibrary';
1717

1818
import ConfigStore from 'sentry/stores/configStore';
@@ -66,9 +66,12 @@ describe('GroupActivity', () => {
6666
GroupStore.add([group]);
6767
// XXX: Explicitly using legacy UI since this component is not used in the new one
6868
const organization = OrganizationFixture({streamlineOnly: false});
69-
const router = RouterFixture({
70-
params: {orgId: organization.slug, groupId: group.id},
71-
});
69+
const initialRouterConfig: RouterConfig = {
70+
location: {
71+
pathname: `/organizations/${organization.slug}/issues/${group.id}/activity/`,
72+
},
73+
route: `/organizations/:orgId/issues/:groupId/activity/`,
74+
};
7275

7376
MockApiClient.addMockResponse({
7477
url: `/organizations/${organization.slug}/issues/${group.id}/`,
@@ -78,9 +81,8 @@ describe('GroupActivity', () => {
7881
TeamStore.loadInitialData([TeamFixture({id: '999', slug: 'no-team'})]);
7982
OrganizationStore.onUpdate(organization, {replace: true});
8083
render(<GroupActivity />, {
81-
router,
8284
organization,
83-
deprecatedRouterMocks: true,
85+
initialRouterConfig,
8486
});
8587
}
8688

static/app/views/issueDetails/groupCheckIns.spec.tsx

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@ import {EventFixture} from 'sentry-fixture/event';
33
import {GroupFixture} from 'sentry-fixture/group';
44
import {OrganizationFixture} from 'sentry-fixture/organization';
55
import {ProjectFixture} from 'sentry-fixture/project';
6-
import {RouterFixture} from 'sentry-fixture/routerFixture';
76

8-
import {render, screen} from 'sentry-test/reactTestingLibrary';
7+
import {render, screen, type RouterConfig} from 'sentry-test/reactTestingLibrary';
98

109
import GroupStore from 'sentry/stores/groupStore';
1110
import {IssueCategory, IssueType} from 'sentry/types/group';
@@ -29,7 +28,12 @@ describe('GroupCheckIns', () => {
2928
project,
3029
});
3130
const organization = OrganizationFixture();
32-
const router = RouterFixture({params: {groupId: group.id}});
31+
const initialRouterConfig: RouterConfig = {
32+
location: {
33+
pathname: `/organizations/${organization.slug}/issues/${group.id}/check-ins/`,
34+
},
35+
route: `/organizations/:orgId/issues/:groupId/check-ins/`,
36+
};
3337

3438
beforeEach(() => {
3539
GroupStore.init();
@@ -53,8 +57,7 @@ describe('GroupCheckIns', () => {
5357

5458
render(<GroupCheckIns />, {
5559
organization,
56-
router,
57-
deprecatedRouterMocks: true,
60+
initialRouterConfig,
5861
});
5962
expect(await screen.findByText('All Check-Ins')).toBeInTheDocument();
6063
expect(
@@ -71,8 +74,7 @@ describe('GroupCheckIns', () => {
7174

7275
render(<GroupCheckIns />, {
7376
organization,
74-
router,
75-
deprecatedRouterMocks: true,
77+
initialRouterConfig,
7678
});
7779
expect(await screen.findByText('All Check-Ins')).toBeInTheDocument();
7880
expect(screen.queryByText('No matching check-ins found')).not.toBeInTheDocument();

static/app/views/issueDetails/groupEventAttachments/groupEventAttachments.spec.tsx

Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
11
import {EnvironmentsFixture} from 'sentry-fixture/environments';
22
import {EventAttachmentFixture} from 'sentry-fixture/eventAttachment';
33
import {GroupFixture} from 'sentry-fixture/group';
4+
import {OrganizationFixture} from 'sentry-fixture/organization';
45
import {ProjectFixture} from 'sentry-fixture/project';
56
import {TagsFixture} from 'sentry-fixture/tags';
67
import {UserFixture} from 'sentry-fixture/user';
78

8-
import {initializeOrg} from 'sentry-test/initializeOrg';
99
import {
1010
act,
1111
render,
1212
renderGlobalModal,
1313
screen,
1414
userEvent,
1515
within,
16+
type RouterConfig,
1617
} from 'sentry-test/reactTestingLibrary';
1718

1819
import ConfigStore from 'sentry/stores/configStore';
@@ -25,19 +26,24 @@ import GroupEventAttachments from './groupEventAttachments';
2526
describe('GroupEventAttachments', () => {
2627
const groupId = 'group-id';
2728
const group = GroupFixture({id: groupId});
28-
const {organization, router} = initializeOrg({
29-
organization: {
30-
features: ['event-attachments'],
31-
orgRole: 'member',
32-
attachmentsRole: 'member',
33-
},
29+
const organization = OrganizationFixture({
30+
features: ['event-attachments'],
31+
orgRole: 'member',
32+
attachmentsRole: 'member',
3433
});
35-
const {router: screenshotRouter} = initializeOrg({
36-
router: {
37-
params: {orgId: 'org-slug', groupId: 'group-id'},
38-
location: {query: {attachmentFilter: 'screenshot'}},
34+
const initialRouterConfig: RouterConfig = {
35+
location: {
36+
pathname: `/organizations/${organization.slug}/issues/${groupId}/attachments/`,
3937
},
40-
});
38+
route: `/organizations/:orgId/issues/:groupId/attachments/`,
39+
};
40+
const screenshotRouterConfig: RouterConfig = {
41+
location: {
42+
pathname: `/organizations/${organization.slug}/issues/${groupId}/attachments/`,
43+
query: {attachmentFilter: 'screenshot'},
44+
},
45+
route: `/organizations/:orgId/issues/:groupId/attachments/`,
46+
};
4147
let project: Project;
4248
let getAttachmentsMock: jest.Mock;
4349

@@ -67,9 +73,8 @@ describe('GroupEventAttachments', () => {
6773

6874
it('calls attachments api with screenshot filter', async () => {
6975
render(<GroupEventAttachments project={project} group={group} />, {
70-
router: screenshotRouter,
7176
organization,
72-
deprecatedRouterMocks: true,
77+
initialRouterConfig: screenshotRouterConfig,
7378
});
7479
expect(screen.getByRole('radio', {name: 'Screenshots'})).toBeInTheDocument();
7580
await userEvent.click(screen.getByRole('radio', {name: 'Screenshots'}));
@@ -87,9 +92,8 @@ describe('GroupEventAttachments', () => {
8792

8893
it('calls opens modal when clicking on panel body', async () => {
8994
render(<GroupEventAttachments project={project} group={group} />, {
90-
router: screenshotRouter,
9195
organization,
92-
deprecatedRouterMocks: true,
96+
initialRouterConfig: screenshotRouterConfig,
9397
});
9498
renderGlobalModal();
9599
await userEvent.click(await screen.findByTestId('screenshot-1'));
@@ -98,9 +102,8 @@ describe('GroupEventAttachments', () => {
98102

99103
it('links event id to event detail', async () => {
100104
render(<GroupEventAttachments project={project} group={group} />, {
101-
router,
102105
organization,
103-
deprecatedRouterMocks: true,
106+
initialRouterConfig,
104107
});
105108
expect(await screen.findByRole('link', {name: '12345678'})).toHaveAttribute(
106109
'href',
@@ -110,9 +113,8 @@ describe('GroupEventAttachments', () => {
110113

111114
it('links to the download URL', async () => {
112115
render(<GroupEventAttachments project={project} group={group} />, {
113-
router: screenshotRouter,
114116
organization,
115-
deprecatedRouterMocks: true,
117+
initialRouterConfig: screenshotRouterConfig,
116118
});
117119
await userEvent.click(await screen.findByLabelText('Actions'));
118120
expect(
@@ -126,9 +128,8 @@ describe('GroupEventAttachments', () => {
126128
statusCode: 500,
127129
});
128130
render(<GroupEventAttachments project={project} group={group} />, {
129-
router,
130131
organization,
131-
deprecatedRouterMocks: true,
132+
initialRouterConfig,
132133
});
133134
expect(await screen.findByText(/error loading/i)).toBeInTheDocument();
134135
});
@@ -139,9 +140,8 @@ describe('GroupEventAttachments', () => {
139140
method: 'DELETE',
140141
});
141142
render(<GroupEventAttachments project={project} group={group} />, {
142-
router,
143143
organization,
144-
deprecatedRouterMocks: true,
144+
initialRouterConfig,
145145
});
146146
renderGlobalModal();
147147

@@ -169,13 +169,14 @@ describe('GroupEventAttachments', () => {
169169
render(<GroupEventAttachments project={project} group={group} />, {
170170
initialRouterConfig: {
171171
location: {
172-
pathname: '/organizations/org-slug/issues/group-id/',
172+
pathname: `/organizations/${organization.slug}/issues/${groupId}/attachments/`,
173173
query: {
174174
statsPeriod: '3d',
175175
query: 'user.email:[email protected]',
176176
environment: ['staging'],
177177
},
178178
},
179+
route: `/organizations/:orgId/issues/:groupId/attachments/`,
179180
},
180181
organization: {...organization, features: ['issue-details-streamline-enforce']},
181182
});

static/app/views/issueDetails/groupUptimeChecks.spec.tsx

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,9 @@ import {EventFixture} from 'sentry-fixture/event';
33
import {GroupFixture} from 'sentry-fixture/group';
44
import {OrganizationFixture} from 'sentry-fixture/organization';
55
import {ProjectFixture} from 'sentry-fixture/project';
6-
import {RouterFixture} from 'sentry-fixture/routerFixture';
76
import {UptimeCheckFixture} from 'sentry-fixture/uptimeCheck';
87

9-
import {render, screen} from 'sentry-test/reactTestingLibrary';
8+
import {render, screen, type RouterConfig} from 'sentry-test/reactTestingLibrary';
109

1110
import GroupStore from 'sentry/stores/groupStore';
1211
import PageFiltersStore from 'sentry/stores/pageFiltersStore';
@@ -29,9 +28,12 @@ describe('GroupUptimeChecks', () => {
2928
});
3029
const organization = OrganizationFixture();
3130
const project = ProjectFixture();
32-
const router = RouterFixture({
33-
params: {groupId: group.id},
34-
});
31+
const initialRouterConfig: RouterConfig = {
32+
location: {
33+
pathname: `/organizations/${organization.slug}/issues/${group.id}/uptime-checks/`,
34+
},
35+
route: `/organizations/:orgId/issues/:groupId/uptime-checks/`,
36+
};
3537

3638
beforeEach(() => {
3739
GroupStore.init();
@@ -66,8 +68,7 @@ describe('GroupUptimeChecks', () => {
6668

6769
render(<GroupUptimeChecks />, {
6870
organization,
69-
router,
70-
deprecatedRouterMocks: true,
71+
initialRouterConfig,
7172
});
7273
expect(await screen.findByText('All Uptime Checks')).toBeInTheDocument();
7374
for (const column of ['Timestamp', 'Status', 'Duration', 'Trace', 'Region']) {
@@ -93,8 +94,7 @@ describe('GroupUptimeChecks', () => {
9394

9495
render(<GroupUptimeChecks />, {
9596
organization,
96-
router,
97-
deprecatedRouterMocks: true,
97+
initialRouterConfig,
9898
});
9999
expect(await screen.findByText('All Uptime Checks')).toBeInTheDocument();
100100
expect(screen.queryByText('No matching uptime checks found')).not.toBeInTheDocument();
@@ -129,8 +129,7 @@ describe('GroupUptimeChecks', () => {
129129

130130
render(<GroupUptimeChecks />, {
131131
organization,
132-
router,
133-
deprecatedRouterMocks: true,
132+
initialRouterConfig,
134133
});
135134
expect(await screen.findByText('All Uptime Checks')).toBeInTheDocument();
136135

static/app/views/issueDetails/groupUserFeedback.spec.tsx

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
import {GroupFixture} from 'sentry-fixture/group';
22
import {OrganizationFixture} from 'sentry-fixture/organization';
33
import {ProjectFixture} from 'sentry-fixture/project';
4-
import {RouterFixture} from 'sentry-fixture/routerFixture';
54

6-
import {render, screen} from 'sentry-test/reactTestingLibrary';
5+
import {render, screen, type RouterConfig} from 'sentry-test/reactTestingLibrary';
76

87
import ProjectsStore from 'sentry/stores/projectsStore';
98

@@ -13,9 +12,12 @@ describe('GroupUserFeedback', () => {
1312
const group = GroupFixture();
1413
const organization = OrganizationFixture();
1514
const project = ProjectFixture();
16-
const router = RouterFixture({
17-
params: {groupId: group.id},
18-
});
15+
const initialRouterConfig: RouterConfig = {
16+
location: {
17+
pathname: `/organizations/${organization.slug}/issues/${group.id}/`,
18+
},
19+
route: `/organizations/:orgId/issues/:groupId/`,
20+
};
1921

2022
beforeEach(() => {
2123
ProjectsStore.init();
@@ -35,8 +37,7 @@ describe('GroupUserFeedback', () => {
3537

3638
render(<GroupUserFeedback />, {
3739
organization,
38-
router,
39-
deprecatedRouterMocks: true,
40+
initialRouterConfig,
4041
});
4142
expect(
4243
await screen.findByRole('heading', {
@@ -74,8 +75,7 @@ describe('GroupUserFeedback', () => {
7475

7576
render(<GroupUserFeedback />, {
7677
organization,
77-
router,
78-
deprecatedRouterMocks: true,
78+
initialRouterConfig,
7979
});
8080
expect(await screen.findByText('Test User')).toBeInTheDocument();
8181
expect(await screen.findByText('custom comment')).toBeInTheDocument();

0 commit comments

Comments
 (0)