Skip to content

Commit cb0b2a2

Browse files
ref(tsc): convert organizationDeveloperSettings to FC (#83675)
relates to getsentry/frontend-tsc#2 --------- Co-authored-by: Scott Cooper <[email protected]>
1 parent 54113fa commit cb0b2a2

File tree

2 files changed

+172
-196
lines changed

2 files changed

+172
-196
lines changed

static/app/views/settings/organizationDeveloperSettings/index.spec.tsx

Lines changed: 63 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1+
import {LocationFixture} from 'sentry-fixture/locationFixture';
12
import {OrganizationFixture} from 'sentry-fixture/organization';
3+
import {RouterFixture} from 'sentry-fixture/routerFixture';
24
import {SentryAppFixture} from 'sentry-fixture/sentryApp';
35

46
import {initializeOrg} from 'sentry-test/initializeOrg';
@@ -14,7 +16,7 @@ import {
1416
import OrganizationDeveloperSettings from 'sentry/views/settings/organizationDeveloperSettings/index';
1517

1618
describe('Organization Developer Settings', function () {
17-
const {organization: org, routerProps, router} = initializeOrg();
19+
const {organization: org} = initializeOrg();
1820
const sentryApp = SentryAppFixture({
1921
scopes: [
2022
'team:read',
@@ -36,7 +38,7 @@ describe('Organization Developer Settings', function () {
3638
url: `/organizations/${org.slug}/sentry-apps/`,
3739
body: [],
3840
});
39-
render(<OrganizationDeveloperSettings {...routerProps} organization={org} />);
41+
render(<OrganizationDeveloperSettings />);
4042
await waitFor(() => {
4143
expect(
4244
screen.getByText('No internal integrations have been created yet.')
@@ -53,25 +55,21 @@ describe('Organization Developer Settings', function () {
5355
});
5456
});
5557

56-
it('internal integrations list is empty', () => {
57-
render(<OrganizationDeveloperSettings {...routerProps} organization={org} />, {
58-
organization: org,
59-
});
58+
it('internal integrations list is empty', async () => {
59+
render(<OrganizationDeveloperSettings />);
6060
expect(
61-
screen.getByText('No internal integrations have been created yet.')
61+
await screen.findByText('No internal integrations have been created yet.')
6262
).toBeInTheDocument();
6363
});
6464

65-
it('public integrations list contains 1 item', () => {
66-
render(
67-
<OrganizationDeveloperSettings
68-
{...routerProps}
69-
organization={org}
70-
location={{...router.location, query: {type: 'public'}}}
71-
/>,
72-
{organization: org}
73-
);
74-
expect(screen.getByText('Sample App')).toBeInTheDocument();
65+
it('public integrations list contains 1 item', async () => {
66+
const router = RouterFixture({
67+
location: LocationFixture({query: {type: 'public'}}),
68+
});
69+
render(<OrganizationDeveloperSettings />, {
70+
router,
71+
});
72+
expect(await screen.findByText('Sample App')).toBeInTheDocument();
7573
expect(screen.getByText('unpublished')).toBeInTheDocument();
7674
});
7775

@@ -81,13 +79,12 @@ describe('Organization Developer Settings', function () {
8179
method: 'DELETE',
8280
body: [],
8381
});
84-
render(
85-
<OrganizationDeveloperSettings
86-
{...routerProps}
87-
organization={org}
88-
location={{...router.location, query: {type: 'public'}}}
89-
/>
90-
);
82+
const router = RouterFixture({
83+
location: LocationFixture({query: {type: 'public'}}),
84+
});
85+
render(<OrganizationDeveloperSettings />, {
86+
router,
87+
});
9188

9289
const deleteButton = await screen.findByRole('button', {name: 'Delete'});
9390
expect(deleteButton).toHaveAttribute('aria-disabled', 'false');
@@ -111,14 +108,13 @@ describe('Organization Developer Settings', function () {
111108
url: `/sentry-apps/${sentryApp.slug}/publish-request/`,
112109
method: 'POST',
113110
});
111+
const router = RouterFixture({
112+
location: LocationFixture({query: {type: 'public'}}),
113+
});
114114

115-
render(
116-
<OrganizationDeveloperSettings
117-
{...routerProps}
118-
organization={org}
119-
location={{...router.location, query: {type: 'public'}}}
120-
/>
121-
);
115+
render(<OrganizationDeveloperSettings />, {
116+
router,
117+
});
122118

123119
const publishButton = await screen.findByRole('button', {name: 'Publish'});
124120

@@ -173,37 +169,34 @@ describe('Organization Developer Settings', function () {
173169
body: [publishedSentryApp],
174170
});
175171
});
176-
it('shows the published status', () => {
177-
render(
178-
<OrganizationDeveloperSettings
179-
{...routerProps}
180-
organization={org}
181-
location={{...router.location, query: {type: 'public'}}}
182-
/>
183-
);
184-
expect(screen.getByText('published')).toBeInTheDocument();
172+
it('shows the published status', async () => {
173+
const router = RouterFixture({
174+
location: LocationFixture({query: {type: 'public'}}),
175+
});
176+
render(<OrganizationDeveloperSettings />, {
177+
router,
178+
});
179+
expect(await screen.findByText('published')).toBeInTheDocument();
185180
});
186181

187182
it('trash button is disabled', async () => {
188-
render(
189-
<OrganizationDeveloperSettings
190-
{...routerProps}
191-
organization={org}
192-
location={{...router.location, query: {type: 'public'}}}
193-
/>
194-
);
183+
const router = RouterFixture({
184+
location: LocationFixture({query: {type: 'public'}}),
185+
});
186+
render(<OrganizationDeveloperSettings />, {
187+
router,
188+
});
195189
const deleteButton = await screen.findByRole('button', {name: 'Delete'});
196190
expect(deleteButton).toHaveAttribute('aria-disabled', 'true');
197191
});
198192

199193
it('publish button is disabled', async () => {
200-
render(
201-
<OrganizationDeveloperSettings
202-
{...routerProps}
203-
organization={org}
204-
location={{...router.location, query: {type: 'public'}}}
205-
/>
206-
);
194+
const router = RouterFixture({
195+
location: LocationFixture({query: {type: 'public'}}),
196+
});
197+
render(<OrganizationDeveloperSettings />, {
198+
router,
199+
});
207200
const publishButton = await screen.findByRole('button', {name: 'Publish'});
208201
expect(publishButton).toHaveAttribute('aria-disabled', 'true');
209202
});
@@ -220,13 +213,13 @@ describe('Organization Developer Settings', function () {
220213
});
221214

222215
it('allows deleting', async () => {
223-
render(<OrganizationDeveloperSettings {...routerProps} organization={org} />);
216+
render(<OrganizationDeveloperSettings />);
224217
const deleteButton = await screen.findByRole('button', {name: 'Delete'});
225218
expect(deleteButton).toHaveAttribute('aria-disabled', 'false');
226219
});
227220

228221
it('publish button does not exist', () => {
229-
render(<OrganizationDeveloperSettings {...routerProps} organization={org} />);
222+
render(<OrganizationDeveloperSettings />);
230223
expect(screen.queryByText('Publish')).not.toBeInTheDocument();
231224
});
232225
});
@@ -240,27 +233,25 @@ describe('Organization Developer Settings', function () {
240233
});
241234
});
242235
it('trash button is disabled', async () => {
243-
render(
244-
<OrganizationDeveloperSettings
245-
{...routerProps}
246-
organization={newOrg}
247-
location={{...router.location, query: {type: 'public'}}}
248-
/>,
249-
{organization: newOrg}
250-
);
236+
const router = RouterFixture({
237+
location: LocationFixture({query: {type: 'public'}}),
238+
});
239+
render(<OrganizationDeveloperSettings />, {
240+
router,
241+
organization: newOrg,
242+
});
251243
const deleteButton = await screen.findByRole('button', {name: 'Delete'});
252244
expect(deleteButton).toHaveAttribute('aria-disabled', 'true');
253245
});
254246

255247
it('publish button is disabled', async () => {
256-
render(
257-
<OrganizationDeveloperSettings
258-
{...routerProps}
259-
organization={newOrg}
260-
location={{...router.location, query: {type: 'public'}}}
261-
/>,
262-
{organization: newOrg}
263-
);
248+
const router = RouterFixture({
249+
location: LocationFixture({query: {type: 'public'}}),
250+
});
251+
render(<OrganizationDeveloperSettings />, {
252+
organization: newOrg,
253+
router,
254+
});
264255
const publishButton = await screen.findByRole('button', {name: 'Publish'});
265256
expect(publishButton).toHaveAttribute('aria-disabled', 'true');
266257
});

0 commit comments

Comments
 (0)