A progressive web application for viewing shift pattern and detail. It consists of a Node.JS application with a postgres database and calls out to Prison Officer Diary API to get shift and task information, as well as notify to send emails and SMS.
git clone [email protected]:ministryofjustice/check-my-diary.git
cd check-my-diary
npm i
template.env
contains all the enviroment variables need for running this app.
Ask a contributor for any values you need then rename this file to .env
npm run build
Ensure you build assets first
npm start
npm start:dev
- Remove any running docker containers
docker-compose down --rm all
- In this repository run
docker-compose up
- Remote into docker database to create your user
docker exec -it check-my-diary-db psql -U [DATABASE-NAME-FROM-.ENV]
INSERT INTO "UserAuthentication"("QuantumId", "EmailAddress", "Sms", "UseEmailAddress", "UseSms", "ApiUrl")VALUES ('your-name', '', '', false, false, 'https://api.check-my-diary-dev.hmpps.dsd.io/api/');
- Clone and cd into
cmd-api
- Run
cmd-api
- Start app in dev mode, in
check-my-diary
runnpm start:dev
npm run lint
Jest is used to run the tests:
npm install
npm test
The integration tests are also run using jest, but separated out from the unit tests as they require a database and a wiremock instance.
NB: To run integration tests you must remove your .env
from scope so that config.js
uses defaults
To start the docker images for the tests:
docker-compose -f docker-compose-test.yml pull && docker-compose -f docker-compose-test.yml up
This will start an database instance on port 5432 and a wiremock instance on port 9191 to mock out the prison officer and notify APIs. This allows us to simulate both services without firing them up.
The tests are written using cypress and will test against a running application instance. To start up the application for running the feature tests:
npm run start-feature
To run the tests from the command line:
npm run int-test
This will run all the specifications in the integration_tests
package.
To run the tests using the cypress runner:
npm run int-test-ui
This will open up cypress and show all the specs. Clicking on one of the specs will fire up chrome and run the tests in that specification.
If the mocking is not working properly after the test has been completed then the docker terminal will show what stubs aren't matched by requests. http://localhost:9191/__admin/requests will provide more information on the requests that are made and http://localhost:9191/__admin/mappings will show what stubs have been created for the requests.