From 0256b6daeae3e91b34648bf61619d6f738daa03a Mon Sep 17 00:00:00 2001 From: Priscila Oliveira Date: Fri, 22 Oct 2021 14:51:57 +0200 Subject: [PATCH 1/6] ref(crashContent): Move crash content related files to folder --- .../exception/content.tsx} | 24 +++++++++---------- .../{exception.tsx => exception/index.tsx} | 5 ++-- .../exception/mechanism.tsx} | 8 +++---- .../exception/stackTrace.tsx} | 8 +++---- .../exception/title.tsx} | 0 .../interfaces/crashContent/stacktrace.tsx | 5 ++-- .../events/interfaces/rawExceptionContent.tsx | 2 +- static/app/types/stacktrace.tsx | 2 +- .../exception/mechanism.spec.jsx} | 2 +- .../exception/stackTrace.spec.jsx} | 2 +- .../events/interfaces/crashContent/index.tsx | 0 11 files changed, 29 insertions(+), 29 deletions(-) rename static/app/components/events/interfaces/{exceptionContent.tsx => crashContent/exception/content.tsx} (72%) rename static/app/components/events/interfaces/crashContent/{exception.tsx => exception/index.tsx} (92%) rename static/app/components/events/interfaces/{exceptionMechanism.tsx => crashContent/exception/mechanism.tsx} (95%) rename static/app/components/events/interfaces/{exceptionStacktraceContent.tsx => crashContent/exception/stackTrace.tsx} (93%) rename static/app/components/events/interfaces/{exceptionTitle.tsx => crashContent/exception/title.tsx} (100%) rename tests/js/spec/components/events/interfaces/{exceptionMechanism.spec.jsx => crashContent/exception/mechanism.spec.jsx} (99%) rename tests/js/spec/components/events/interfaces/{exceptionStacktraceContent.spec.jsx => crashContent/exception/stackTrace.spec.jsx} (98%) create mode 100644 tests/js/spec/components/events/interfaces/crashContent/index.tsx diff --git a/static/app/components/events/interfaces/exceptionContent.tsx b/static/app/components/events/interfaces/crashContent/exception/content.tsx similarity index 72% rename from static/app/components/events/interfaces/exceptionContent.tsx rename to static/app/components/events/interfaces/crashContent/exception/content.tsx index db185b27c94897..acf73b34b95836 100644 --- a/static/app/components/events/interfaces/exceptionContent.tsx +++ b/static/app/components/events/interfaces/crashContent/exception/content.tsx @@ -1,33 +1,31 @@ import * as React from 'react'; import styled from '@emotion/styled'; -import ExceptionMechanism from 'app/components/events/interfaces/exceptionMechanism'; import Annotated from 'app/components/events/meta/annotated'; import space from 'app/styles/space'; import {ExceptionType} from 'app/types'; import {Event} from 'app/types/event'; import {STACK_TYPE} from 'app/types/stacktrace'; -import ExceptionStacktraceContent from './exceptionStacktraceContent'; -import ExceptionTitle from './exceptionTitle'; +import Mechanism from './mechanism'; +import StackTrace from './stackTrace'; +import ExceptionTitle from './title'; -type ExceptionStacktraceContentProps = React.ComponentProps< - typeof ExceptionStacktraceContent ->; +type StackTraceProps = React.ComponentProps; type Props = { event: Event; type: STACK_TYPE; - platform: ExceptionStacktraceContentProps['platform']; - stackView?: ExceptionStacktraceContentProps['stackView']; + platform: StackTraceProps['platform']; + stackView?: StackTraceProps['stackView']; newestFirst?: boolean; } & Pick & Pick< - React.ComponentProps, + React.ComponentProps, 'groupingCurrentLevel' | 'hasHierarchicalGrouping' >; -const ExceptionContent = ({ +const Content = ({ newestFirst, event, stackView, @@ -47,8 +45,8 @@ const ExceptionContent = ({ {value => {value}} - {exc.mechanism && } - } + {children}; }; -export default ExceptionContent; +export default Content; const StyledPre = styled('pre')` margin-bottom: ${space(1)}; diff --git a/static/app/components/events/interfaces/crashContent/exception.tsx b/static/app/components/events/interfaces/crashContent/exception/index.tsx similarity index 92% rename from static/app/components/events/interfaces/crashContent/exception.tsx rename to static/app/components/events/interfaces/crashContent/exception/index.tsx index 843c3dbc355188..af37792e2a32f8 100644 --- a/static/app/components/events/interfaces/crashContent/exception.tsx +++ b/static/app/components/events/interfaces/crashContent/exception/index.tsx @@ -1,10 +1,11 @@ import ErrorBoundary from 'app/components/errorBoundary'; -import ExceptionContent from 'app/components/events/interfaces/exceptionContent'; import RawExceptionContent from 'app/components/events/interfaces/rawExceptionContent'; import {ExceptionType, Group, PlatformType, Project} from 'app/types'; import {Event} from 'app/types/event'; import {STACK_TYPE, STACK_VIEW} from 'app/types/stacktrace'; +import Content from './content'; + type Props = { stackType: STACK_TYPE; projectId: Project['id']; @@ -37,7 +38,7 @@ const Exception = ({ platform={platform} /> ) : ( - { +class Mechanism extends Component { render() { const mechanism = this.props.data; const {type, description, help_link, handled, meta = {}, data = {}} = mechanism; @@ -86,7 +86,7 @@ class ExceptionMechanism extends Component { } } -export default ExceptionMechanism; +export default Mechanism; const Wrapper = styled('div')` margin: ${space(2)} 0; diff --git a/static/app/components/events/interfaces/exceptionStacktraceContent.tsx b/static/app/components/events/interfaces/crashContent/exception/stackTrace.tsx similarity index 93% rename from static/app/components/events/interfaces/exceptionStacktraceContent.tsx rename to static/app/components/events/interfaces/crashContent/exception/stackTrace.tsx index 96a374263003c7..299bad4e67d8a1 100644 --- a/static/app/components/events/interfaces/exceptionStacktraceContent.tsx +++ b/static/app/components/events/interfaces/crashContent/exception/stackTrace.tsx @@ -7,8 +7,8 @@ import {STACK_VIEW} from 'app/types/stacktrace'; import {defined} from 'app/utils'; import EmptyMessage from 'app/views/settings/components/emptyMessage'; -import StacktraceContent from './stacktraceContent'; -import StacktraceContentV2 from './stacktraceContentV2'; +import StacktraceContent from '../../stacktraceContent'; +import StacktraceContentV2 from '../../stacktraceContentV2'; type Props = { data: ExceptionValue['stacktrace']; @@ -23,7 +23,7 @@ type Props = { newestFirst?: boolean; }; -const ExceptionStacktraceContent = ({ +const StackTrace = ({ stackView, stacktrace, chainedException, @@ -101,4 +101,4 @@ const ExceptionStacktraceContent = ({ ); }; -export default ExceptionStacktraceContent; +export default StackTrace; diff --git a/static/app/components/events/interfaces/exceptionTitle.tsx b/static/app/components/events/interfaces/crashContent/exception/title.tsx similarity index 100% rename from static/app/components/events/interfaces/exceptionTitle.tsx rename to static/app/components/events/interfaces/crashContent/exception/title.tsx diff --git a/static/app/components/events/interfaces/crashContent/stacktrace.tsx b/static/app/components/events/interfaces/crashContent/stacktrace.tsx index f3e2492aace04b..b03bc245572b4b 100644 --- a/static/app/components/events/interfaces/crashContent/stacktrace.tsx +++ b/static/app/components/events/interfaces/crashContent/stacktrace.tsx @@ -1,11 +1,12 @@ import ErrorBoundary from 'app/components/errorBoundary'; import rawStacktraceContent from 'app/components/events/interfaces/rawStacktraceContent'; -import StacktraceContent from 'app/components/events/interfaces/stacktraceContent'; -import StacktraceContentV2 from 'app/components/events/interfaces/stacktraceContentV2'; import {PlatformType} from 'app/types'; import {Event} from 'app/types/event'; import {STACK_VIEW, StacktraceType} from 'app/types/stacktrace'; +import StacktraceContent from '../stacktraceContent'; +import StacktraceContentV2 from '../stacktraceContentV2'; + type Props = Pick< React.ComponentProps, 'groupingCurrentLevel' diff --git a/static/app/components/events/interfaces/rawExceptionContent.tsx b/static/app/components/events/interfaces/rawExceptionContent.tsx index 7828aad3fde16a..34c1aca3138505 100644 --- a/static/app/components/events/interfaces/rawExceptionContent.tsx +++ b/static/app/components/events/interfaces/rawExceptionContent.tsx @@ -20,7 +20,7 @@ type Props = { platform: PlatformType; eventId: Event['id']; // XXX: Organization is NOT available for Shared Issues! - organization: Organization; + organization?: Organization; } & Pick; type State = { diff --git a/static/app/types/stacktrace.tsx b/static/app/types/stacktrace.tsx index d14c560f89c2be..1898f7f1df894e 100644 --- a/static/app/types/stacktrace.tsx +++ b/static/app/types/stacktrace.tsx @@ -39,7 +39,7 @@ type MechanismMeta = { }; }; -export type Mechanism = { +export type StackTraceMechanism = { handled: boolean; synthetic: boolean; type: string; diff --git a/tests/js/spec/components/events/interfaces/exceptionMechanism.spec.jsx b/tests/js/spec/components/events/interfaces/crashContent/exception/mechanism.spec.jsx similarity index 99% rename from tests/js/spec/components/events/interfaces/exceptionMechanism.spec.jsx rename to tests/js/spec/components/events/interfaces/crashContent/exception/mechanism.spec.jsx index 86841ec0e0e3af..2918c077406298 100644 --- a/tests/js/spec/components/events/interfaces/exceptionMechanism.spec.jsx +++ b/tests/js/spec/components/events/interfaces/crashContent/exception/mechanism.spec.jsx @@ -1,6 +1,6 @@ import {mountWithTheme} from 'sentry-test/enzyme'; -import ExceptionMechanism from 'app/components/events/interfaces/exceptionMechanism'; +import ExceptionMechanism from 'app/components/events/interfaces/crashContent/exception/mechanism'; describe('ExceptionMechanism', () => { describe('basic attributes', () => { diff --git a/tests/js/spec/components/events/interfaces/exceptionStacktraceContent.spec.jsx b/tests/js/spec/components/events/interfaces/crashContent/exception/stackTrace.spec.jsx similarity index 98% rename from tests/js/spec/components/events/interfaces/exceptionStacktraceContent.spec.jsx rename to tests/js/spec/components/events/interfaces/crashContent/exception/stackTrace.spec.jsx index 5c4a3cb811610f..4b231d432e4f7c 100644 --- a/tests/js/spec/components/events/interfaces/exceptionStacktraceContent.spec.jsx +++ b/tests/js/spec/components/events/interfaces/crashContent/exception/stackTrace.spec.jsx @@ -2,7 +2,7 @@ import cloneDeep from 'lodash/cloneDeep'; import {mountWithTheme} from 'sentry-test/enzyme'; -import ExceptionStacktraceContent from 'app/components/events/interfaces/exceptionStacktraceContent'; +import ExceptionStacktraceContent from 'app/components/events/interfaces/crashContent/exception/stackTrace'; import EmptyMessage from 'app/views/settings/components/emptyMessage'; describe('ExceptionStacktraceContent', () => { diff --git a/tests/js/spec/components/events/interfaces/crashContent/index.tsx b/tests/js/spec/components/events/interfaces/crashContent/index.tsx new file mode 100644 index 00000000000000..e69de29bb2d1d6 From b98a0246f712b896b608641d1cb5b32d3dde8ead Mon Sep 17 00:00:00 2001 From: Priscila Oliveira Date: Fri, 22 Oct 2021 15:34:28 +0200 Subject: [PATCH 2/6] fixed import --- static/app/types/index.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/static/app/types/index.tsx b/static/app/types/index.tsx index a1a712e9b0f34a..fbe35bc641179a 100644 --- a/static/app/types/index.tsx +++ b/static/app/types/index.tsx @@ -21,7 +21,7 @@ import {Field} from 'app/views/settings/components/forms/type'; import {DynamicSamplingRules} from './dynamicSampling'; import {Event} from './event'; -import {Mechanism, RawStacktrace, StacktraceType} from './stacktrace'; +import {RawStacktrace, StackTraceMechanism, StacktraceType} from './stacktrace'; export enum SentryInitRenderReactComponent { INDICATORS = 'Indicators', @@ -2046,7 +2046,7 @@ export type ExceptionValue = { threadId: number | null; stacktrace: StacktraceType | null; rawStacktrace: RawStacktrace; - mechanism: Mechanism | null; + mechanism: StackTraceMechanism | null; module: string | null; frames: Frame[] | null; }; From 69b5c2da35884b5b0b05c34247dd66b4e576d7f9 Mon Sep 17 00:00:00 2001 From: Priscila Oliveira Date: Fri, 22 Oct 2021 15:36:36 +0200 Subject: [PATCH 3/6] removed unused file --- tests/js/spec/components/events/interfaces/crashContent/index.tsx | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 tests/js/spec/components/events/interfaces/crashContent/index.tsx diff --git a/tests/js/spec/components/events/interfaces/crashContent/index.tsx b/tests/js/spec/components/events/interfaces/crashContent/index.tsx deleted file mode 100644 index e69de29bb2d1d6..00000000000000 From 3e1ffcd06fbe048a45132ed7725b4d5dd414bd7d Mon Sep 17 00:00:00 2001 From: Priscila Oliveira Date: Fri, 22 Oct 2021 15:47:37 +0200 Subject: [PATCH 4/6] tests --- tests/js/spec/utils/withTeamsForUser.spec.jsx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/js/spec/utils/withTeamsForUser.spec.jsx b/tests/js/spec/utils/withTeamsForUser.spec.jsx index 75ab3d238e665f..730dec3ab0ca1b 100644 --- a/tests/js/spec/utils/withTeamsForUser.spec.jsx +++ b/tests/js/spec/utils/withTeamsForUser.spec.jsx @@ -9,6 +9,8 @@ describe('withUserTeams HoC', function () { const organization = TestStubs.Organization(); delete organization.projects; + // console.log + beforeEach(function () { MockApiClient.clearMockResponses(); jest.spyOn(ProjectActions, 'loadProjects'); From 708d8ba62be79e42172a2c2813976ed635167e92 Mon Sep 17 00:00:00 2001 From: Priscila Oliveira Date: Fri, 22 Oct 2021 15:48:52 +0200 Subject: [PATCH 5/6] tests2 --- tests/js/spec/utils/test.spec.jsx | 57 +++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 tests/js/spec/utils/test.spec.jsx diff --git a/tests/js/spec/utils/test.spec.jsx b/tests/js/spec/utils/test.spec.jsx new file mode 100644 index 00000000000000..730dec3ab0ca1b --- /dev/null +++ b/tests/js/spec/utils/test.spec.jsx @@ -0,0 +1,57 @@ +import {mountWithTheme} from 'sentry-test/enzyme'; + +import ProjectActions from 'app/actions/projectActions'; +import TeamActions from 'app/actions/teamActions'; +import withTeamsForUser from 'app/utils/withTeamsForUser'; + +describe('withUserTeams HoC', function () { + const api = new MockApiClient(); + const organization = TestStubs.Organization(); + delete organization.projects; + + // console.log + + beforeEach(function () { + MockApiClient.clearMockResponses(); + jest.spyOn(ProjectActions, 'loadProjects'); + jest.spyOn(TeamActions, 'loadTeams'); + }); + + it('forwards errors', async function () { + MockApiClient.addMockResponse({ + url: `/organizations/${organization.slug}/user-teams/`, + statusCode: 400, + }); + const MyComponent = () => null; + const Container = withTeamsForUser(MyComponent); + const wrapper = mountWithTheme(); + await tick(); + expect(wrapper.update().find('MyComponent').prop('error')).not.toBeNull(); + }); + + it('fetches teams and loads stores', async function () { + const mockProjectA = TestStubs.Project({slug: 'a', id: '1'}); + const mockProjectB = TestStubs.Project({slug: 'b', id: '2'}); + const mockTeams = [ + { + slug: 'sentry', + projects: [mockProjectB], + }, + { + slug: 'captainplanet', + projects: [mockProjectA, mockProjectB], + }, + ]; + + MockApiClient.addMockResponse({ + url: `/organizations/${organization.slug}/user-teams/`, + body: mockTeams, + }); + + const MyComponent = () => null; + const Container = withTeamsForUser(MyComponent); + const wrapper = mountWithTheme(); + await tick(); + expect(wrapper.update().find('MyComponent').prop('teams')).toEqual(mockTeams); + }); +}); From 4efb296b9705e46b6e9b5e1662b78c3fa0ae2ba9 Mon Sep 17 00:00:00 2001 From: Priscila Oliveira Date: Mon, 25 Oct 2021 11:24:14 +0200 Subject: [PATCH 6/6] remove unused file --- tests/js/spec/utils/test.spec.jsx | 57 ------------------- tests/js/spec/utils/withTeamsForUser.spec.jsx | 2 - 2 files changed, 59 deletions(-) delete mode 100644 tests/js/spec/utils/test.spec.jsx diff --git a/tests/js/spec/utils/test.spec.jsx b/tests/js/spec/utils/test.spec.jsx deleted file mode 100644 index 730dec3ab0ca1b..00000000000000 --- a/tests/js/spec/utils/test.spec.jsx +++ /dev/null @@ -1,57 +0,0 @@ -import {mountWithTheme} from 'sentry-test/enzyme'; - -import ProjectActions from 'app/actions/projectActions'; -import TeamActions from 'app/actions/teamActions'; -import withTeamsForUser from 'app/utils/withTeamsForUser'; - -describe('withUserTeams HoC', function () { - const api = new MockApiClient(); - const organization = TestStubs.Organization(); - delete organization.projects; - - // console.log - - beforeEach(function () { - MockApiClient.clearMockResponses(); - jest.spyOn(ProjectActions, 'loadProjects'); - jest.spyOn(TeamActions, 'loadTeams'); - }); - - it('forwards errors', async function () { - MockApiClient.addMockResponse({ - url: `/organizations/${organization.slug}/user-teams/`, - statusCode: 400, - }); - const MyComponent = () => null; - const Container = withTeamsForUser(MyComponent); - const wrapper = mountWithTheme(); - await tick(); - expect(wrapper.update().find('MyComponent').prop('error')).not.toBeNull(); - }); - - it('fetches teams and loads stores', async function () { - const mockProjectA = TestStubs.Project({slug: 'a', id: '1'}); - const mockProjectB = TestStubs.Project({slug: 'b', id: '2'}); - const mockTeams = [ - { - slug: 'sentry', - projects: [mockProjectB], - }, - { - slug: 'captainplanet', - projects: [mockProjectA, mockProjectB], - }, - ]; - - MockApiClient.addMockResponse({ - url: `/organizations/${organization.slug}/user-teams/`, - body: mockTeams, - }); - - const MyComponent = () => null; - const Container = withTeamsForUser(MyComponent); - const wrapper = mountWithTheme(); - await tick(); - expect(wrapper.update().find('MyComponent').prop('teams')).toEqual(mockTeams); - }); -}); diff --git a/tests/js/spec/utils/withTeamsForUser.spec.jsx b/tests/js/spec/utils/withTeamsForUser.spec.jsx index 730dec3ab0ca1b..75ab3d238e665f 100644 --- a/tests/js/spec/utils/withTeamsForUser.spec.jsx +++ b/tests/js/spec/utils/withTeamsForUser.spec.jsx @@ -9,8 +9,6 @@ describe('withUserTeams HoC', function () { const organization = TestStubs.Organization(); delete organization.projects; - // console.log - beforeEach(function () { MockApiClient.clearMockResponses(); jest.spyOn(ProjectActions, 'loadProjects');