generated from ministryofjustice/hmpps-template-typescript
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
32 changed files
with
441 additions
and
31 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,11 @@ | ||
function Card(container) { | ||
this.container = container | ||
|
||
if (this.container.querySelector('a') !== null) { | ||
this.container.addEventListener('click', () => { | ||
this.container.querySelector('a').click() | ||
}) | ||
} | ||
} | ||
|
||
export default Card |
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 |
---|---|---|
@@ -1,5 +1,12 @@ | ||
import * as govukFrontend from 'govuk-frontend' | ||
import * as mojFrontend from '@ministryofjustice/frontend' | ||
import Card from './card' | ||
import { nodeListForEach } from './utils' | ||
|
||
govukFrontend.initAll() | ||
mojFrontend.initAll() | ||
|
||
var $cards = document.querySelectorAll('.card--clickable') | ||
nodeListForEach($cards, function ($card) { | ||
new Card($card) | ||
}) |
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,10 @@ | ||
function nodeListForEach(nodes, callback) { | ||
if (window.NodeList.prototype.forEach) { | ||
return nodes.forEach(callback) | ||
} | ||
for (var i = 0; i < nodes.length; i++) { | ||
callback.call(window, nodes[i], i, nodes) | ||
} | ||
} | ||
|
||
export { nodeListForEach } |
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,98 @@ | ||
/* ========================================================================== | ||
COMPONENTS / #CARD | ||
========================================================================== */ | ||
|
||
$card-border-width: 1px; | ||
$card-border-bottom-width: govuk-spacing(1); | ||
$card-border-hover-color: $govuk-border-colour; | ||
$card-border-color: lighten($card-border-hover-color, 15%); | ||
|
||
.card { | ||
margin-bottom: govuk-spacing(7); | ||
background: $govuk-body-background-colour; | ||
border: $card-border-width solid $card-border-color; | ||
position: relative; | ||
width: 100%; | ||
padding: govuk-spacing(5); | ||
|
||
&__heading { | ||
margin-top: 0; | ||
margin-bottom: govuk-spacing(3); | ||
} | ||
|
||
&__description { | ||
margin-bottom: 0; | ||
} | ||
|
||
/* Clickable card | ||
========================================================================== */ | ||
&--clickable { | ||
border-bottom-width: $card-border-bottom-width; | ||
|
||
&:hover, | ||
&:active { | ||
cursor: pointer; | ||
|
||
.card__heading a, | ||
.card__link { | ||
color: $govuk-link-hover-colour; | ||
text-decoration: none; | ||
|
||
&:focus { | ||
@include govuk-focused-text; | ||
} | ||
} | ||
} | ||
|
||
&:hover { | ||
border-color: $card-border-hover-color; | ||
} | ||
|
||
&:active { | ||
border-color: $card-border-hover-color; | ||
bottom: -$card-border-width; | ||
} | ||
} | ||
} | ||
|
||
/* Card group | ||
========================================================================== */ | ||
|
||
/** | ||
* A card group allows you to have a row of cards. | ||
* Flexbox is used to make each card in a row the same height. | ||
*/ | ||
|
||
.card-group { | ||
display: flex; | ||
flex-wrap: wrap; | ||
margin-bottom: govuk-spacing(3); | ||
padding: 0; | ||
|
||
@include govuk-media-query($until: desktop) { | ||
margin-bottom: govuk-spacing(6); | ||
} | ||
|
||
&__item { | ||
display: flex; | ||
list-style-type: none; | ||
margin-bottom: 0; | ||
|
||
@include govuk-media-query($until: desktop) { | ||
flex: 0 0 100%; | ||
} | ||
.card { | ||
margin-bottom: govuk-spacing(5); | ||
} | ||
|
||
@include govuk-media-query($until: desktop) { | ||
.card { | ||
margin-bottom: govuk-spacing(3); | ||
} | ||
|
||
&:last-child .card { | ||
margin-bottom: 0; | ||
} | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -1,3 +1,22 @@ | ||
.govuk-main-wrapper { | ||
min-height: 600px; | ||
} | ||
|
||
.homepage-content-container { | ||
width: 300%; | ||
margin-left: -100%; | ||
padding: 30px 0; | ||
background: #f0f4f5; | ||
height: auto; | ||
display: flex; | ||
justify-content: center; | ||
} | ||
|
||
.homepage-content { | ||
max-width: 100vw; | ||
} | ||
|
||
.dropshadow { | ||
border: 1px solid govuk-colour('dark-grey'); | ||
box-shadow: 0 5px govuk-colour('mid-grey'); | ||
} |
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 |
---|---|---|
@@ -1,10 +1,13 @@ | ||
import hmppsConfig from '@ministryofjustice/eslint-config-hmpps' | ||
|
||
export default [ | ||
...hmppsConfig(), | ||
...hmppsConfig({ | ||
extraIgnorePaths: ['assets'], | ||
}), | ||
{ | ||
rules: { | ||
'dot-notation': 'off', | ||
'import/prefer-default-export': 0, | ||
}, | ||
}, | ||
] |
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
14 changes: 5 additions & 9 deletions
14
server/errorHandler.cy.ts → integration_tests/e2e/errorHandler.cy.ts
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 |
---|---|---|
@@ -1,25 +1,21 @@ | ||
import { v4 as uuidV4 } from 'uuid' | ||
|
||
context('test errorHandler', () => { | ||
const uuid = uuidV4() | ||
|
||
beforeEach(() => { | ||
cy.task('reset') | ||
cy.task('stubSignIn') | ||
cy.task('stubComponents') | ||
}) | ||
|
||
it('should go to the custom error page when an API 500s', () => { | ||
cy.task('stubGetPrisoner500') | ||
cy.task('stubGetPrisonerImage') | ||
// TODO: add test for API error handling | ||
it.skip('should go to the custom error page when an API 500s', () => { | ||
cy.task('stubAPI500Error') | ||
cy.signIn() | ||
cy.visit(`${uuid}/prisoners/A1111AA/referral/start`, { failOnStatusCode: false }) | ||
cy.visit(`/path-that-requires-API-call`, { failOnStatusCode: false }) | ||
cy.findByText(/sorry, there is a problem with the service/i).should('be.visible') | ||
}) | ||
|
||
it('should say page not found when 404', () => { | ||
cy.signIn() | ||
cy.visit(`${uuid}/foobar`, { failOnStatusCode: false }) | ||
cy.visit(`/foobar`, { failOnStatusCode: false }) | ||
cy.findByRole('heading', { name: /Page not found/i }).should('be.visible') | ||
}) | ||
}) |
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 |
---|---|---|
@@ -1 +1,2 @@ | ||
import './commands' | ||
import '@testing-library/cypress/add-commands' |
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,11 @@ | ||
{ | ||
"compilerOptions": { | ||
"target": "es5", | ||
"noEmit": true, | ||
"lib": ["es5", "dom", "es2015.promise"], | ||
"types": ["cypress", "express", "express-session", "@testing-library/cypress"], | ||
"esModuleInterop": true, | ||
"skipLibCheck": true | ||
}, | ||
"include": ["**/*.ts"] | ||
} |
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
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
Oops, something went wrong.