@defra/lis-infra-ui-services 0.28.0 → 0.29.0-lreg-665.alpha.2

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.28.0",
3
+ "version": "0.29.0-lreg-665.alpha.2",
4
4
  "description": "UI-Services shared definitions for the livestock taxonomy topology.",
5
5
  "main": "src/index.js",
6
6
  "repository": {
@@ -1,5 +1,5 @@
1
1
  @use 'accessible-autocomplete/dist/accessible-autocomplete.min.css';
2
- @use 'govuk-frontend' as *;
2
+ @use 'govuk-frontend/dist/govuk/base' as *;
3
3
 
4
4
  .app-autocomplete .autocomplete__input.govuk-input--error,
5
5
  .app-autocomplete .autocomplete__hint.govuk-input--error {
@@ -1,6 +1,10 @@
1
1
  // Modelled on govuk_publishing_components' gem-c-search (large, on-white
2
2
  // variant): https://github.com/alphagov/govuk_publishing_components
3
- @use 'govuk-frontend' as *;
3
+ // Only govuk-frontend's settings, tools and helpers are used here, never its
4
+ // full entry point: that emits every govuk rule again wherever it resolves to
5
+ // a second copy of the package (a symlinked install does), and the repeat
6
+ // lands after this package's rules and overrides them.
7
+ @use 'govuk-frontend/dist/govuk/base' as *;
4
8
 
5
9
  $lis-search-form-input-size: 50px;
6
10
 
@@ -1,5 +1,8 @@
1
1
  /* Pushes the Sign out item to the end of the service navigation bar.
2
- base.njk renders it with the app-service-navigation__item--right class. */
2
+ base.njk renders it with the app-service-navigation__item--right class.
3
+ govuk-frontend lays the list out as a flex row from tablet up, so an auto
4
+ margin is all it takes. This file deliberately uses nothing from
5
+ govuk-frontend: see the note in search-form.scss. */
3
6
  .app-service-navigation__item--right {
4
7
  margin-left: auto;
5
8
  }
@@ -1,4 +1,4 @@
1
- @use 'govuk-frontend' as *;
1
+ @use 'govuk-frontend/dist/govuk/base' as *;
2
2
 
3
3
  .lis-sortable-table__link {
4
4
  display: inline-flex;
@@ -1,4 +1,4 @@
1
- @use 'govuk-frontend' as *;
1
+ @use 'govuk-frontend/dist/govuk/base' as *;
2
2
 
3
3
  .lis-sub-navigation {
4
4
  margin-bottom: govuk-spacing(6);
@@ -85,6 +85,34 @@ describe('error pages', () => {
85
85
  expect(html).not.toContain('Sign in')
86
86
  })
87
87
 
88
+ test('not authorised offers a sign out button when signOutHref is given', () => {
89
+ // Arrange
90
+ const context = { signOutHref: '/signout' }
91
+
92
+ // Act
93
+ const html = render('error/not-authorised.njk', context)
94
+
95
+ // Assert
96
+ expect(html).toContain(
97
+ '<a href="/signout" role="button" draggable="false" class="govuk-button" data-module="govuk-button">Sign out</a>'
98
+ )
99
+ expect(html).not.toContain('Sign in')
100
+ })
101
+
102
+ test('not authorised prefers sign out over sign in when both are given', () => {
103
+ // Arrange
104
+ const context = { signInHref: '/auth/login', signOutHref: '/signout' }
105
+
106
+ // Act
107
+ const html = render('error/not-authorised.njk', context)
108
+
109
+ // Assert
110
+ expect(html).toContain('href="/signout"')
111
+ expect(html).toContain('Sign out')
112
+ expect(html).not.toContain('Sign in')
113
+ expect(html).not.toContain('/auth/login')
114
+ })
115
+
88
116
  test('not authorised shows the heading and the support link', () => {
89
117
  // Arrange
90
118
  const context = {
@@ -6,7 +6,9 @@
6
6
  <h1 class="govuk-heading-l">Sorry, you are not authorised to view this page</h1>
7
7
  <p class="govuk-body">Check your details are correct and try again.</p>
8
8
  <p class="govuk-body">If you think this is incorrect <a class="govuk-link" href="{{ errorPages.contactHref }}">contact our support team</a>.</p>
9
- {% if signInHref %}
9
+ {% if signOutHref %}
10
+ <a href="{{ signOutHref }}" role="button" draggable="false" class="govuk-button" data-module="govuk-button">Sign out</a>
11
+ {% elif signInHref %}
10
12
  <a href="{{ signInHref }}" role="button" draggable="false" class="govuk-button" data-module="govuk-button">Sign in</a>
11
13
  {% endif %}
12
14
  </div>