Skip to content

Commit f45a522

Browse files
authored
Merge pull request #1131 from digital-land/1122-design-implementation-2a-update-dataset-actions-for-get-started
1122 design implementation 2a update dataset actions for get started
2 parents c3797a1 + 80b6aa2 commit f45a522

File tree

6 files changed

+36
-18
lines changed

6 files changed

+36
-18
lines changed

src/serverSetup/nunjucks.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ export function setupNunjucks (opts) {
6161
dataDesignUrl: config.dataDesignUrl,
6262
mainWebsiteUrl: config.mainWebsiteUrl,
6363
govukRebrand: true,
64+
env: config.environment,
6465
...config.templateContent
6566
}
6667

src/views/organisations/dataset-overview.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,9 @@ <h2 class="govuk-heading-m">Dataset details</h2>
202202
<section>
203203
<h2 class="govuk-heading-m">Dataset actions</h2>
204204
<ul class="govuk-list">
205+
<li>
206+
<a class="govuk-link" href="/organisations/{{ organisation.organisation }}/{{ dataset.dataset }}/get-started">How to prepare and provide your {{ dataset.name }} data</a>
207+
</li>
205208
<li>
206209
<a class="govuk-link" href="{{ organisation | checkToolDeepLink(dataset) }}">Check {{ dataset.name }} dataset</a>
207210
</li>

src/views/organisations/get-started.html

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,12 @@ <h2 class="gem-c-step-nav__title">
7676
data is required</a>. Start with
7777
the fields you already have, you can update and
7878
improve your data over time.</p>
79+
{% if env !== 'production' %}
80+
<p class="gem-c-step-nav__paragraph">
81+
If we have data from alternative sources, you can download this from your <a
82+
href="/organisations/{{ organisation.organisation }}/{{ dataset.dataset }}/overview">dataset details</a> page to help you get started.
83+
</p>
84+
{% endif %}
7985
</div>
8086

8187
</li>

test/acceptance/dataset_overview.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ test.describe('Dataset overview', () => {
4545

4646
expect(await page.getByRole('h2', { name: 'Dataset actions' })).toBeDefined()
4747
expect(await page.locator('.govuk-grid-column-one-third .govuk-list').count()).toEqual(1)
48-
expect(await page.locator('.govuk-grid-column-one-third .govuk-list li').count()).toEqual(2)
48+
expect(await page.locator('.govuk-grid-column-one-third .govuk-list li').count()).toEqual(3)
4949
})
5050

5151
test('Can view dataset tables', async ({ page, context }) => {

test/unit/views/organisations/dataset-overview.test.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -180,10 +180,13 @@ describe('Dataset Overview Page', () => {
180180

181181
expect(header.textContent.trim()).toEqual('Dataset actions')
182182

183-
expect(links[0].textContent.trim()).toEqual('Check Article 4 direction area dataset')
184-
expect(links[0].querySelector('.govuk-link').href).toEqual('/check/link?dataset=article-4-direction-area&orgName=Mock%20org&orgId=mock-org')
183+
expect(links[0].textContent.trim()).toEqual('How to prepare and provide your Article 4 direction area data')
184+
expect(links[0].querySelector('.govuk-link').href).toEqual('/organisations/mock-org/article-4-direction-area/get-started')
185185

186-
expect(links[1].textContent.trim()).toEqual('Article 4 direction area guidance')
187-
expect(links[1].querySelector('.govuk-link').href).toEqual('/guidance/specifications/article-4-direction')
186+
expect(links[1].textContent.trim()).toEqual('Check Article 4 direction area dataset')
187+
expect(links[1].querySelector('.govuk-link').href).toEqual('/check/link?dataset=article-4-direction-area&orgName=Mock%20org&orgId=mock-org')
188+
189+
expect(links[2].textContent.trim()).toEqual('Article 4 direction area guidance')
190+
expect(links[2].querySelector('.govuk-link').href).toEqual('/guidance/specifications/article-4-direction')
188191
})
189192
})

test/unit/views/organisations/lpaOverviewPage.test.js

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -73,16 +73,12 @@ describe(`LPA Overview Page (seed: ${seed})`, () => {
7373
}
7474
})
7575

76-
it('The correct number of dataset cards are rendered with the correct titles in group "expected"', () => {
77-
if (params.datasets.expected && params.datasets.expected.length > 0) {
78-
datasetGroup({ expect }, 'expected', params.datasets.expected, document)
79-
}
76+
it.skipIf(!params.datasets.expected || params.datasets.expected.length === 0)('The correct number of dataset cards are rendered with the correct titles in group "expected"', () => {
77+
datasetGroup({ expect }, 'expected', params.datasets.expected, document)
8078
})
8179

82-
it('The correct number of dataset cards are rendered with the correct titles in group "prospective"', () => {
83-
if (params.datasets.prospective && params.datasets.prospective.length > 0) {
84-
datasetGroup({ expect }, 'prospective', params.datasets.prospective, document)
85-
}
80+
it.skipIf(!params.datasets.prospective || params.datasets.prospective.length === 0)('The correct number of dataset cards are rendered with the correct titles in group "prospective"', () => {
81+
datasetGroup({ expect }, 'prospective', params.datasets.prospective, document)
8682
})
8783

8884
const allDatasets = [
@@ -136,29 +132,38 @@ describe(`LPA Overview Page (seed: ${seed})`, () => {
136132
})
137133
})
138134

139-
const datasetCards = document.querySelectorAll('li[data-dataset]:not(:empty)')
140-
allDatasets.forEach((dataset, i) => {
135+
allDatasets.forEach((dataset) => {
141136
it(`Renders the correct status on each dataset card for dataset='${dataset.dataset}'`, () => {
137+
const datasetCard = document.querySelector(`li[data-dataset="${dataset.dataset}"]`)
138+
if (!datasetCard) {
139+
throw new Error(`Dataset card for "${dataset.dataset}" not found in rendered HTML`)
140+
}
141+
142142
if (!(dataset.status in datasetStatusEnum)) {
143143
throw new Error(`Unknown dataset status: ${dataset.status}`)
144144
}
145145

146146
const expectedStatus = datasetStatusEnum[dataset.status]
147147

148-
const statusIndicator = datasetCards[i].querySelector('.govuk-task-list__status')
148+
const statusIndicator = datasetCard.querySelector('.govuk-task-list__status')
149149
expect(statusIndicator.textContent.trim()).toContain(expectedStatus)
150150
})
151151

152152
it(`Renders the correct link on each dataset card for dataset='${dataset.dataset}'`, () => {
153-
const expectedLink = datasetCards[i].querySelector('.govuk-task-list__link').href
153+
const datasetCard = document.querySelector(`li[data-dataset="${dataset.dataset}"]`)
154+
if (!datasetCard) {
155+
throw new Error(`Dataset card for "${dataset.dataset}" not found in rendered HTML`)
156+
}
157+
158+
const expectedLink = datasetCard.querySelector('.govuk-task-list__link').href
154159

155160
if (dataset.status === 'Not submitted') {
156161
expect(expectedLink).toEqual(`/organisations/${params.organisation.organisation}/${dataset.dataset}/get-started`)
157162
} else {
158163
expect(expectedLink).toEqual(`/organisations/${params.organisation.organisation}/${dataset.dataset}/overview`)
159164
}
160165

161-
const link = datasetCards[i].querySelector('.govuk-link')
166+
const link = datasetCard.querySelector('.govuk-link')
162167
expect(link.href).toContain(expectedLink)
163168
})
164169
})

0 commit comments

Comments
 (0)