Modern slavery
An app for a first responder to submit a form for a possible victim of modern slavery.
When the environment variable WRITE_TO_CASEWORK
is true the app will post cases to an SQS queue for later processing by a casework resolver service.
Contents
-
Install & Run
-
Email functionality
-
Skip email verify step
-
PDF generation
-
Acceptance tests
-
Coverage Reporting
-
Release Guidelines
Install & Run
The application can either be run on your local machine or built inside a docker container using docker-compose
Environment variables
You'll need to set the following env vars to run the application:
NOTIFY_KEY | Your GOV.UK notify key
AWS_SQS | AWS SQS URL
AWS_SECRET_ACCESS_KEY | AWS Secret Access Key
AWS_ACCESS_KEY_ID | AWS Access Key ID
WRITE_TO_CASEWORK | Enable/Disable sending the case to iCasework (defaults to false)
Please note if you are using IP whitelisting in the iCasework backend you will also need to add your public IP!
Install & Run on local machine
Install the dependencies and build the project resources
$ npm install
Install Redis and make sure you have a running redis instance in the background.
$ redis-server
Start the server in development mode
$ npm run dev
Then go to http://localhost:8081
Install & Run on docker container
Build the docker containers containing an instance of the Chrome browser chrome-browser
the Node JS application app
and an instance of Redis redis
$ docker-compose up -d --build chrome-browser app redis
Email functionality
We use Gov Notify to send emails. We have two accounts:
- Modern slavery for our Live service. This is on our production environment
- Modern slavery test for testing. This is on our dev, uat and preprod environments
In order to run the email functionality, you'll need the API Gov Notify Key called, NOTIFY_KEY
for the Modern slavery test service. Do NOT use the Production key.
This can be obtained from a developer in the team. It is recommended to have a .env
file with the environment variable and then run the app like so:
$ npm run dev -- --env
Skip email verify step
On dev, preprod and locally you can skip the email verify step by going to the following url
http://localhost:8081/nrm/start?token=skip
PDF Generation
We are currently working on a feature for pdf generation. In order for this not to affect development, this has been put on a different route on the app
http://localhost:8081/pdf/
Acceptance tests
Google Puppeteer is our automated browser testing. It is a Node library which provides a high-level API to control headless Chrome or Chromium over the DevTools Protocol. It can also be configured to use full (non-headless) Chrome or Chromium.
You can run acceptance tests either on your local machine via the Chrome browser or within a docker container
Running local acceptance tests
Install & Run the application locally then you can run the acceptance tests using the command below:
$ npm run test:local-acceptance
This will open up an instance of Google Chrome on your local machine for each test.
Running acceptance tests inside a docker container
Install & Run the application within a docker conatiner then you can run the acceptance tests using the commands below:
Enter into the docker container with the Node JS application running
$ docker exec -i -t modern-slavery-app /bin/bash
Run acceptance tests
$ npm run test:docker-acceptance
Running acceptance tests as part of Drone CI
We use Drone CI for our continious integration testing. For each Push and Pull Request to the Github repository we run our acceptance tests using a docker image with docker-compose pre-installed. The configuration can be found within the drone.yml
file
Acceptance test scripts
Acceptance scripts
- test:docker-acceptance
- test:local-acceptance
- test:local-acceptance-demo
The location of the user pathway tests are in the directory: /modern-slavery/acceptance-test/user-pathways/
The test scripts utilise the environment variables BROWSER_TYPE
& BROWSER_DEMO
to determine what the test files within the directory /modern-slavery/acceptance-test/user-pathways/
uses as its browser and whether the browser runs slower for demonstration purposes.
BROWSER_TYPE
can be left blank or set to local
for local machine browser testing. This variable can be set to remote
for remote browser testing.
BROWSER_DEMO
can be left blank so the tests run at normal speed or can be set so the test runs at a slower speed.
Uploading files
The acceptance script /modern-slavery/acceptance-test/user-pathways/upload-file/upload-file.test.js
currently tests 1 aspect of the upload functionality; a single file upload. This will be expanded in future to test other functionalities of the application.
This test suite uses the file /modern-slavery/acceptance-test/user-pathways/upload-file/images/test.png
to complete the upload action on behalf of the user for local browser acceptance tests. The file /modern-slavery/browsers/chrome/test.png
is used for remote browser acceptance tests
Coverage Reporting
For unit test coverage reporting we use the Istanbul `nyc' npm module. To generate a report run the following command:
$ npm run test:coverage
Release Guidelines
More Details