Skip to content

Git repository for service cdp-portal-journey-tests

License

Notifications You must be signed in to change notification settings

DEFRA/cdp-portal-journey-tests

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cdp-portal-journey-tests

Testing CDP Portal.

WDIO tests against an environment, github workflow or locally.

Warning

DO NOT DEPLOY THESE TESTS TO AN CDP ENVIRONMENT AT THE MOMENT! Contains non-ephemeral flows.

Local Development

Requirements

Node.js

Please install Node.js >= v20 and npm >= v9. You will find it easier to use the Node Version Manager nvm

To use the correct version of Node.js for this application, via nvm:

nvm use

Setup

Install application dependencies:

npm install

Running

Local

To run against portal running locally on http://localhost:3000:

npm run test:local

Local with debug

To debug a local version of the portal running on http://localhost:3000:

npm run test:local:debug

GitHub

To mimic the GitHub workflow locally. Start up the docker compose:

docker compose up --wait-timeout 300 -d --quiet-pull --force-recreate

Then run the following command:

npm run test:github

Debugging

WebdriverIO Plugin

In IntelliJ and Webstorm use the WebdriverIO Plugin. This provides full run, debug and breakpoint capabilities in your WebDriverIO tests.

Setup in IntelliJ/Webstorm

  1. Add a WebdriverIO configuration template
  2. Run -> Edit configurations
  3. Edit configuration templates -> WebdriverIO
  4. Add the following values to the WebdriverIO configuration template: WebDriverIO configuration template
  5. Add an All tests configuration
  6. Run -> Edit configurations
  7. Add new configuration -> WebdriverIO
  8. Add the values shown in the following image: WebDriverIO all tests configuration
  9. You can now run and debug your tests in IntelliJ/Webstorm: WebDriverIO with test controls

Note

If you wish to run against cdp-local-environment, you will need to set the Wdio config file to point at wdio. docker.conf.js in the WebdriverIO configuration template:

Debug environment variable

You can also set the following env:

This provides debug config in the wdio.local.conf.js file

DEBUG=true

Or use the npm script:

This script automatically sets the debug environment variable

npm run test-local:debug

WebdriverIO debug command

Use the following command in code:

browser.debug()

Production

Running the tests

Tests are run from the CDP-Portal under the Test Suites section. Before any changes can be run, a new docker image must be built, this will happen automatically when a pull request is merged into the main branch. You can check the progress of the build under the actions section of this repository. Builds typically take around 1-2 minutes.

The results of the test run are made available in the portal.

Requirements of CDP Environment Tests

  1. Your service builds as a docker container using the .github/workflows/publish.yml The workflow tags the docker images allowing the CDP Portal to identify how the container should be run on the platform. It also ensures its published to the correct docker repository.

  2. The Dockerfile's entrypoint script should return exit code of 0 if the test suite passes or 1/>0 if it fails

  3. Test reports should be published to S3 using the script in ./bin/publish-tests.sh

Running on GitHub

Alternatively you can run the test suite as a GitHub workflow. Test runs on GitHub are not able to connect to the CDP Test environments. Instead, they run the tests agains a version of the services running in docker. A docker compose compose.yml is included as a starting point, which includes the databases (mongodb, redis) and infrastructure (localstack) pre-setup.

Steps:

  1. Edit the compose.yml to include your services.
  2. Modify the scripts in docker/scripts to pre-populate the database, if required and create any localstack resources.
  3. Test the setup locally with docker compose up and npm run test:github
  4. Set up the workflow trigger in .github/workflows/journey-tests.

By default, the provided workflow will run when triggered manually from GitHub or when triggered by another workflow.

If you want to use the repository exclusively for running docker composed based test suites consider displaying the publish.yml workflow.

Licence

THIS INFORMATION IS LICENSED UNDER THE CONDITIONS OF THE OPEN GOVERNMENT LICENCE found at:

http://www.nationalarchives.gov.uk/doc/open-government-licence/version/3

The following attribution statement MUST be cited in your products and applications when using this information.

Contains public sector information licensed under the Open Government licence v3

About the licence

The Open Government Licence (OGL) was developed by the Controller of Her Majesty's Stationery Office (HMSO) to enable information providers in the public sector to license the use and re-use of their information under a common open licence.

It is designed to encourage use and re-use of information freely and flexibly, with only a few conditions.