Skip to content

Commit

Permalink
Enable document upload task in Scenarios with mocks (#130)
Browse files Browse the repository at this point in the history
* include document management APIs in mocks

* update scenarios to facilitate doc uploads and other changes

* add scenario tests to CI process
  • Loading branch information
mattonfoot authored Nov 15, 2024
1 parent 19a7347 commit ccad793
Show file tree
Hide file tree
Showing 20 changed files with 498 additions and 181 deletions.
87 changes: 77 additions & 10 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
version: 2.1

orbs:
hmpps: ministryofjustice/hmpps@8
slack: circleci/slack@4.12.5
hmpps: ministryofjustice/hmpps@10
slack: circleci/slack@5

parameters:
alerts-slack-channel:
Expand All @@ -20,6 +20,38 @@ parameters:
type: string
default: 20.12-browsers

executors:
scenario-testing:
docker:
- image: cimg/node:20.18.0-browsers
- image: postgres:14
environment:
POSTGRES_PASSWORD: postgres
POSTGRES_USER: postgres
POSTGRES_DB: postgres
- image: redis:7.2
- image: wiremock/wiremock:latest
environment:
WIREMOCK_OPTIONS: '--port 9091 --verbose'
- image: quay.io/hmpps/hmpps-electronic-monitoring-create-an-order-api:latest
environment:
SERVER_PORT: 8080
DB_SERVER: localhost
DB_NAME: postgres
DB_USER: postgres
DB_PASS: postgres
HMPPS_AUTH_URL: http://localhost:9091/auth
CLIENT_ID: clientid
CLIENT_SECRET: clientsecret
DOCUMENT_MANAGEMENT_URL: http://localhost:9091/hmpps
SERCO_AUTH_URL: http://localhost:9091/auth/oauth/token
SERCO_CLIENT_ID: clientid
SERCO_CLIENT_SECRET: clientsecret
SERCO_USERNAME: serco
SERCO_PASSWORD: serco
SERCO_URL: http://localhost:9091/fms
CP_INTEGRATION_ENABLED: false

jobs:
build:
executor:
Expand All @@ -29,7 +61,7 @@ jobs:
- checkout
- run:
name: Update npm
command: 'sudo npm install -g npm@latest'
command: sudo npm install -g npm@latest
- restore_cache:
key: dependency-cache-{{ checksum "package-lock.json" }}
- run:
Expand Down Expand Up @@ -90,7 +122,7 @@ jobs:
command: java -jar wiremock.jar --port 9091
background: true
- run:
name: Run the node app.
name: Run the node app
command: npm run start-feature
background: true
- run:
Expand All @@ -106,8 +138,40 @@ jobs:
- store_artifacts:
path: integration_tests/screenshots

scenario_test:
executor: scenario-testing
steps:
- checkout
- attach_workspace:
at: ~/app
- run:
name: Update npm
command: sudo npm install -g npm@latest
- restore_cache:
key: dependency-cache-{{ checksum "package-lock.json" }}
- run:
name: Install Dependencies
command: npm ci --no-audit
- run:
command: npm run build
- run:
name: Run the node app
command: npm run start-scenarios
background: true
- run:
name: Wait for node app to start
command: sleep 5
- run:
name: Run scenario tests
command: npm run int-test-scenarios
- store_test_results:
path: test_results
- store_artifacts:
path: integration_tests/videos
- store_artifacts:
path: integration_tests/screenshots

workflows:
version: 2
build-test-and-deploy:
jobs:
- build:
Expand All @@ -120,6 +184,9 @@ workflows:
- integration_test:
requires:
- build
- scenario_test:
requires:
- build
- hmpps/helm_lint:
name: helm_lint
- hmpps/build_docker:
Expand All @@ -130,7 +197,7 @@ workflows:
- main
- hmpps/deploy_env:
name: deploy_dev
env: "dev"
env: 'dev'
jira_update: true
pipeline_id: <<pipeline.id>>
pipeline_number: <<pipeline.number>>
Expand All @@ -147,7 +214,7 @@ workflows:
helm_timeout: 5m
- hmpps/deploy_env:
name: deploy_preprod
env: "preprod"
env: 'preprod'
jira_update: true
jira_env_type: staging
pipeline_id: <<pipeline.id>>
Expand All @@ -164,7 +231,7 @@ workflows:
helm_timeout: 5m
- hmpps/deploy_env:
name: deploy_prod
env: "prod"
env: 'prod'
jira_update: true
jira_env_type: production
pipeline_id: <<pipeline.id>>
Expand All @@ -181,7 +248,7 @@ workflows:
security:
triggers:
- schedule:
cron: "30 5 * * 1-5"
cron: '30 5 * * 1-5'
filters:
branches:
only:
Expand All @@ -204,7 +271,7 @@ workflows:
security-weekly:
triggers:
- schedule:
cron: "0 5 * * 1"
cron: '0 5 * * 1'
filters:
branches:
only:
Expand Down
2 changes: 2 additions & 0 deletions cypress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import auth from './integration_tests/mockApis/auth'
import tokenVerification from './integration_tests/mockApis/tokenVerification'
import cemo from './integration_tests/mockApis/cemo'
import fms from './integration_tests/mockApis/fms'
import hmppsDocumentManagement from './integration_tests/mockApis/hmppsDocumentManagement'

export default defineConfig({
chromeWebSecurity: false,
Expand All @@ -30,6 +31,7 @@ export default defineConfig({
...tokenVerification,
...cemo,
...fms,
...hmppsDocumentManagement,
/*
* used to output summary accessibility testing issues found to console during integration testing
*/
Expand Down
11 changes: 5 additions & 6 deletions docker-compose-scenarios.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
services:

cemo-api:
container_name: cemo-api
image: quay.io/hmpps/hmpps-electronic-monitoring-create-an-order-api:latest
networks:
- hmpps_integration
ports:
- "8080:8080"
- '8080:8080'
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8080/health/ping"]
test: ['CMD', 'curl', '-f', 'http://localhost:8080/health/ping']
depends_on:
cemo-db:
condition: service_healthy
Expand All @@ -27,7 +26,7 @@ services:
- CLIENT_ID=clientid
- CLIENT_SECRET=clientsecret

- DOCUMENT_MANAGEMENT_URL=http://cemo-wiremock:8080/docs
- DOCUMENT_MANAGEMENT_URL=http://cemo-wiremock:8080/hmpps

- SERCO_AUTH_URL=http://cemo-wiremock:8080/auth/oauth/token
- SERCO_CLIENT_ID=clientid
Expand All @@ -47,7 +46,7 @@ services:
ports:
- '5432:5432'
healthcheck:
test: [ "CMD-SHELL", "pg_isready -U postgres" ]
test: ['CMD-SHELL', 'pg_isready -U postgres']
interval: 5s
timeout: 5s
retries: 5
Expand All @@ -71,7 +70,7 @@ services:
networks:
- hmpps_integration
ports:
- "9091:8080"
- '9091:8080'

networks:
hmpps_integration:
7 changes: 4 additions & 3 deletions integration_tests/mockApis/cemo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -476,10 +476,8 @@ ${jsonDiff.diffString(expected, requests[0], { color: false })}
})

const tables = [
'address',
'alternative_contact_details',
'device_wearer_contact_details',
'device_wearer',

'curfew_timetable',

Expand All @@ -493,8 +491,11 @@ const tables = [
'installation_and_risk',
'enforcement_zone',
'trail_monitoring',
'interested_parties',
'responsible_adult',
'responsible_officer',

'device_wearer',
'address',

'orders',
]
Expand Down
Loading

0 comments on commit ccad793

Please sign in to comment.