Skip to content

Commit a01a8a1

Browse files
authored
update block page with blockversion changes (#12261)
1 parent 8b514b8 commit a01a8a1

File tree

4 files changed

+39
-17
lines changed

4 files changed

+39
-17
lines changed

src/amo/pages/Block/index.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,13 +115,14 @@ export class BlockBase extends React.Component<InternalProps> {
115115
return <LoadingText />;
116116
}
117117

118-
if (block.min_version === '0' && block.max_version === '*') {
118+
if (block.is_all_versions) {
119119
return i18n.gettext('Versions blocked: all versions.');
120120
}
121121

122-
return i18n.sprintf(i18n.gettext('Versions blocked: %(min)s to %(max)s.'), {
123-
min: block.min_version,
124-
max: block.max_version,
122+
const versions = block.versions.join(', ');
123+
124+
return i18n.sprintf(i18n.gettext('Versions blocked: %(versions)s.'), {
125+
versions,
125126
});
126127
}
127128

src/amo/reducers/blocks.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ export type ExternalBlockType = {|
1414
created: string,
1515
guid: string,
1616
id: number,
17-
max_version: string,
18-
min_version: string,
17+
versions: [string],
18+
is_all_versions?: boolean,
1919
modified: string,
2020
reason: string | null,
2121
url: UrlWithOutgoing | null,

tests/unit/amo/pages/TestBlock.js

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -185,10 +185,9 @@ describe(__filename, () => {
185185
expect(screen.queryByClassName('Block-reason')).not.toBeInTheDocument();
186186
});
187187

188-
it('renders "all versions" when min is 0 and max is *', () => {
188+
it('renders "all versions" when "is_all_versions" is true', () => {
189189
const block = _createFakeBlockResult({
190-
min_version: '0',
191-
max_version: '*',
190+
is_all_versions: true,
192191
});
193192
const i18n = fakeI18n();
194193
store.dispatch(loadBlock({ block }));
@@ -205,12 +204,12 @@ describe(__filename, () => {
205204
).toBeInTheDocument();
206205
});
207206

208-
it('renders the min/max versions if min is not 0 and max is not *', () => {
209-
const min = '12';
210-
const max = '34';
207+
it('renders the versions if "is_all_versions" is false', () => {
208+
const v1 = '12';
209+
const v2 = '34';
211210
const block = _createFakeBlockResult({
212-
min_version: min,
213-
max_version: max,
211+
versions: [v1, v2],
212+
is_all_versions: false,
214213
});
215214
const i18n = fakeI18n();
216215
store.dispatch(loadBlock({ block }));
@@ -220,7 +219,29 @@ describe(__filename, () => {
220219
// by a </br>.
221220
expect(
222221
screen.getByTextAcrossTags(
223-
`Versions blocked: ${min} to ${max}.Blocked on ${i18n
222+
`Versions blocked: ${v1}, ${v2}.Blocked on ${i18n
223+
.moment(block.created)
224+
.format('ll')}.`,
225+
),
226+
).toBeInTheDocument();
227+
});
228+
229+
it('renders the versions if "is_all_versions" is missing', () => {
230+
const v1 = '12';
231+
const v2 = '34';
232+
const block = _createFakeBlockResult({
233+
versions: [v1, v2],
234+
is_all_versions: undefined,
235+
});
236+
const i18n = fakeI18n();
237+
store.dispatch(loadBlock({ block }));
238+
render();
239+
240+
// The version info and the block date are inside the same tag, separated
241+
// by a </br>.
242+
expect(
243+
screen.getByTextAcrossTags(
244+
`Versions blocked: ${v1}, ${v2}.Blocked on ${i18n
224245
.moment(block.created)
225246
.format('ll')}.`,
226247
),

tests/unit/helpers.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1292,8 +1292,8 @@ export const createFakeBlockResult = ({
12921292
created: '2020-01-22T10:09:01Z',
12931293
modified: '2020-01-22T10:09:01Z',
12941294
guid,
1295-
min_version: '0',
1296-
max_version: '*',
1295+
versions: ['0.1', '4.56'],
1296+
is_all_versions: false,
12971297
addon_name: addonName,
12981298
reason,
12991299
url,

0 commit comments

Comments
 (0)