@defra/lis-infra-ui-services 0.23.0 → 0.24.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@defra/lis-infra-ui-services",
3
- "version": "0.23.0",
3
+ "version": "0.24.0",
4
4
  "description": "UI-Services shared definitions for the livestock taxonomy topology.",
5
5
  "main": "src/index.js",
6
6
  "repository": {
@@ -58,10 +58,5 @@ export function catchAll(request, h) {
58
58
  return h.continue
59
59
  }
60
60
  const { view, pageTitle } = errorPageFor(statusCode)
61
- const developmentMessage =
62
- process.env.NODE_ENV === 'development'
63
- ? (response?.message ?? response?.source?.message)
64
- : undefined
65
-
66
- return h.view(view, { pageTitle, developmentMessage }).code(statusCode)
61
+ return h.view(view, { pageTitle }).code(statusCode)
67
62
  }
@@ -83,10 +83,7 @@ test.each([
83
83
  catchAll(request, toolkit)
84
84
 
85
85
  // Assert
86
- assert.deepEqual(toolkit.view.mock.calls[0], [
87
- view,
88
- { pageTitle, developmentMessage: undefined }
89
- ])
86
+ assert.deepEqual(toolkit.view.mock.calls[0], [view, { pageTitle }])
90
87
  assert.deepEqual(toolkit.code.mock.calls[0], [statusCode])
91
88
  }
92
89
  )
@@ -103,8 +100,7 @@ test('catchAll logs server errors and renders the problem with the service page'
103
100
  assert.deepEqual(toolkit.view.mock.calls[0], [
104
101
  'error/problem-with-service',
105
102
  {
106
- pageTitle: 'Sorry, there is a problem with the service',
107
- developmentMessage: undefined
103
+ pageTitle: 'Sorry, there is a problem with the service'
108
104
  }
109
105
  ])
110
106
  assert.deepEqual(toolkit.code.mock.calls[0], [
@@ -143,43 +139,12 @@ test('catchAll prefers a client-attached statusCode over a boomified 500', () =>
143
139
  // Assert
144
140
  assert.deepEqual(toolkit.view.mock.calls[0], [
145
141
  'error/page-not-found',
146
- { pageTitle: 'Page not found', developmentMessage: undefined }
142
+ { pageTitle: 'Page not found' }
147
143
  ])
148
144
  assert.deepEqual(toolkit.code.mock.calls[0], [statusCodes.notFound])
149
145
  assert.equal(logger.error.mock.calls.length, 0)
150
146
  })
151
147
 
152
- test("catchAll passes the error's own message to the page in development", () => {
153
- // Arrange
154
- vi.stubEnv('NODE_ENV', 'development')
155
- const request = createBoomRequest(statusCodes.internalServerError)
156
- request.response.message = 'Upstream timed out'
157
- const toolkit = createToolkit()
158
-
159
- // Act
160
- catchAll(request, toolkit)
161
-
162
- // Assert
163
- assert.equal(
164
- toolkit.view.mock.calls[0][1].developmentMessage,
165
- 'Upstream timed out'
166
- )
167
- })
168
-
169
- test("catchAll leaves out the error's own message outside development", () => {
170
- // Arrange
171
- vi.stubEnv('NODE_ENV', 'production')
172
- const request = createBoomRequest(statusCodes.internalServerError)
173
- request.response.message = 'Upstream timed out'
174
- const toolkit = createToolkit()
175
-
176
- // Act
177
- catchAll(request, toolkit)
178
-
179
- // Assert
180
- assert.equal(toolkit.view.mock.calls[0][1].developmentMessage, undefined)
181
- })
182
-
183
148
  test('catchAll does not log the 503 the maintenance plugin answered with', () => {
184
149
  // Arrange
185
150
  const toolkit = createToolkit()
@@ -160,35 +160,4 @@ describe('error pages', () => {
160
160
  '<a class="govuk-link" href="https://example.com/contact">British Cattle Movement Service (BCMS)</a>'
161
161
  )
162
162
  })
163
-
164
- test('service unavailable says later when no return time is given', () => {
165
- // Arrange
166
- const context = { pageTitle: 'Sorry, the service is unavailable' }
167
-
168
- // Act
169
- const html = render('error/service-unavailable.njk', context)
170
-
171
- // Assert
172
- expect(textOf(html)).toContain('You will be able to use the service later.')
173
- })
174
-
175
- test.each([
176
- 'error/page-not-found.njk',
177
- 'error/not-authorised.njk',
178
- 'error/problem-with-service.njk',
179
- 'error/service-unavailable.njk'
180
- ])('%s shows the development message only when one is given', (view) => {
181
- // Arrange
182
- const withMessage = { developmentMessage: 'Upstream timed out' }
183
-
184
- // Act
185
- const htmlWithMessage = render(view, withMessage)
186
- const htmlWithoutMessage = render(view)
187
-
188
- // Assert
189
- expect(htmlWithMessage).toContain(
190
- '<p class="govuk-body">Upstream timed out</p>'
191
- )
192
- expect(htmlWithoutMessage).not.toContain('Upstream timed out')
193
- })
194
163
  })
@@ -9,9 +9,6 @@
9
9
  {% if signInHref %}
10
10
  <a href="{{ signInHref }}" role="button" draggable="false" class="govuk-button" data-module="govuk-button">Sign in</a>
11
11
  {% endif %}
12
- {% if developmentMessage %}
13
- <p class="govuk-body">{{ developmentMessage }}</p>
14
- {% endif %}
15
12
  </div>
16
13
  </div>
17
14
  {% endblock %}
@@ -12,9 +12,6 @@
12
12
  <li><a class="govuk-link" href="https://www.gov.uk">GOV.UK</a></li>
13
13
  </ul>
14
14
  <p class="govuk-body">If you cannot find the information you need, <a class="govuk-link" href="{{ errorPages.contactHref }}">contact our support team</a>.</p>
15
- {% if developmentMessage %}
16
- <p class="govuk-body">{{ developmentMessage }}</p>
17
- {% endif %}
18
15
  </div>
19
16
  </div>
20
17
  {% endblock %}
@@ -6,9 +6,6 @@
6
6
  <h1 class="govuk-heading-l">Sorry, there is a problem with the service</h1>
7
7
  <p class="govuk-body">Try again later.</p>
8
8
  <p class="govuk-body">Contact the <a class="govuk-link" href="{{ errorPages.contactHref }}">British Cattle Movement Service (BCMS)</a> if you need to speak to someone about your account.</p>
9
- {% if developmentMessage %}
10
- <p class="govuk-body">{{ developmentMessage }}</p>
11
- {% endif %}
12
9
  </div>
13
10
  </div>
14
11
  {% endblock %}
@@ -10,9 +10,6 @@
10
10
  <p class="govuk-body">You will be able to use the service later.</p>
11
11
  {% endif %}
12
12
  <p class="govuk-body">Contact the <a class="govuk-link" href="{{ errorPages.contactHref }}">British Cattle Movement Service (BCMS)</a> if you need to speak to someone about your account.</p>
13
- {% if developmentMessage %}
14
- <p class="govuk-body">{{ developmentMessage }}</p>
15
- {% endif %}
16
13
  </div>
17
14
  </div>
18
15
  {% endblock %}