Skip to content

Commit d3e4825

Browse files
authored
Merge pull request #5186 from dfe-analytical-services/ees-5456
EES-5456 Fix broken changelog link in API data set version history
2 parents 566e75f + 1782e6d commit d3e4825

File tree

3 files changed

+61
-26
lines changed

3 files changed

+61
-26
lines changed

src/explore-education-statistics-admin/src/pages/release/data/ReleaseApiDataSetChangelogPage.tsx

+4-4
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import apiDataSetQueries from '@admin/queries/apiDataSetQueries';
1111
import apiDataSetVersionQueries from '@admin/queries/apiDataSetVersionQueries';
1212
import apiDataSetVersionService from '@admin/services/apiDataSetVersionService';
1313
import LoadingSpinner from '@common/components/LoadingSpinner';
14+
import TagGroup from '@common/components/TagGroup';
1415
import useToggle from '@common/hooks/useToggle';
1516
import Button from '@common/components/Button';
1617
import ApiDataSetChangelog from '@common/modules/data-catalogue/components/ApiDataSetChangelog';
@@ -80,16 +81,15 @@ export default function ReleaseApiDataSetChangelogPage() {
8081
<h2>{dataSet?.title}</h2>
8182
</div>
8283
</div>
83-
<p>
84+
85+
<TagGroup className="govuk-!-margin-bottom-7">
8486
<Tag colour={isDraft ? 'green' : 'blue'}>{`${
8587
isDraft ? 'Draft' : 'Published'
8688
} v${dataSetVersion?.version}`}</Tag>
87-
</p>
88-
<p>
8989
<Tag
9090
colour={dataSetVersion?.type === 'Major' ? 'blue' : 'grey'}
9191
>{`${dataSetVersion?.type} update`}</Tag>
92-
</p>
92+
</TagGroup>
9393

9494
{isDraft && showForm ? (
9595
<ApiDataSetGuidanceNotesForm

src/explore-education-statistics-admin/src/pages/release/data/ReleaseApiDataSetVersionHistoryPage.tsx

+14-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import Link from '@admin/components/Link';
22
import { useConfig } from '@admin/contexts/ConfigContext';
33
import {
4+
releaseApiDataSetChangelogRoute,
45
releaseApiDataSetDetailsRoute,
6+
ReleaseDataSetChangelogRouteParams,
57
ReleaseDataSetPreviewTokenRouteParams,
68
ReleaseDataSetRouteParams,
79
ReleaseRouteParams,
@@ -92,8 +94,8 @@ export default function ReleaseApiDataSetVersionHistoryPage() {
9294
to={generatePath<ReleaseRouteParams>(
9395
releaseSummaryRoute.path,
9496
{
95-
releaseId: dataSetVersion.releaseVersion.id,
9697
publicationId,
98+
releaseId: dataSetVersion.releaseVersion.id,
9799
},
98100
)}
99101
>
@@ -112,7 +114,17 @@ export default function ReleaseApiDataSetVersionHistoryPage() {
112114

113115
<td className="govuk-!-text-align-right">
114116
{dataSetVersion.version !== '1.0' && (
115-
<Link to="/todo">
117+
<Link
118+
to={generatePath<ReleaseDataSetChangelogRouteParams>(
119+
releaseApiDataSetChangelogRoute.path,
120+
{
121+
publicationId,
122+
releaseId: dataSetVersion.releaseVersion.id,
123+
dataSetId,
124+
dataSetVersionId: dataSetVersion.id,
125+
},
126+
)}
127+
>
116128
View changelog
117129
<VisuallyHidden>
118130
{' '}

src/explore-education-statistics-admin/src/pages/release/data/__tests__/ReleaseApiDataSetVersionHistoryPage.test.tsx

+43-20
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ describe('ReleaseApiDataSetVersionHistoryPage', () => {
4040
},
4141
published: '2024-04-01',
4242
releaseVersion: {
43-
id: 'release-version-3-1-id',
43+
id: 'release-v3-1-id',
4444
title: 'Release version 3.1',
4545
},
4646
status: 'Published',
@@ -55,7 +55,7 @@ describe('ReleaseApiDataSetVersionHistoryPage', () => {
5555
},
5656
published: '2024-03-01',
5757
releaseVersion: {
58-
id: 'release-version-3-id',
58+
id: 'release-v3-id',
5959
title: 'Release version 3',
6060
},
6161
status: 'Published',
@@ -70,7 +70,7 @@ describe('ReleaseApiDataSetVersionHistoryPage', () => {
7070
},
7171
published: '2024-02-01',
7272
releaseVersion: {
73-
id: 'release-version-2-id',
73+
id: 'release-v2-id',
7474
title: 'Release version 2',
7575
},
7676
status: 'Published',
@@ -85,7 +85,7 @@ describe('ReleaseApiDataSetVersionHistoryPage', () => {
8585
},
8686
published: '2024-01-01',
8787
releaseVersion: {
88-
id: 'release-version-1-id',
88+
id: 'release-v1-id',
8989
title: 'Release version 1',
9090
},
9191
status: 'Published',
@@ -109,6 +109,8 @@ describe('ReleaseApiDataSetVersionHistoryPage', () => {
109109

110110
expect(await screen.findByText('Data set title')).toBeInTheDocument();
111111

112+
const { publicationId } = testRelease;
113+
112114
const rows = within(screen.getByRole('table')).getAllByRole('row');
113115
expect(rows).toHaveLength(5);
114116

@@ -118,68 +120,86 @@ describe('ReleaseApiDataSetVersionHistoryPage', () => {
118120
within(row1Cells[1]).getByRole('link', { name: 'Release version 3.1' }),
119121
).toHaveAttribute(
120122
'href',
121-
`/publication/${testRelease.publicationId}/release/release-version-3-1-id/summary`,
123+
`/publication/${publicationId}/release/release-v3-1-id/summary`,
122124
);
123125
expect(row1Cells[2]).toHaveTextContent('Published');
124126
expect(row1Cells[2]).toHaveTextContent('Latest version');
125127
expect(
126128
within(row1Cells[3]).getByRole('link', {
127129
name: 'View changelog for version 3.1',
128130
}),
129-
).toBeInTheDocument();
131+
).toHaveAttribute(
132+
'href',
133+
`/publication/${publicationId}/release/release-v3-1-id/api-data-sets/data-set-id/changelog/version-3-1-id`,
134+
);
130135
expect(
131136
within(row1Cells[3]).getByRole('link', {
132-
name: 'View live data set for version 3.1 (opens in new tab)',
137+
name: /View live data set for version 3.1/,
133138
}),
134-
).toBeInTheDocument();
139+
).toHaveAttribute(
140+
'href',
141+
'http://localhost/data-catalogue/data-set/version-3-1-file-id',
142+
);
135143

136144
const row2Cells = within(rows[2]).getAllByRole('cell');
137145
expect(row2Cells[0]).toHaveTextContent('3.0');
138146
expect(
139147
within(row2Cells[1]).getByRole('link', { name: 'Release version 3' }),
140148
).toHaveAttribute(
141149
'href',
142-
`/publication/${testRelease.publicationId}/release/release-version-3-id/summary`,
150+
`/publication/${publicationId}/release/release-v3-id/summary`,
143151
);
144152
expect(row2Cells[2]).toHaveTextContent('Published');
145153
expect(
146154
within(row2Cells[3]).getByRole('link', {
147155
name: 'View changelog for version 3.0',
148156
}),
149-
).toBeInTheDocument();
157+
).toHaveAttribute(
158+
'href',
159+
`/publication/${publicationId}/release/release-v3-id/api-data-sets/data-set-id/changelog/version-3-id`,
160+
);
150161
expect(
151162
within(row2Cells[3]).getByRole('link', {
152-
name: 'View live data set for version 3.0 (opens in new tab)',
163+
name: /View live data set for version 3.0/,
153164
}),
154-
).toBeInTheDocument();
165+
).toHaveAttribute(
166+
'href',
167+
'http://localhost/data-catalogue/data-set/version-3-file-id',
168+
);
155169

156170
const row3Cells = within(rows[3]).getAllByRole('cell');
157171
expect(row3Cells[0]).toHaveTextContent('2.0');
158172
expect(
159173
within(row3Cells[1]).getByRole('link', { name: 'Release version 2' }),
160174
).toHaveAttribute(
161175
'href',
162-
`/publication/${testRelease.publicationId}/release/release-version-2-id/summary`,
176+
`/publication/${publicationId}/release/release-v2-id/summary`,
163177
);
164178
expect(row3Cells[2]).toHaveTextContent('Published');
165179
expect(
166180
within(row3Cells[3]).getByRole('link', {
167181
name: 'View changelog for version 2.0',
168182
}),
169-
).toBeInTheDocument();
183+
).toHaveAttribute(
184+
'href',
185+
`/publication/${publicationId}/release/release-v2-id/api-data-sets/data-set-id/changelog/version-2-id`,
186+
);
170187
expect(
171188
within(row3Cells[3]).getByRole('link', {
172-
name: 'View live data set for version 2.0 (opens in new tab)',
189+
name: /View live data set for version 2.0/,
173190
}),
174-
).toBeInTheDocument();
191+
).toHaveAttribute(
192+
'href',
193+
'http://localhost/data-catalogue/data-set/version-2-file-id',
194+
);
175195

176196
const row4Cells = within(rows[4]).getAllByRole('cell');
177197
expect(row4Cells[0]).toHaveTextContent('1.0');
178198
expect(
179199
within(row4Cells[1]).getByRole('link', { name: 'Release version 1' }),
180200
).toHaveAttribute(
181201
'href',
182-
`/publication/${testRelease.publicationId}/release/release-version-1-id/summary`,
202+
`/publication/${publicationId}/release/release-v1-id/summary`,
183203
);
184204
expect(row4Cells[2]).toHaveTextContent('Published');
185205
expect(
@@ -189,12 +209,15 @@ describe('ReleaseApiDataSetVersionHistoryPage', () => {
189209
).not.toBeInTheDocument();
190210
expect(
191211
within(row4Cells[3]).getByRole('link', {
192-
name: 'View live data set for version 1.0 (opens in new tab)',
212+
name: /View live data set for version 1.0/,
193213
}),
194-
).toBeInTheDocument();
214+
).toHaveAttribute(
215+
'href',
216+
'http://localhost/data-catalogue/data-set/version-1-file-id',
217+
);
195218
});
196219

197-
test('pagination', async () => {
220+
test('pagination works correctly', async () => {
198221
apiDataSetService.getDataSet.mockResolvedValue(testDataSet);
199222
apiDataSetVersionService.listVersions.mockResolvedValueOnce({
200223
results: [testVersions[0], testVersions[1]],

0 commit comments

Comments
 (0)