Skip to content

Commit a2efd66

Browse files
authored
Merge pull request #1173 from digital-land/1059-update-designs-for-multiple-endpoints
1059 update designs for multiple endpoints
2 parents a17f2ec + e9ec1aa commit a2efd66

5 files changed

Lines changed: 100 additions & 88 deletions

File tree

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,4 +150,6 @@ uploads/*
150150
npm-audit-report.json
151151
.cursor/rules/*
152152

153-
github-pages
153+
github-pages
154+
155+
.history

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/views/organisations/dataset-overview.html

Lines changed: 67 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@
1010
/organisations/{{ organisation.organisation | urlencode }}/{{ dataset.dataset | urlencode }}/endpoint-error/{{ endpoint.endpoint | urlencode }}
1111
{% endmacro %}
1212

13-
{% macro lastAccessedInfo(organisation, dataset, endpoint) %}
14-
{{endpoint.lastAccessed | govukDateTime}}
15-
<br>
13+
{% macro endpointUrlWithError(organisation, dataset, endpoint) %}
14+
<a style="{{ urlStyle}}" href="{{ endpoint.endpoint_url }}">{{ endpoint.endpoint_url }}</a>
15+
1616
<p class="govuk-error-message">
17-
<a href="{{ datasetUrl(organisation, dataset, endpoint) }}">{{ endpointErrorMessage(endpoint) }}</a>
17+
{{ endpointErrorMessage(endpoint) }}
1818
</p>
19-
<p class="app-inset-text__error"></p>
19+
2020
{% endmacro %}
2121

2222
{% from "govuk/components/breadcrumbs/macro.njk" import govukBreadcrumbs %}
@@ -66,7 +66,7 @@
6666
{% set rows = [
6767
{
6868
key: {
69-
text: "Number of records"
69+
text: "Number of records supplied"
7070
},
7171
value: {
7272
text: stats.numberOfRecords | default(0)
@@ -103,7 +103,6 @@
103103
{% endif %}
104104
{% set _ = rows.push(alternateSourcesRow) %}
105105
{% endif %}
106-
107106
{% if authority !== 'some' %}
108107
{% set licenceRow = {
109108
key: {
@@ -114,76 +113,66 @@
114113
}
115114
} %}
116115
{{ rows.push(licenceRow) }}
116+
{% endif %}
117117

118+
{% set endpointCount = 0 %}
119+
{% set endpointSummaryCards = [] %}
120+
{% if authority !== 'some' %}
121+
{% set endpointCount = stats.endpoints | length %}
118122
{% for endpoint in stats.endpoints %}
119-
{% set endpointRow = {
120-
key: {
121-
text: 'Endpoint URL',
122-
classes: 'padding-top'
123-
},
124-
value: {
125-
html: '<a style="'+urlStyle+'" href="'+endpoint.endpoint_url+'">'+endpoint.endpoint_url+'</a>'
126-
},
127-
classes: 'padding-top'
128-
} %}
129-
{{ rows.push(endpointRow) }}
130-
131-
{% if endpoint.documentation_url %}
132-
{% set documentationRow = {
133-
key: {
134-
text: 'Documentation URL'
135-
},
136-
value: {
137-
html: '<a style="'+urlStyle+'" href="'+endpoint.documentation_url+'">'+endpoint.documentation_url+'</a>'
138-
}
139-
} %}
140-
{{ rows.push(documentationRow) }}
141-
{% endif %}
142-
123+
{% set endpointRows = [] %}
143124
{% if endpoint.error %}
144-
{% set lastAccessedRow = {
145-
key: {
146-
text: 'Endpoint URL last accessed',
147-
classes: 'app-inset-text---error'
148-
},
149-
value: {
150-
html: lastAccessedInfo(organisation, dataset, endpoint)
151-
}
152-
} %}
125+
{% set _ = endpointRows.push({
126+
key: { text: "Endpoint URL" },
127+
value: { html: endpointUrlWithError(organisation, dataset, endpoint) },
128+
classes: 'app-inset-text---error dl-summary-card-list__row--error'
129+
}) %}
153130
{% else %}
154-
{% set lastAccessedRow = {
155-
key: {
156-
text: 'Endpoint URL last accessed'
157-
},
158-
value: {
159-
text: endpoint.lastAccessed | govukDateTime
160-
}
161-
} %}
131+
{% set endpointUrlHtml %}
132+
<a style="{{ urlStyle }}" href="{{ endpoint.endpoint_url }}">{{ endpoint.endpoint_url }}</a>
133+
{% endset %}
134+
{% set _ = endpointRows.push({
135+
key: { text: "Endpoint URL" },
136+
value: { html: endpointUrlHtml }
137+
}) %}
162138
{% endif %}
163139

140+
{% if not endpoint.documentation_url %}
141+
{% set _ = endpointRows.push({
142+
key: { text: "Webpage URL" },
143+
value: { html: '<p class="govuk-error-message" > Documentation URL missing</p>' },
144+
classes: 'app-inset-text---error dl-summary-card-list__row--error'
145+
}) %}
146+
{% else %}
147+
{% set documentationUrlHtml %}
148+
<a style="{{ urlStyle }}" href="{{ endpoint.documentation_url }}">{{ endpoint.documentation_url }}</a>
149+
{% endset %}
150+
{% set _ = endpointRows.push({
151+
key: { text: "Webpage URL" },
152+
value: { html: documentationUrlHtml }
153+
}) %}
154+
{% endif %}
164155

165-
{{ rows.push(lastAccessedRow) }}
166-
167-
{% set lastUpdatedRow = {
168-
key: {
169-
text: 'Endpoint URL last updated'
170-
},
171-
value: {
172-
text: endpoint.lastUpdated and ( endpoint.lastUpdated | govukDateTime )
173-
}
174-
} %}
175-
{{ rows.push(lastUpdatedRow) }}
156+
{% set _ = endpointRows.push({
157+
key: { text: "Date added" },
158+
value: { text: endpoint.entryDate and (endpoint.entryDate | govukDateTime) }
159+
}) %}
160+
{% set _ = endpointRows.push({
161+
key: { text: "Endpoint last accessed" },
162+
value: { text: endpoint.lastAccessed and (endpoint.lastAccessed | govukDateTime) }
163+
}) %}
164+
{% set _ = endpointRows.push({
165+
key: { text: "Endpoint last updated" },
166+
value: { text: endpoint.lastUpdated and (endpoint.lastUpdated | govukDateTime) }
167+
}) %}
176168

177-
{% set entryDateRow = {
178-
key: {
179-
text: 'Endpoint entry date'
169+
{% set endpointDisplayIndex = endpointCount - loop.index0 %}
170+
{% set _ = endpointSummaryCards.push({
171+
card: {
172+
title: { text: "Endpoint " ~ endpointDisplayIndex }
180173
},
181-
value: {
182-
text: endpoint.entryDate and ( endpoint.entryDate | govukDateTime )
183-
}
184-
} %}
185-
{{ rows.push(entryDateRow) }}
186-
174+
rows: endpointRows
175+
}) %}
187176
{% endfor %}
188177
{% endif %}
189178

@@ -218,6 +207,15 @@ <h2 class="govuk-heading-m govuk-visually-hidden">Map of dataset</h2>
218207
<h2 class="govuk-heading-m">Dataset details</h2>
219208
{{ govukSummaryList({ rows: rows }) }}
220209
</section>
210+
{% if authority !== 'some' %}
211+
<section>
212+
<h2 class="govuk-heading-m">Active endpoints</h2>
213+
<p class="govuk-body">You have {{ endpointCount }} endpoint{% if endpointCount != 1 %}s{% endif %} we are currently checking for data.</p>
214+
{% for endpointSummaryCard in endpointSummaryCards %}
215+
{{ govukSummaryList(endpointSummaryCard) }}
216+
{% endfor %}
217+
</section>
218+
{% endif %}
221219
{% if authority === "some" %}
222220
{{ alternativeSourceNotice(organisation, dataset, downloadUrl, alternateSources) }}
223221
{% endif %}
@@ -266,4 +264,4 @@ <h2 class="govuk-heading-m">Dataset actions</h2>
266264
</script>
267265
<script src="/public/js/map.bundle.js"></script>
268266
{% endif %}
269-
{% endblock %}
267+
{% endblock %}

test/acceptance/dataset_overview.test.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ test.describe('Dataset overview', () => {
4141
expect(await page.getByRole('link', { name: 'Task list' })).toBeDefined()
4242

4343
expect(await page.getByRole('h2', { name: 'Dataset details' })).toBeDefined()
44-
expect(await page.locator('.govuk-grid-column-two-thirds .govuk-summary-list').count()).toEqual(1)
44+
expect(await page.getByRole('h2', { name: 'Active endpoints' })).toBeDefined()
45+
expect(await page.locator('.govuk-grid-column-two-thirds .govuk-summary-list').count()).toBeGreaterThanOrEqual(2)
4546

4647
expect(await page.getByRole('h2', { name: 'Dataset actions' })).toBeDefined()
4748
expect(await page.locator('.govuk-grid-column-one-third .govuk-list').count()).toEqual(1)

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

Lines changed: 27 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ describe('Dataset Overview Page', () => {
3737
name: 'endpoint 2',
3838
endpoint: 'BAR',
3939
endpoint_url: 'http://endpoint2.co.uk',
40-
lastAccessed: '2024-19-19',
41-
lastUpdated: '2024-19-19',
40+
lastAccessed: '2024-09-19',
41+
lastUpdated: '2024-09-19',
4242
entryDate: '2024-12-12',
4343
error: {
4444
code: 404,
@@ -77,20 +77,31 @@ describe('Dataset Overview Page', () => {
7777

7878
it('Renders dataset details correctly', () => {
7979
expect(document.querySelector('#main-content h2.govuk-heading-m').textContent).toContain('Dataset details')
80-
const summaryListValues = document.querySelectorAll('dd.govuk-summary-list__value')
81-
82-
expect(summaryListValues[0].textContent.trim()).toEqual(params.stats.numberOfRecords.toString())
83-
expect(summaryListValues[1].textContent.trim()).toEqual('Open Government Licence')
84-
expect(summaryListValues[2].textContent).toContain(params.stats.endpoints[0].endpoint_url)
85-
expect(summaryListValues[3].textContent).toContain(params.stats.endpoints[0].documentation_url)
86-
expect(summaryListValues[4].textContent).toContain(govukDateTime(params.stats.endpoints[0].lastAccessed))
87-
expect(summaryListValues[5].textContent).toContain(govukDateTime(params.stats.endpoints[0].lastUpdated))
88-
expect(summaryListValues[6].textContent).toContain(govukDateTime(params.stats.endpoints[0].entryDate))
89-
expect(summaryListValues[7].textContent).toContain(params.stats.endpoints[1].endpoint_url)
90-
expect(summaryListValues[8].textContent).toContain(govukDateTime(params.stats.endpoints[1].lastAccessed))
91-
expect(summaryListValues[8].textContent).toContain(params.stats.endpoints[1].error.code)
92-
expect(summaryListValues[9].textContent).toContain(govukDateTime(params.stats.endpoints[1].lastUpdated))
93-
expect(summaryListValues[10].textContent).toContain(govukDateTime(params.stats.endpoints[1].entryDate))
80+
const summaryLists = document.querySelectorAll('.govuk-summary-list')
81+
82+
expect(summaryLists.length).toEqual(3)
83+
expect(summaryLists[0].textContent).toContain(params.stats.numberOfRecords.toString())
84+
})
85+
86+
it('Renders active endpoint cards in descending order', () => {
87+
const endpointCards = document.querySelectorAll('.govuk-summary-card')
88+
const endpointTitles = document.querySelectorAll('.govuk-summary-card__title')
89+
90+
expect(endpointCards.length).toEqual(2)
91+
expect(endpointTitles[0].textContent.trim()).toEqual('Endpoint 2')
92+
expect(endpointTitles[1].textContent.trim()).toEqual('Endpoint 1')
93+
94+
expect(endpointCards[0].textContent).toContain(params.stats.endpoints[0].endpoint_url)
95+
expect(endpointCards[0].textContent).toContain(params.stats.endpoints[0].documentation_url)
96+
expect(endpointCards[0].textContent).toContain(govukDateTime(params.stats.endpoints[0].lastAccessed))
97+
expect(endpointCards[0].textContent).toContain(govukDateTime(params.stats.endpoints[0].lastUpdated))
98+
expect(endpointCards[0].textContent).toContain(govukDateTime(params.stats.endpoints[0].entryDate))
99+
100+
expect(endpointCards[1].textContent).toContain(params.stats.endpoints[1].endpoint_url)
101+
expect(endpointCards[1].textContent).toContain(govukDateTime(params.stats.endpoints[1].lastAccessed))
102+
expect(endpointCards[1].textContent).toContain(params.stats.endpoints[1].error.code)
103+
expect(endpointCards[1].textContent).toContain(govukDateTime(params.stats.endpoints[1].lastUpdated))
104+
expect(endpointCards[1].textContent).toContain(govukDateTime(params.stats.endpoints[1].entryDate))
94105
})
95106

96107
it('Renders breadcrumbs correctly', () => {

0 commit comments

Comments
 (0)