Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ADOP-2503: update readme file #1573

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,8 @@ $ yarn test:a11y

Make sure all the paths in your application are covered by accessibility tests (see [a11y.ts](src/test/a11y/a11y.ts)).

Accessibility tests are also covered in playwright e2e tests using AXE-CORE.

### Security

#### CSRF prevention
Expand All @@ -158,6 +160,8 @@ included in this template app. Your njk file would look like this:
</form>
...
```
##### Fortify Scan
Fortify scan is run in the nighly pipeline. See [Fortify Scan Setup confluence page](https://tools.hmcts.net/confluence/display/DATS/1C+-+Fortify+Scan+Setup+in+nightly+pipelines) for more details on set up

#### Helmet

Expand Down Expand Up @@ -194,11 +198,19 @@ e.g. the ones verifying the state of each service it depends on.
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details

## Testing:
Test is moving to playwright framework but old tests still exist.

#Old Tests:
E2E tests are configured to run in parallel in 5 headless browsers by default.

To run e2e tests enter `yarn test:local` in the command line.

## Testing E2E - Playwright

We use Playwright with TypeScript. All the details can be found in the [E2E README.md](./playwright-e2e/README.md).

To run playwright tests, use command: 'yarn playwright test`

### Optional configuration

To run all tests only in one browser please set `PARALLEL_CHUNKS` environment variable to `1`. By default 5 chunks are enabled.
Expand Down Expand Up @@ -236,3 +248,4 @@ ADOP_WEB_URL=https://adoption-web-pr-146.service.core-compute-preview.internal/
src/main/app/controller contains default controllers. These will be used if no controllers are specified alongside content in the steps folders.
If a step needs additional functionality, add a controller alongside the content.ts, which inherits the default controller. Get and post controllers
need 'get' or 'post' in their filenames.

64 changes: 53 additions & 11 deletions playwright-e2e/README.md
Original file line number Diff line number Diff line change
@@ -1,29 +1,71 @@
# 🎭 Playwright End-to-End UI Testing Suite
# Playwright End to End suite

End to end UI testing suite using:
End to End testing suite using:

- Playwright https://playwright.dev/
- TypeScript https://www.typescriptlang.org/

## 🤖 Getting Started
## 🤖 Starting up

Before diving in, make sure to explore the various options available for running tests in Playwright by referring to the [official documentation.](https://playwright.dev/docs/running-tests)
For all options take a look at https://playwright.dev/docs/running-tests

To begin, familiarise yourself with the options available for running tests by visiting Playwright's documentation https://playwright.dev/docs/running-tests.

To execute the 'smoke-test.spec.ts' individually from the terminal, simply use the following command: `yarn playwright test smoke-test.spec.ts`.
To execute the 'smoke-test.spec.ts' individually from the Terminal, use the command `yarn playwright test smoke-test.spec.ts`.

## 📁 Structure

```sh
|- playwright-e2e
|-|- fixtures # Predefined components like page, context, browser, and browserName that you can use across different test cases.
|-|- fixtures # With fixtures, you can group tests based on their meaning, instead of their common setup.
|-|- pages # Where to keep page classes with respective locators and methods. We utilise POM (Page Object Modeling).
|-|- settings # essential settings for the framework, such as user credentials and URLs.
|-|- tests # Here is where you can do your magic. 🧙‍♂️
|-|- utils # Essential items for the framework, such as user credentials and URLs.

playwright.config.ts # This sits outside playwright-e2e folder in the projects root. It is the config file for playwright only tests.
playwright.config.ts # This sits outside playwright-e2e folder, but is the config file for playwright only tests.
.env # This sits outside playwright-e2e folder, this is required to run your tests locally. See Setup Environment Variables below.
```

## 🔐 Setup Environment Variables

This repository contains automation tests that can be run locally. To set up the environment variables for configuring URLs and passwords, follow the instructions below:

1. Create a .env file in the root directory of this project if it doesn't already exist.

2. Add the following environment variables to the .env file: (ask a team mate for details/values can be found in Azure Keyvault)

IDAM_SECRET=
IDAM_TOKEN_URL=
IDAM_TESTING_SUPPORT_USERS_URL=
IDAM_START_PAGE=
IDAM_CITIZEN_USER_PASSWORD=


## User creation

Citizen user are created on the fly using IDAM API endpoints. You can use the [idamTestApiHelper.ts](./playwright-e2e/helpers/idamTestApiHelpers.ts) to create the user.
Remember you must be connected to the VPN to create users using the API endpoint.


3. Save the .env file.

.env file is excluded from version control using Git's .gitignore.

## Install Dependencies

Before running the automation tests, ensure that all necessary dependencies are installed. You can do this by running:

```
yarn install
```

Feel free to explore and customise according to your project's needs!
## Running Tests

Once the environment variables are configured and dependencies are installed, you can run the automation tests using the following command:
```
yarn playwright test smoke-test.spec.ts
```

## 🎬 Debugging

Playwright provides a couple of great debugging capabilities at all levels. The ones that you will probably find most useful are:

For all options take a look at https://playwright.dev/docs/debug