Skip to content

Commit b0f3542

Browse files
feat(tests): Add mobile screenshot tests
1 parent 89b8b9b commit b0f3542

File tree

14 files changed

+475
-52
lines changed

14 files changed

+475
-52
lines changed

static/app/components/acl/role.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ class Role extends React.Component<Props> {
3636
const user = ConfigStore.get('user');
3737
const {organization, role} = this.props;
3838
const {availableRoles} = organization;
39+
3940
const currentRole = organization.role ?? '';
4041

4142
if (!user) {

static/app/components/events/attachmentViewers/imageViewer.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,13 @@ import {
66
} from 'app/components/events/attachmentViewers/utils';
77
import {PanelItem} from 'app/components/panels';
88

9-
function ImageViewer({className, ...props}: ViewerProps) {
9+
type Props = Omit<ViewerProps, 'attachment'> & {
10+
attachment: Omit<ViewerProps['attachment'], 'event_id'> & {
11+
event_id?: string;
12+
};
13+
};
14+
15+
function ImageViewer({className, ...props}: Props) {
1016
return (
1117
<Container className={className}>
1218
<img src={getAttachmentUrl(props, true)} />

static/app/components/events/attachmentViewers/utils.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ export type ViewerProps = {
55
event: Event;
66
orgId: string;
77
projectId: string;
8-
attachment: EventAttachment;
8+
attachment: Omit<EventAttachment, 'event_id'> & {
9+
event_id?: string;
10+
};
911
className?: string;
1012
};
1113

static/app/components/events/contextSummary/item.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ type Props = {
1111
};
1212

1313
const Item = ({children, icon, className}: Props) => (
14-
<Wrapper className={classNames('context-item', className)}>
14+
<Wrapper className={classNames('context-item', className)} data-test-id="context-item">
1515
{icon}
1616
{children && <Details>{children}</Details>}
1717
</Wrapper>

static/app/components/events/eventDataSection.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,13 @@ class EventDataSection extends React.Component<Props> {
6565
actions,
6666
isCentered,
6767
showPermalink,
68+
...props
6869
} = this.props;
6970

7071
const titleNode = wrapTitle ? <h3>{title}</h3> : title;
7172

7273
return (
73-
<DataSection ref={this.dataSectionDOMRef} className={className || ''}>
74+
<DataSection ref={this.dataSectionDOMRef} className={className || ''} {...props}>
7475
{title && (
7576
<SectionHeader id={type} isCentered={isCentered}>
7677
<Title>

static/app/components/events/eventEntries.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ import {projectProcessingIssuesMessages} from 'app/views/settings/project/projec
4848
import findBestThread from './interfaces/threads/threadSelector/findBestThread';
4949
import getThreadException from './interfaces/threads/threadSelector/getThreadException';
5050
import EventEntry from './eventEntry';
51-
import EventTagAndScreenshot from './eventTagsAndScreenshot';
51+
import EventTagsAndScreenshot from './eventTagsAndScreenshot';
5252

5353
const MINIFIED_DATA_JAVA_EVENT_REGEX_MATCH =
5454
/^(([\w\$]\.[\w\$]{1,2})|([\w\$]{2}\.[\w\$]\.[\w\$]))(\.|$)/g;
@@ -393,7 +393,7 @@ const EventEntries = memo(
393393
)}
394394
{showTagSummary &&
395395
(hasMobileScreenshotsFeature ? (
396-
<EventTagAndScreenshot
396+
<EventTagsAndScreenshot
397397
event={event}
398398
organization={organization as Organization}
399399
projectId={projectSlug}

static/app/components/events/eventTagsAndScreenshot/dataSection.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,11 @@ type Props = {
1313
className?: string;
1414
};
1515

16-
function DataSection({title, description, children, className}: Props) {
16+
function DataSection({title, description, children, className, ...props}: Props) {
1717
const type = kebabCase(title);
1818
return (
1919
<StyledEventDataSection
20+
{...props}
2021
className={className}
2122
type={type}
2223
title={

static/app/components/events/eventTagsAndScreenshot/index.tsx

Lines changed: 29 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -8,49 +8,56 @@ import Tags from './tags';
88

99
type ScreenshotProps = React.ComponentProps<typeof Screenshot>;
1010

11-
type Props = Omit<React.ComponentProps<typeof Tags>, 'projectSlug'> &
12-
Pick<ScreenshotProps, 'attachments'> & {
13-
projectId: string;
14-
isShare: boolean;
15-
isBorderless: boolean;
16-
onDeleteScreenshot: ScreenshotProps['onDelete'];
17-
};
11+
type Props = Omit<React.ComponentProps<typeof Tags>, 'projectSlug' | 'hasContext'> & {
12+
projectId: string;
13+
onDeleteScreenshot: ScreenshotProps['onDelete'];
14+
attachments: ScreenshotProps['screenshot'][];
15+
isShare?: boolean;
16+
isBorderless?: boolean;
17+
hasContext?: boolean;
18+
};
1819

1920
function EventTagsAndScreenshots({
2021
projectId: projectSlug,
21-
isShare,
22-
hasContext,
2322
location,
24-
isBorderless,
2523
event,
2624
attachments,
2725
onDeleteScreenshot,
28-
...props
26+
organization,
27+
isShare = false,
28+
isBorderless = false,
29+
hasContext = false,
2930
}: Props) {
3031
const {tags = []} = event;
3132

32-
if (!tags.length && !hasContext && isShare) {
33+
const screenshot = attachments.find(
34+
({name}) => name === 'screenshot.jpg' || name === 'screenshot.png'
35+
);
36+
37+
if (!tags.length && !hasContext && (isShare || !screenshot)) {
3338
return null;
3439
}
3540

3641
return (
3742
<Wrapper isBorderless={isBorderless}>
38-
{!isShare && !!attachments.length && (
43+
{!isShare && !!screenshot && (
3944
<Screenshot
40-
{...props}
45+
organization={organization}
4146
event={event}
4247
projectSlug={projectSlug}
43-
attachments={attachments}
48+
screenshot={screenshot}
4449
onDelete={onDeleteScreenshot}
4550
/>
4651
)}
47-
<Tags
48-
{...props}
49-
event={event}
50-
projectSlug={projectSlug}
51-
hasContext={hasContext}
52-
location={location}
53-
/>
52+
{(!!tags.length || hasContext) && (
53+
<Tags
54+
organization={organization}
55+
event={event}
56+
projectSlug={projectSlug}
57+
hasContext={hasContext}
58+
location={location}
59+
/>
60+
)}
5461
</Wrapper>
5562
);
5663
}

static/app/components/events/eventTagsAndScreenshot/screenshot/index.tsx

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -19,24 +19,21 @@ import DataSection from '../dataSection';
1919
import ImageVisualization from './imageVisualization';
2020
import Modal, {modalCss} from './modal';
2121

22+
type Screenshot = Omit<EventAttachment, 'event_id'>;
23+
2224
type Props = {
2325
event: Event;
2426
organization: Organization;
2527
projectSlug: Project['slug'];
26-
attachments: EventAttachment[];
27-
onDelete: (attachmentId: EventAttachment['id']) => void;
28+
screenshot: Screenshot;
29+
onDelete: (attachmentId: Screenshot['id']) => void;
2830
};
2931

30-
function Screenshot({event, attachments, organization, projectSlug, onDelete}: Props) {
32+
function Screenshot({event, organization, screenshot, projectSlug, onDelete}: Props) {
3133
const orgSlug = organization.slug;
3234

33-
function hasScreenshot(attachment: EventAttachment) {
34-
const {mimetype} = attachment;
35-
return mimetype === 'image/jpeg' || mimetype === 'image/png';
36-
}
37-
3835
function handleOpenVisualizationModal(
39-
eventAttachment: EventAttachment,
36+
eventAttachment: Screenshot,
4037
downloadUrl: string
4138
) {
4239
openModal(
@@ -55,7 +52,7 @@ function Screenshot({event, attachments, organization, projectSlug, onDelete}: P
5552
);
5653
}
5754

58-
function renderContent(screenshotAttachment: EventAttachment) {
55+
function renderContent(screenshotAttachment: Screenshot) {
5956
const downloadUrl = `/api/0/projects/${organization.slug}/${projectSlug}/events/${event.id}/attachments/${screenshotAttachment.id}/`;
6057

6158
return (
@@ -118,22 +115,20 @@ function Screenshot({event, attachments, organization, projectSlug, onDelete}: P
118115
}
119116

120117
return (
121-
<Role role={organization.attachmentsRole}>
118+
<Role organization={organization} role={organization.attachmentsRole}>
122119
{({hasRole}) => {
123-
const screenshotAttachment = attachments.find(hasScreenshot);
124-
125-
if (!hasRole || !screenshotAttachment) {
120+
if (!hasRole) {
126121
return null;
127122
}
128123

129124
return (
130125
<DataSection
131-
title={t('Screenshots')}
126+
title={t('Screenshot')}
132127
description={t(
133-
'Screenshots help identify what the user saw when the event happened'
128+
'Screenshot help identify what the user saw when the event happened'
134129
)}
135130
>
136-
<StyledPanel>{renderContent(screenshotAttachment)}</StyledPanel>
131+
<StyledPanel>{renderContent(screenshot)}</StyledPanel>
137132
</DataSection>
138133
);
139134
}}

static/app/components/events/eventTagsAndScreenshot/screenshot/modal.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,10 @@ import getDynamicText from 'app/utils/getDynamicText';
1717

1818
import ImageVisualization from './imageVisualization';
1919

20+
type Screenshot = Omit<EventAttachment, 'event_id'>;
21+
2022
type Props = ModalRenderProps & {
21-
eventAttachment: EventAttachment;
23+
eventAttachment: Screenshot;
2224
orgSlug: Organization['slug'];
2325
projectSlug: Project['slug'];
2426
event: Event;

0 commit comments

Comments
 (0)