-
Notifications
You must be signed in to change notification settings - Fork 236
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 #2071 from alphagov/tidier-more-informative-errors
Tidier more informative errors
- Loading branch information
Showing
11 changed files
with
207 additions
and
8 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head><title>{% block pageTitle %}{% endblock %}</title></head> | ||
<body><main{% if mainClasses %} class="{{ mainClasses }}"{% endif %}>{% block content %}{% endblock %}</main></body> | ||
</html> | ||
|
||
|
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
24 changes: 24 additions & 0 deletions
24
cypress/e2e/dev/7-error-page-tests/page-not-found-error.cypress.js
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,24 @@ | ||
const { waitForApplication } = require('../../utils') | ||
|
||
const pageName = 'Page not found' | ||
const checkPageNotFoundText = 'There is no page at /p4ge-n0t-f0und' | ||
const helpText = 'This may be because:' | ||
const helpList = [ | ||
'you typed or pasted the web address incorrectly', | ||
'a link in your code is wrong', | ||
'a form in your code is wrong', | ||
'you have not created the page yet'] | ||
const contactSupportText = 'You can try and fix this yourself or contact the GOV.UK Prototype Kit team if you need help.' | ||
|
||
it('internal server error results in 500 page being displayed correctly', () => { | ||
waitForApplication() | ||
|
||
cy.visit('/p4ge-n0t-f0und', { failOnStatusCode: false }) | ||
cy.get('.govuk-heading-l').contains(pageName) | ||
cy.get('.govuk-body').contains(checkPageNotFoundText) | ||
cy.get('.govuk-body').contains(helpText) | ||
for (const hint of helpList) { | ||
cy.get('li').contains(hint) | ||
} | ||
cy.get('.govuk-body').contains(contactSupportText) | ||
}) |
40 changes: 40 additions & 0 deletions
40
cypress/e2e/dev/7-error-page-tests/server-error.cypress.js
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,40 @@ | ||
const path = require('path') | ||
const { waitForApplication } = require('../../utils') | ||
const routesFixture = path.join(Cypress.config('fixturesFolder'), 'routes.js') | ||
const appRoutesPath = path.join('app', 'routes.js') | ||
const appRoutes = path.join(Cypress.env('projectFolder'), appRoutesPath) | ||
|
||
const pageName = 'There is an error in your code' | ||
const contactSupportText = 'You can try and fix this yourself or contact the GOV.UK Prototype Kit team if you need help.' | ||
|
||
const templateNotFoundText = 'template not found: test-page.html' | ||
|
||
describe('Server Error Test', () => { | ||
before(() => { | ||
cy.task('log', `Replace ${appRoutes} with Cypress routes`) | ||
cy.task('copyFile', { source: routesFixture, target: appRoutes }) | ||
}) | ||
|
||
after(() => { | ||
cy.task('log', `Restore ${appRoutesPath}`) | ||
cy.task('copyFromStarterFiles', { filename: appRoutesPath }) | ||
}) | ||
|
||
it('internal server error results in 500 page being displayed correctly', () => { | ||
waitForApplication() | ||
|
||
cy.visit('/error', { failOnStatusCode: false }) | ||
|
||
cy.get('.govuk-heading-l').contains(pageName) | ||
cy.get('.govuk-body').contains(contactSupportText) | ||
}) | ||
it('shows an error if a template cannot be found', () => { | ||
waitForApplication() | ||
|
||
cy.visit('/test-page', { failOnStatusCode: false }) | ||
|
||
cy.get('.govuk-heading-l').contains(pageName) | ||
cy.get('.govuk-body').contains(contactSupportText) | ||
cy.get('code').contains(templateNotFoundText) | ||
}) | ||
}) |
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,29 @@ | ||
{% extends "govuk-prototype-kit/layouts/govuk-branded.njk" %} | ||
|
||
{% block pageTitle %} | ||
Page not found – {{ serviceName }} – GOV.UK Prototype Kit | ||
{% endblock %} | ||
{% set mainClasses = "govuk-main-wrapper--l" %} | ||
|
||
{% block content %} | ||
|
||
<div class="govuk-grid-row"> | ||
<div class="govuk-grid-column-two-thirds"> | ||
|
||
<h1 class="govuk-heading-l">Page not found</h1> | ||
<p class="govuk-body"> | ||
There is no page at <strong>{{ path }}</strong> | ||
</p> | ||
<p class="govuk-body">This may be because:</p> | ||
<ul class="govuk-list govuk-list--bullet"> | ||
<li>you typed or pasted the web address incorrectly</li> | ||
<li>a link in your code is wrong</li> | ||
<li>a form in your code is wrong</li> | ||
<li>you have not created the page yet</li> | ||
</ul> | ||
<p class="govuk-body"> | ||
You can try and fix this yourself or <a class="govuk-link" href="https://prototype-kit.service.gov.uk/docs/support">contact the GOV.UK Prototype Kit team</a> if you need help. | ||
</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,20 @@ | ||
{% extends "govuk-prototype-kit/layouts/govuk-branded.njk" %} | ||
|
||
{% block pageTitle %} | ||
Error – {{ serviceName }} – GOV.UK Prototype Kit | ||
{% endblock %} | ||
|
||
{% block content %} | ||
|
||
<div class="govuk-grid-row"> | ||
<div class="govuk-grid-column-two-thirds"> | ||
<h1 class="govuk-heading-l">There is an error in your code</h1> | ||
<p class="govuk-body"> | ||
You can try and fix this yourself or <a class="govuk-link" href="https://prototype-kit.service.gov.uk/docs/support">contact the GOV.UK Prototype Kit team</a> if you need help. | ||
</p> | ||
<pre><code>{{ errorStack }}</code></pre> | ||
</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