Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,7 @@ export default typescript.config([
plugins: {'@sentry': sentryPlugin},
rules: {
'@sentry/no-static-translations': 'error',
'@sentry/no-renderHook-arrow-function': 'error',
},
},
{
Expand Down
15 changes: 7 additions & 8 deletions static/app/actionCreators/savedSearches.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,13 @@ describe('useFetchRecentSearches', () => {
],
});

const {result} = renderHookWithProviders(
() =>
useFetchRecentSearches({
savedSearchType: SavedSearchType.TRACEMETRIC,
namespace,
}),
{organization}
);
const {result} = renderHookWithProviders(useFetchRecentSearches, {
organization,
initialProps: {
savedSearchType: SavedSearchType.TRACEMETRIC,
namespace,
},
});

await waitFor(() => expect(result.current.isSuccess).toBe(true));

Expand Down
43 changes: 32 additions & 11 deletions static/app/bootstrap/boostrapRequests.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,10 @@ describe('useBootstrapOrganizationQuery', () => {
query: {detailed: 0, include_feature_flags: 1},
});

const {result} = renderHook(() => useBootstrapOrganizationQuery(orgSlug), {wrapper});
const {result} = renderHook(useBootstrapOrganizationQuery, {
wrapper,
initialProps: orgSlug,
});

await waitFor(() => expect(result.current.data).toBeDefined());
expect(JSON.stringify(OrganizationStore.get().organization)).toEqual(
Expand All @@ -64,7 +67,10 @@ describe('useBootstrapOrganizationQuery', () => {
body: {},
});

const {result} = renderHook(() => useBootstrapOrganizationQuery(orgSlug), {wrapper});
const {result} = renderHook(useBootstrapOrganizationQuery, {
wrapper,
initialProps: orgSlug,
});

await waitFor(() => expect(result.current.error).toBeDefined());
expect(OrganizationStore.get().organization).toBeNull();
Expand All @@ -75,7 +81,10 @@ describe('useBootstrapOrganizationQuery', () => {
});

it('does not fetch when orgSlug is null', () => {
const {result} = renderHook(() => useBootstrapOrganizationQuery(null), {wrapper});
const {result} = renderHook(useBootstrapOrganizationQuery, {
wrapper,
initialProps: null,
});
expect(result.current.data).toBeUndefined();
});

Expand All @@ -84,7 +93,10 @@ describe('useBootstrapOrganizationQuery', () => {
orgSlug: org.slug,
organization: Promise.resolve<ApiResult<Organization>>([org, undefined, undefined]),
};
const {result} = renderHook(() => useBootstrapOrganizationQuery(orgSlug), {wrapper});
const {result} = renderHook(useBootstrapOrganizationQuery, {
wrapper,
initialProps: orgSlug,
});
await waitFor(() => expect(result.current.data).toBeDefined());
expect(window.__sentry_preload?.organization).toBeUndefined();
});
Expand All @@ -105,7 +117,10 @@ describe('useBootstrapOrganizationQuery', () => {
query: {detailed: 0, include_feature_flags: 1},
});

const {result} = renderHook(() => useBootstrapOrganizationQuery(orgSlug), {wrapper});
const {result} = renderHook(useBootstrapOrganizationQuery, {
wrapper,
initialProps: orgSlug,
});
await waitFor(() => expect(result.current.data).toBeDefined());
expect(JSON.stringify(OrganizationStore.get().organization?.features)).toEqual(
JSON.stringify(['enable-issues'])
Expand Down Expand Up @@ -141,7 +156,7 @@ describe('useBootstrapTeamsQuery', () => {
},
});

const {result} = renderHook(() => useBootstrapTeamsQuery(orgSlug), {wrapper});
const {result} = renderHook(useBootstrapTeamsQuery, {wrapper, initialProps: orgSlug});

await waitFor(() => expect(result.current.data).toBeDefined());
expect(TeamStore.getState().teams).toEqual(mockTeams);
Expand All @@ -154,14 +169,14 @@ describe('useBootstrapTeamsQuery', () => {
statusCode: 500,
});

const {result} = renderHook(() => useBootstrapTeamsQuery(orgSlug), {wrapper});
const {result} = renderHook(useBootstrapTeamsQuery, {wrapper, initialProps: orgSlug});

await waitFor(() => expect(result.current.error).toBeDefined());
expect(TeamStore.getState().teams).toEqual([]);
});

it('does not fetch when orgSlug is null', () => {
const {result} = renderHook(() => useBootstrapTeamsQuery(null), {wrapper});
const {result} = renderHook(useBootstrapTeamsQuery, {wrapper, initialProps: null});
expect(result.current.data).toBeUndefined();
});
});
Expand All @@ -186,7 +201,10 @@ describe('useBootstrapProjectsQuery', () => {
},
});

const {result} = renderHook(() => useBootstrapProjectsQuery(orgSlug), {wrapper});
const {result} = renderHook(useBootstrapProjectsQuery, {
wrapper,
initialProps: orgSlug,
});

await waitFor(() => expect(result.current.data).toBeDefined());
expect(ProjectsStore.getState().projects).toEqual(mockProjects);
Expand All @@ -198,14 +216,17 @@ describe('useBootstrapProjectsQuery', () => {
statusCode: 500,
});

const {result} = renderHook(() => useBootstrapProjectsQuery(orgSlug), {wrapper});
const {result} = renderHook(useBootstrapProjectsQuery, {
wrapper,
initialProps: orgSlug,
});

await waitFor(() => expect(result.current.error).toBeDefined());
expect(ProjectsStore.getState().projects).toEqual([]);
});

it('does not fetch when orgSlug is null', () => {
const {result} = renderHook(() => useBootstrapProjectsQuery(null), {wrapper});
const {result} = renderHook(useBootstrapProjectsQuery, {wrapper, initialProps: null});
expect(result.current.data).toBeUndefined();
});
});
12 changes: 8 additions & 4 deletions static/app/components/acl/useRole.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ describe('useRole', () => {
});

it('has a sufficient role', () => {
const {result} = renderHookWithProviders(() => useRole({role: 'attachmentsRole'}), {
const {result} = renderHookWithProviders(useRole, {
organization,
initialProps: {role: 'attachmentsRole'},
});
expect(result.current.hasRole).toBe(true);
expect(result.current.roleRequired).toBe('admin');
Expand All @@ -37,8 +38,9 @@ describe('useRole', () => {
orgRole: 'member',
});
OrganizationStore.onUpdate(org, {replace: true});
const {result} = renderHookWithProviders(() => useRole({role: 'attachmentsRole'}), {
const {result} = renderHookWithProviders(useRole, {
organization: org,
initialProps: {role: 'attachmentsRole'},
});
expect(result.current.hasRole).toBe(false);
});
Expand All @@ -50,17 +52,19 @@ describe('useRole', () => {
access: ['org:superuser'],
});
OrganizationStore.onUpdate(org, {replace: true});
const {result} = renderHookWithProviders(() => useRole({role: 'attachmentsRole'}), {
const {result} = renderHookWithProviders(useRole, {
organization: org,
initialProps: {role: 'attachmentsRole'},
});
expect(result.current.hasRole).toBe(true);
});

it('handles no organization.orgRoleList', () => {
const org = {...organization, orgRoleList: []};
OrganizationStore.onUpdate(org, {replace: true});
const {result} = renderHookWithProviders(() => useRole({role: 'attachmentsRole'}), {
const {result} = renderHookWithProviders(useRole, {
organization: org,
initialProps: {role: 'attachmentsRole'},
});
expect(result.current.hasRole).toBe(false);
});
Expand Down
Loading
Loading