generated from ministryofjustice/hmpps-template-typescript
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PI-2406: Created Playwright Basic Setup and Added Test for Manage a …
…Supervision Spike (#117) * PI-2406-Created a basic setup for Playwright and added a test for spike * PI-2406-Created a basic setup for Playwright and added a test for spike * PI-2406-Created a basic setup for Playwright and added a test for spike * Initial changes for running Playwright tests * Re-use shared steps from e2e project + add CI workflow --------- Co-authored-by: Marcus Aspin <[email protected]>
- Loading branch information
1 parent
eeb6399
commit 7fea8f4
Showing
13 changed files
with
807 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
node_modules | ||
public | ||
assets | ||
test-results | ||
playwright-report | ||
cypress.json | ||
reporter-config.json | ||
dist/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
name: Playwright Tests | ||
on: | ||
schedule: | ||
- cron: "0 8 * * MON-FRI" | ||
workflow_dispatch: | ||
|
||
jobs: | ||
test: | ||
timeout-minutes: 60 | ||
runs-on: moj-cloud-platform | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: lts/* | ||
- name: Install dependencies | ||
run: npm ci | ||
- name: Install Playwright Browsers | ||
run: npx playwright install | ||
- name: Add config | ||
run: cp e2e_tests/.env.example e2e_tests/.env | ||
- name: Run Playwright tests | ||
run: npm run e2e-test | ||
env: | ||
DELIUS_USERNAME: ${{ secrets.E2E_DELIUS_USERNAME }} | ||
DELIUS_PASSWORD: ${{ secrets.E2E_DELIUS_PASSWORD }} | ||
- name: Publish HTML report | ||
if: always() | ||
uses: JamesIves/github-pages-deploy-action@94f3c658273cf92fb48ef99e5fbc02bd2dc642b2 # v4 | ||
with: | ||
folder: playwright-report | ||
target-folder: playwright-report/${{ github.ref_name }}/${{ github.run_id }}/${{ github.run_attempt }} | ||
- name: Output HTML report URL | ||
if: always() | ||
run: echo '[🎭 Playwright HTML Report](https://ministryofjustice.github.io/hmpps-probation-integration-e2e-tests/playwright-report/${{ github.ref_name }}/${{ github.run_id }}/${{ github.run_attempt }})' | tee -a "$GITHUB_STEP_SUMMARY" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1 @@ | ||
#!/bin/sh | ||
. "$(dirname "$0")/_/husky.sh" | ||
|
||
NODE_ENV=dev && node_modules/.bin/lint-staged && npm run typecheck && npm test | ||
NODE_ENV=dev && node_modules/.bin/lint-staged && npm run typecheck && npm test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# URLs | ||
DELIUS_URL=https://ndelius.test.probation.service.justice.gov.uk | ||
MANAGE_A_SUPERVISION_URL=https://manage-a-supervision-dev.hmpps.service.justice.gov.uk | ||
|
||
# Credentials | ||
#DELIUS_USERNAME=example | ||
#DELIUS_PASSWORD=example |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { expect, test } from '@playwright/test' | ||
import * as dotenv from 'dotenv' | ||
import { DateTime } from 'luxon' | ||
import { deliusPerson } from '@ministryofjustice/hmpps-probation-integration-e2e-tests/steps/delius/utils/person' | ||
import { createOffender } from '@ministryofjustice/hmpps-probation-integration-e2e-tests/steps/delius/offender/create-offender' | ||
import { login as loginToDelius } from '@ministryofjustice/hmpps-probation-integration-e2e-tests/steps/delius/login' | ||
import { login as loginToManageMySupervision } from '@ministryofjustice/hmpps-probation-integration-e2e-tests/steps/manage-a-supervision/login' | ||
|
||
dotenv.config({ path: 'e2e_tests/.env' }) // read environment variables into process.env | ||
|
||
test('Verify the header details', async ({ page }) => { | ||
// Create a person in Delius | ||
await loginToDelius(page) | ||
const person = deliusPerson() | ||
const crn = await createOffender(page, { person }) | ||
|
||
// Search for the CRN | ||
await loginToManageMySupervision(page) | ||
await page.getByRole('link', { name: 'Search' }).click() | ||
await page.getByLabel('Find a person on probation').fill(crn) | ||
await page.getByRole('button', { name: 'Search' }).click() | ||
|
||
// Verify the person appears in the search results and crn, name, dob & tier matches | ||
await page.locator(`[href$="${crn}"]`).click() | ||
await expect(page).toHaveTitle('Manage a Supervision - Overview') | ||
await expect(page.locator('[data-qa="crn"]')).toContainText(crn) | ||
await expect(page.locator('[data-qa="name"]')).toContainText(`${person.firstName} ${person.lastName}`) | ||
await expect(page.locator('[data-qa="headerDateOfBirthValue"]')).toContainText( | ||
DateTime.fromJSDate(person.dob).toFormat('d MMMM yyyy'), | ||
) | ||
await expect(page.locator('[data-qa="tierValue"]').first()).toContainText('D0') | ||
}) |
Oops, something went wrong.