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
-
Connect to database
-
Create database and set up required values (see docker-compose.yml)
-
Run migration scripts to create and populate tables (\postgres-dump*.sql)
-
Create your account:
INSERT INTO "UserAuthentication"("QuantumId", "EmailAddress", "Sms", "UseEmailAddress", "UseSms", "ApiUrl")VALUES ('your-name', '', '', false, false, 'https://api.check-my-diary-dev.hmpps.dsd.io/api/');
-
Amend environment variables to point to local database:
template.env
contains all the enviroment variables need for running this app.Add env variables from values-dev.yaml, modify where necessary, for example:
- INGRESS_URL: http://localhost:3000
- CMD_API_URL: http://localhost:3002
- PORT: 3000
Add OAuth keys ()
- API_CLIENT_ID:
- API_CLIENT_SECRET:
-
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/');
-
Create a tunnel into cmd-api because it has no ingress:
kubectl port-forward <cmd-api-pod number> 3002:8080 -n check-my-diary-dev
Note: 3002 is the port number specified in CMD_API_URL above, it could be any number you chose.
OR
5. Clone and cd into cmd-api
6. Run cmd-api
7. Start app in dev mode, in check-my-diary
run npm 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 9091 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:9091/__admin/requests will provide more information on the requests that are made and http://localhost:9091/__admin/mappings will show what stubs have been created for the requests.
Check my diary
displays shift data from CSR
, so you need to configure access appropriately:
- Request access to CSR
- Map your DPS account to an existing CSR account
- Create some shift data in CSR
Follow instructions here: Set up access to CSR
Run command:
npx openapi-typescript http://localhost:8080/v3/api-docs --output server/@types/cmdApi/index.d.ts
Eslint will not be happy - tidy up the generated file with Prettier.