Skip to content

Commit

Permalink
ref(userfeedback): convert test to tsx (#52038)
Browse files Browse the repository at this point in the history
  • Loading branch information
JonasBa authored Jul 4, 2023
1 parent ba7b2e2 commit 856c373
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 14 deletions.
4 changes: 2 additions & 2 deletions static/app/views/asyncView.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import AsyncComponent from 'sentry/components/asyncComponent';
import SentryDocumentTitle from 'sentry/components/sentryDocumentTitle';

type AsyncViewState = AsyncComponent['state'];
type AsyncViewProps = AsyncComponent['props'];
export type AsyncViewState = AsyncComponent['state'];
export type AsyncViewProps = AsyncComponent['props'];

export default class AsyncView<
P extends AsyncViewProps = AsyncViewProps,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@ describe('UserFeedback', function () {

const project = TestStubs.Project({isMember: true});

const routeProps = {
routes: router.routes,
route: {},
router,
location: router.location,
routeParams: router.params,
};

beforeEach(function () {
ProjectsStore.loadInitialData([project]);

Expand All @@ -34,10 +42,10 @@ describe('UserFeedback', function () {
it('renders', function () {
const params = {
organization: TestStubs.Organization(),
location: {query: {}, search: ''},
params: {
orgId: organization.slug,
},
...routeProps,
};

MockApiClient.addMockResponse({
Expand All @@ -56,10 +64,10 @@ describe('UserFeedback', function () {

const params = {
organization: TestStubs.Organization(),
location: {query: {}, search: ''},
params: {
orgId: organization.slug,
},
...routeProps,
};
render(<UserFeedback {...params} />, {context: routerContext});

Expand All @@ -78,10 +86,10 @@ describe('UserFeedback', function () {
organization: TestStubs.Organization({
projects: [TestStubs.Project({isMember: true})],
}),
location: {query: {}, search: ''},
params: {
orgId: organization.slug,
},
...routeProps,
};
render(<UserFeedback {...params} />, {context: routerContext});

Expand All @@ -95,10 +103,16 @@ describe('UserFeedback', function () {
});

const params = {
...routeProps,
organization: TestStubs.Organization({
projects: [TestStubs.Project({isMember: true})],
}),
location: {pathname: 'sentry', query: {project: '112'}, search: ''},
location: {
...routeProps.location,
pathname: 'sentry',
query: {project: '112'},
search: '',
},
params: {
orgId: organization.slug,
},
Expand All @@ -113,11 +127,10 @@ describe('UserFeedback', function () {
organization: TestStubs.Organization({
projects: [TestStubs.Project({isMember: true})],
}),
location: router.location,
params: {
orgId: organization.slug,
},
router,
...routeProps,
};
render(<UserFeedback {...params} />, {context: routerContext});

Expand All @@ -144,10 +157,16 @@ describe('UserFeedback', function () {
});

const params = {
...routeProps,
organization: TestStubs.Organization({
projects: [TestStubs.Project({isMember: true})],
}),
location: {pathname: 'sentry', query: {project: ['112', '113']}, search: ''},
location: {
...routeProps.location,
pathname: 'sentry',
query: {project: ['112', '113']},
search: '',
},
params: {
orgId: organization.slug,
},
Expand Down
10 changes: 5 additions & 5 deletions static/app/views/userFeedback/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,18 @@ import {t} from 'sentry/locale';
import {space} from 'sentry/styles/space';
import {Organization, UserReport} from 'sentry/types';
import withOrganization from 'sentry/utils/withOrganization';
import AsyncView from 'sentry/views/asyncView';
import AsyncView, {AsyncViewState} from 'sentry/views/asyncView';

import {UserFeedbackEmpty} from './userFeedbackEmpty';
import {getQuery} from './utils';

type State = AsyncView['state'] & {
interface State extends AsyncViewState {
reportList: UserReport[];
};
}

type Props = RouteComponentProps<{}, {}> & {
interface Props extends RouteComponentProps<{}, {}> {
organization: Organization;
};
}

class OrganizationUserFeedback extends AsyncView<Props, State> {
getEndpoints(): ReturnType<AsyncView['getEndpoints']> {
Expand Down

0 comments on commit 856c373

Please sign in to comment.