Skip to content

Prepare a case is a service that allows probation staff to prepare court cases.

License

Notifications You must be signed in to change notification settings

ministryofjustice/prepare-a-case

Repository files navigation

Prepare a case

CircleCI

Prepare a case is a service that allows probation staff to prepare court cases.

For more informations, check our Runbook

Prerequisities

Before you begin, ensure you have met the following requirements:

  • You have Node.js LTS (Fermium) >= v14.17.5

For code quality the project adheres to JavaScript Standard Style which requires minimal configuration of your chosen IDE.

Unit tests use Jest.

Integration tests use Cypress and employ Gherkin features, integration tests also check for accessibility violations with Axe.

To use Prepare a case, follow these steps:

Install dependencies using

npm i

And then, to build the assets and start the app with (substituting in a valid client secret for the dev environment)

env API_CLIENT_SECRET={client-secret} COURT_CASE_SERVICE_URL=http://court-case-service-dev.apps.live-1.cloud-platform.service.justice.gov.uk NOMIS_AUTH_URL=https://sign-in-dev.hmpps.service.justice.gov.uk/auth npm run start

Or to use alongside a local instance of court-case-service

env COURT_CASE_SERVICE_URL=http://127.0.0.1:8080 npm run start

For development, there are additional tasks:

Start app with mocked backend

If unspecified, the app will use your local court-case-service app but you can also use WireMock.

Start the standalone WireMock server

java -jar wiremock-jre8-standalone-2.30.1.jar --global-response-templating --port 9091

And then, to build assets and start app with

npm run start:watch

This will watch for changes in the application JavaScript and Nunjucks templates and automatically restart as required.

This will also ensure that the application does not restart due to changes to test scripts.

Run linter

npm run lint

Run unit tests

npm run unit-test

Run integration tests

For local running, start redis instance by:

docker-compose -f docker-compose.test.yml up

Start the standalone WireMock server

java -jar wiremock-jre8-standalone-2.30.1.jar --global-response-templating --port 9091

Then run the server in test mode by:

npm run start-feature` (or `npm run start-feature:dev` to run with nodemon)

Then run the integration tests:

npm run int-test

Or run the integration tests with the Cypress UI:

npm run int-test:ui

N.B. If your tests fail at cy.task('getLoginUrl').then(cy.visit) try restarting your standalone WireMock server

Environment variables

Court case service

Default: http://127.0.0.1:9091

Specify the court-case-service URL with COURT_CASE_SERVICE_URL

Cases per page

Default: 20

Specify the number of cases to display, per page with CASES_PER_PAGE

HMPPS User Preferences service

Default: http://127.0.0.1:9091

Specify the hmpps-user-preferences URL with USER_PREFERENCE_SERVICE_URL

Dependencies

  • hmpps-auth - for authentication
  • redis - session store and token caching