Skip to content

Commit fc8ecea

Browse files
scttcperarmenzg
authored andcommitted
feat(issues): Display semver info when resolved in release (#53243)
1 parent 802b311 commit fc8ecea

File tree

5 files changed

+219
-127
lines changed

5 files changed

+219
-127
lines changed
Lines changed: 104 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -1,76 +1,111 @@
11
import {render} from 'sentry-test/reactTestingLibrary';
22

3-
import ResolutionBox from 'sentry/components/resolutionBox';
3+
import {GroupActivityType} from 'sentry/types';
4+
5+
import ResolutionBox from './resolutionBox';
46

57
describe('ResolutionBox', function () {
6-
describe('render()', function () {
7-
it('handles inNextRelease', function () {
8-
const {container} = render(
9-
<ResolutionBox statusDetails={{inNextRelease: true}} projectId="1" />
10-
);
11-
expect(container).toSnapshot();
12-
});
13-
it('handles inNextRelease with actor', function () {
14-
const {container} = render(
15-
<ResolutionBox
16-
statusDetails={{
17-
inNextRelease: true,
18-
actor: {
19-
id: '111',
20-
name: 'David Cramer',
21-
username: 'dcramer',
22-
ip_address: '127.0.0.1',
23-
24-
},
25-
}}
26-
projectId="1"
27-
/>
28-
);
29-
expect(container).toSnapshot();
30-
});
31-
it('handles inRelease', function () {
32-
const {container} = render(
33-
<ResolutionBox
34-
statusDetails={{
35-
inRelease: '1.0',
36-
}}
37-
projectId="1"
38-
/>
39-
);
40-
expect(container).toSnapshot();
41-
});
42-
it('handles inRelease with actor', function () {
43-
const {container} = render(
44-
<ResolutionBox
45-
statusDetails={{
46-
inRelease: '1.0',
47-
actor: {
48-
id: '111',
49-
name: 'David Cramer',
50-
username: 'dcramer',
51-
ip_address: '127.0.0.1',
52-
8+
it('handles default', function () {
9+
const {container} = render(<ResolutionBox statusDetails={{}} projectId="1" />);
10+
expect(container).toHaveTextContent('This issue has been marked as resolved.');
11+
});
12+
it('handles inNextRelease', function () {
13+
const {container} = render(
14+
<ResolutionBox statusDetails={{inNextRelease: true}} projectId="1" />
15+
);
16+
expect(container).toHaveTextContent(
17+
'This issue has been marked as resolved in the upcoming release.'
18+
);
19+
});
20+
it('handles inNextRelease with actor', function () {
21+
const {container} = render(
22+
<ResolutionBox
23+
statusDetails={{
24+
inNextRelease: true,
25+
actor: {
26+
id: '111',
27+
name: 'David Cramer',
28+
username: 'dcramer',
29+
ip_address: '127.0.0.1',
30+
31+
},
32+
}}
33+
projectId="1"
34+
/>
35+
);
36+
expect(container).toHaveTextContent(
37+
'David Cramer marked this issue as resolved in the upcoming release.'
38+
);
39+
});
40+
it('handles in next release (semver current_release_version)', function () {
41+
const {container} = render(
42+
<ResolutionBox
43+
statusDetails={{
44+
inNextRelease: true,
45+
actor: TestStubs.User(),
46+
}}
47+
projectId="1"
48+
activities={[
49+
{
50+
id: '1',
51+
type: GroupActivityType.SET_RESOLVED_IN_RELEASE,
52+
data: {
53+
current_release_version: '[email protected]',
5354
},
54-
}}
55-
projectId="1"
56-
/>
57-
);
58-
expect(container).toSnapshot();
59-
});
60-
it('handles default', function () {
61-
const {container} = render(<ResolutionBox statusDetails={{}} projectId="1" />);
62-
expect(container).toSnapshot();
63-
});
64-
it('handles inCommit', function () {
65-
const {container} = render(
66-
<ResolutionBox
67-
statusDetails={{
68-
inCommit: TestStubs.Commit(),
69-
}}
70-
projectId="1"
71-
/>
72-
);
73-
expect(container).toSnapshot();
74-
});
55+
dateCreated: new Date().toISOString(),
56+
project: TestStubs.Project(),
57+
},
58+
]}
59+
/>
60+
);
61+
expect(container).toHaveTextContent(
62+
'Foo Bar marked this issue as resolved in versions greater than 1.0.0'
63+
);
64+
});
65+
it('handles inRelease', function () {
66+
const {container} = render(
67+
<ResolutionBox
68+
statusDetails={{
69+
inRelease: '1.0',
70+
}}
71+
projectId="1"
72+
/>
73+
);
74+
expect(container).toHaveTextContent(
75+
'This issue has been marked as resolved in version 1.0.'
76+
);
77+
});
78+
it('handles inRelease with actor', function () {
79+
const {container} = render(
80+
<ResolutionBox
81+
statusDetails={{
82+
inRelease: '1.0',
83+
actor: {
84+
id: '111',
85+
name: 'David Cramer',
86+
username: 'dcramer',
87+
ip_address: '127.0.0.1',
88+
89+
},
90+
}}
91+
projectId="1"
92+
/>
93+
);
94+
expect(container).toHaveTextContent(
95+
'David Cramer marked this issue as resolved in version 1.0.'
96+
);
97+
});
98+
it('handles inCommit', function () {
99+
const {container} = render(
100+
<ResolutionBox
101+
statusDetails={{
102+
inCommit: TestStubs.Commit(),
103+
}}
104+
projectId="1"
105+
/>
106+
);
107+
expect(container).toHaveTextContent(
108+
'This issue has been marked as resolved by f7f395din'
109+
);
75110
});
76111
});

static/app/components/resolutionBox.tsx

Lines changed: 44 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {t, tct} from 'sentry/locale';
1111
import {space} from 'sentry/styles/space';
1212
import {
1313
GroupActivity,
14+
GroupActivitySetByResolvedInNextSemverRelease,
1415
GroupActivitySetByResolvedInRelease,
1516
GroupActivityType,
1617
Repository,
@@ -37,64 +38,55 @@ function renderReason(
3738

3839
const relevantActivity = activities.find(
3940
activity => activity.type === GroupActivityType.SET_RESOLVED_IN_RELEASE
40-
) as GroupActivitySetByResolvedInRelease | undefined;
41+
) as
42+
| GroupActivitySetByResolvedInRelease
43+
| GroupActivitySetByResolvedInNextSemverRelease
44+
| undefined;
4145

42-
const currentReleaseVersion = relevantActivity?.data.current_release_version!;
43-
44-
if (statusDetails.inNextRelease && statusDetails.actor) {
45-
return tct('[actor] marked this issue as resolved in the upcoming release.', {
46-
actor,
47-
});
48-
}
4946
if (statusDetails.inNextRelease) {
50-
return t('This issue has been marked as resolved in the upcoming release.');
51-
}
52-
if (statusDetails.inRelease && statusDetails.actor) {
53-
return currentReleaseVersion
54-
? tct('[actor] marked this issue as resolved in versions greater than [version].', {
47+
// Resolved in next release has current_release_version (semver only)
48+
if (relevantActivity && 'current_release_version' in relevantActivity.data) {
49+
const version = (
50+
<Version
51+
version={relevantActivity.data.current_release_version}
52+
projectId={projectId}
53+
tooltipRawVersion
54+
/>
55+
);
56+
return statusDetails.actor
57+
? tct(
58+
'[actor] marked this issue as resolved in versions greater than [version].',
59+
{
60+
actor,
61+
version,
62+
}
63+
)
64+
: tct(
65+
'This issue has been marked as resolved in versions greater than [version].',
66+
{version}
67+
);
68+
}
69+
70+
return actor
71+
? tct('[actor] marked this issue as resolved in the upcoming release.', {
5572
actor,
56-
version: (
57-
<Version
58-
version={currentReleaseVersion}
59-
projectId={projectId}
60-
tooltipRawVersion
61-
/>
62-
),
6373
})
64-
: tct('[actor] marked this issue as resolved in version [version].', {
65-
actor,
66-
version: (
67-
<Version
68-
version={statusDetails.inRelease}
69-
projectId={projectId}
70-
tooltipRawVersion
71-
/>
72-
),
73-
});
74+
: t('This issue has been marked as resolved in the upcoming release.');
7475
}
7576
if (statusDetails.inRelease) {
76-
return currentReleaseVersion
77-
? tct(
78-
'This issue has been marked as resolved in versions greater than [version].',
79-
{
80-
version: (
81-
<Version
82-
version={currentReleaseVersion}
83-
projectId={projectId}
84-
tooltipRawVersion
85-
/>
86-
),
87-
}
88-
)
89-
: tct('This issue has been marked as resolved in version [version].', {
90-
version: (
91-
<Version
92-
version={statusDetails.inRelease}
93-
projectId={projectId}
94-
tooltipRawVersion
95-
/>
96-
),
97-
});
77+
const version = (
78+
<Version
79+
version={statusDetails.inRelease}
80+
projectId={projectId}
81+
tooltipRawVersion
82+
/>
83+
);
84+
return actor
85+
? tct('[actor] marked this issue as resolved in version [version].', {
86+
actor,
87+
version,
88+
})
89+
: tct('This issue has been marked as resolved in version [version].', {version});
9890
}
9991
if (statusDetails.inCommit) {
10092
return tct('This issue has been marked as resolved by [commit]', {

static/app/types/group.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,9 +334,16 @@ interface GroupActivityRegression extends GroupActivityBase {
334334
type: GroupActivityType.SET_REGRESSION;
335335
}
336336

337+
export interface GroupActivitySetByResolvedInNextSemverRelease extends GroupActivityBase {
338+
data: {
339+
// Set for semver releases
340+
current_release_version: string;
341+
};
342+
type: GroupActivityType.SET_RESOLVED_IN_RELEASE;
343+
}
344+
337345
export interface GroupActivitySetByResolvedInRelease extends GroupActivityBase {
338346
data: {
339-
current_release_version?: string;
340347
version?: string;
341348
};
342349
type: GroupActivityType.SET_RESOLVED_IN_RELEASE;
@@ -461,6 +468,7 @@ export type GroupActivity =
461468
| GroupActivitySetIgnored
462469
| GroupActivitySetByAge
463470
| GroupActivitySetByResolvedInRelease
471+
| GroupActivitySetByResolvedInNextSemverRelease
464472
| GroupActivitySetByResolvedInCommit
465473
| GroupActivitySetByResolvedInPullRequest
466474
| GroupActivityFirstSeen

static/app/views/issueDetails/groupActivity.spec.tsx

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -581,4 +581,47 @@ describe('GroupActivity', function () {
581581
'Foo Bar archived this issue forever'
582582
);
583583
});
584+
585+
it('renders resolved in release with semver information', function () {
586+
createWrapper({
587+
activity: [
588+
{
589+
id: '123',
590+
type: GroupActivityType.SET_RESOLVED_IN_RELEASE,
591+
project: TestStubs.Project(),
592+
data: {
593+
version: '[email protected]',
594+
},
595+
user: TestStubs.User(),
596+
dateCreated,
597+
},
598+
],
599+
organization: TestStubs.Organization({features: ['issue-release-semver']}),
600+
});
601+
expect(screen.getAllByTestId('activity-item').at(-1)).toHaveTextContent(
602+
'Foo Bar marked this issue as resolved in 1.0.0 (semver)'
603+
);
604+
});
605+
606+
it('renders resolved in next release with semver information', function () {
607+
createWrapper({
608+
activity: [
609+
{
610+
id: '123',
611+
type: GroupActivityType.SET_RESOLVED_IN_RELEASE,
612+
project: TestStubs.Project(),
613+
data: {
614+
current_release_version: '[email protected]',
615+
},
616+
user: TestStubs.User(),
617+
dateCreated,
618+
},
619+
],
620+
// TODO(scttcper): combine test with the above test once we remove the feature flag
621+
organization: TestStubs.Organization({features: ['issue-release-semver']}),
622+
});
623+
expect(screen.getAllByTestId('activity-item').at(-1)).toHaveTextContent(
624+
'Foo Bar marked this issue as resolved in releases greater than 1.0.0 (semver)'
625+
);
626+
});
584627
});

0 commit comments

Comments
 (0)