-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #264 from digital-land/feat/endpointError/template
Feat/endpoint error/template
- Loading branch information
Showing
5 changed files
with
160 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
{% from "govuk/components/summary-list/macro.njk" import govukSummaryList %} | ||
|
||
{% extends "layouts/main.html" %} | ||
|
||
{% set pageName %}{{organisation.name}} - {{dataset.name}} - Task list{% endset %} | ||
{% set serviceType = 'manage' %} | ||
|
||
{% block content %} | ||
|
||
<div class="govuk-grid-row"> | ||
{% include "includes/_dataset-page-header.html" %} | ||
</div> | ||
|
||
<div class="govuk-grid-row"> | ||
<div class="govuk-grid-column-two-thirds"> | ||
<h2 class="govuk-heading-l"> | ||
Error accessing data URL | ||
</h2> | ||
|
||
<p>There was an error accessing the data URL. Please check the URL is correct and your API is functioning correctly. | ||
</p> | ||
|
||
<h3 class="govuk-heading-m">Error details</h3> | ||
|
||
{{ govukSummaryList({ | ||
rows: [ | ||
{ | ||
key: { | ||
text: "Data URL" | ||
}, | ||
value: { | ||
html: '<code>' + errorData.endpoint_url + '</code>' | ||
} | ||
}, | ||
{ | ||
key: { | ||
text: "HTTP status" | ||
}, | ||
value: { | ||
text: errorData.http_status | ||
} | ||
}, | ||
{ | ||
key: { | ||
text: "Last attempted access" | ||
}, | ||
value: { | ||
text: errorData.latest_log_entry_date | govukDateTime | ||
} | ||
}, | ||
{ | ||
key: { | ||
text: "Last successful access" | ||
}, | ||
value: { | ||
text: errorData.latest_200_date | govukDateTime | ||
} | ||
} | ||
] | ||
}) }} | ||
|
||
<p>If your data URL has changed you can <a href="https://check.staging.digital-land.info/submit">resubmit your data URL</a>.</p> | ||
|
||
<p>You should try to make sure your data URLs stay the same when you update your data so we can collect your data | ||
each night.</p> | ||
|
||
</div> | ||
</div> | ||
|
||
|
||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import { describe, it, expect } from 'vitest' | ||
import nunjucks from 'nunjucks' | ||
import addFilters from '../../src/filters/filters' | ||
import { JSDOM } from 'jsdom' | ||
import { runGenericPageTests } from './generic-page.js' | ||
|
||
const nunjucksEnv = nunjucks.configure([ | ||
'src/views', | ||
'src/views/check', | ||
'src/views/submit', | ||
'node_modules/govuk-frontend/dist/', | ||
'node_modules/@x-govuk/govuk-prototype-components/' | ||
], { | ||
dev: true, | ||
noCache: true, | ||
watch: true | ||
}) | ||
|
||
const datasetNameMapping = new Map() | ||
addFilters(nunjucksEnv, { datasetNameMapping }) | ||
|
||
describe('http-error.html', () => { | ||
const params = { | ||
organisation: { | ||
name: 'mock org' | ||
}, | ||
dataset: { | ||
name: 'mock dataset' | ||
}, | ||
errorData: { | ||
endpoint_url: 'https://example.com/data-url', | ||
http_status: 404, | ||
latest_log_entry_date: '2022-01-01T12:00:00Z', | ||
latest_200_date: '2022-01-02T12:00:00Z' | ||
} | ||
} | ||
|
||
const html = nunjucks.render('organisations/http-error.html', params) | ||
const dom = new JSDOM(html) | ||
const document = dom.window.document | ||
|
||
runGenericPageTests(html, { | ||
pageTitle: 'mock org - mock dataset - Task list - Submit and update your planning data' | ||
}) | ||
|
||
it('Renders the correct heading', () => { | ||
expect(document.querySelector('h2').textContent).toContain('Error accessing data URL') | ||
}) | ||
|
||
it('Renders the error details summary list', () => { | ||
const summaryList = document.querySelector('.govuk-summary-list') | ||
const rows = [...summaryList.children] | ||
|
||
expect(rows.length).toBe(4) | ||
|
||
expect(rows[0].querySelector('.govuk-summary-list__key').textContent).toContain('Data URL') | ||
expect(rows[0].querySelector('.govuk-summary-list__value').innerHTML).toContain(params.errorData.endpoint_url) | ||
|
||
expect(rows[1].querySelector('.govuk-summary-list__key').textContent).toContain('HTTP status') | ||
expect(rows[1].querySelector('.govuk-summary-list__value').textContent).toContain(String(params.errorData.http_status)) | ||
|
||
expect(rows[2].querySelector('.govuk-summary-list__key').textContent).toContain('Last attempted access') | ||
expect(rows[2].querySelector('.govuk-summary-list__value').textContent).toMatch(/\d{1,2} [A-Za-z]{3,9} \d{4} at \d{1,2}(am|pm)/) | ||
|
||
expect(rows[3].querySelector('.govuk-summary-list__key').textContent).toContain('Last successful access') | ||
expect(rows[3].querySelector('.govuk-summary-list__value').textContent).toMatch(/\d{1,2} [A-Za-z]{3,9} \d{4} at \d{1,2}(am|pm)/) | ||
}) | ||
}) |