-
Notifications
You must be signed in to change notification settings - Fork 0
CODE RUB: Test Nhs Login Playwright Update #190
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
Merged
davidhayes03
merged 2 commits into
main
from
users/davidhayes03/code-rub-playwright-updates
Feb 2, 2026
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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
99 changes: 99 additions & 0 deletions
99
LondonDataServices.IDecide.Portal.Client/tests/homepageNhsLogin.spec.ts
This file contains hidden or 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,99 @@ | ||
| import { test, expect } from '@playwright/test'; | ||
| import { | ||
| clickStartButton, | ||
| fillNhsLoginCredentials, | ||
| clickContinueButton, | ||
| handleOtpIfPrompted | ||
| } from './helpers/helper'; | ||
|
|
||
| test.describe('Home Page Nhs Login', () => { | ||
davidhayes03 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| test.beforeEach(async ({ page }) => { | ||
| await page.goto('https://localhost:5173/home'); | ||
| }); | ||
|
|
||
| test('should display the Start button', async ({ page }) => { | ||
| await expect(page.getByTestId('start-login-button')).toBeVisible(); | ||
| }); | ||
|
|
||
| test('should navigate to NHS login and complete authentication', async ({ page }) => { | ||
| await clickStartButton(page); | ||
| await expect(page).toHaveURL('https://access.sandpit.signin.nhs.uk/login'); | ||
|
|
||
| await fillNhsLoginCredentials(page); | ||
| await clickContinueButton(page); | ||
|
|
||
| await handleOtpIfPrompted(page); | ||
|
|
||
| // Verify we're back on the app after authentication | ||
| await expect(page).toHaveURL(/https:\/\/localhost:5173/); | ||
| }); | ||
|
|
||
| test('should display Confirm Details page with user information', async ({ page }) => { | ||
| await clickStartButton(page); | ||
| await expect(page).toHaveURL('https://access.sandpit.signin.nhs.uk/login'); | ||
|
|
||
| await fillNhsLoginCredentials(page); | ||
| await clickContinueButton(page); | ||
|
|
||
| await handleOtpIfPrompted(page); | ||
|
|
||
| // Wait for redirect back to app | ||
| await page.waitForURL('https://localhost:5173/nhs-optOut'); | ||
|
|
||
| // Verify the Next button is visible on the Confirm Details page | ||
| await expect(page.getByRole('button', { name: /next/i })).toBeVisible(); | ||
|
|
||
| // Verify the summary list contains the expected user details | ||
| const summaryList = page.locator('dl.nhsuk-summary-list'); | ||
| await expect(summaryList).toBeVisible(); | ||
|
|
||
| // Verify Name field | ||
| await expect( | ||
| summaryList | ||
| .locator('.nhsuk-summary-list__row', { has: page.locator('dt:has-text("Name")') }) | ||
| .locator('dd.nhsuk-summary-list__value') | ||
| ).toHaveText('Mona, MILLAR'); | ||
|
|
||
| // Verify Email field | ||
| await expect( | ||
| summaryList | ||
| .locator('.nhsuk-summary-list__row', { has: page.locator('dt:has-text("Email")') }) | ||
| .locator('dd.nhsuk-summary-list__value') | ||
| ).toHaveText('testuserlive@demo.signin.nhs.uk'); | ||
|
|
||
| // Verify Mobile Number field | ||
| await expect( | ||
| summaryList | ||
| .locator( | ||
| '.nhsuk-summary-list__row', | ||
| { has: page.locator('dt:has-text("Mobile Number")') } | ||
| ) | ||
| .locator('dd.nhsuk-summary-list__value') | ||
| ).toHaveText('+447887510886'); | ||
| }); | ||
|
|
||
| test('should navigate to Make your Choice page after clicking Next button', async ({ page }) => { | ||
| await clickStartButton(page); | ||
| await expect(page).toHaveURL('https://access.sandpit.signin.nhs.uk/login'); | ||
|
|
||
| await fillNhsLoginCredentials(page); | ||
| await clickContinueButton(page); | ||
|
|
||
| await handleOtpIfPrompted(page); | ||
|
|
||
| // Wait for redirect back to app | ||
| await page.waitForURL('https://localhost:5173/nhs-optOut'); | ||
|
|
||
| // Click the Next button on the Confirm Details page | ||
| await page.getByRole('button', { name: /next/i }).click(); | ||
|
|
||
| // Wait for navigation to complete | ||
| await page.waitForLoadState('networkidle'); | ||
|
|
||
| // Verify that we're on the Make your Choice page (still same route) | ||
| await expect(page).toHaveURL('https://localhost:5173/nhs-optOut'); | ||
|
|
||
| // Verify page content has changed to Make your Choice | ||
| await expect(page.locator('h4:has-text("Make your Choice")')).toBeVisible(); | ||
| }); | ||
| }); | ||
32 changes: 32 additions & 0 deletions
32
LondonDataServices.IDecide.Portal.Client/tests/setup/auth.setup.tffs
This file contains hidden or 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 { test as setup, expect } from '@playwright/test'; | ||
davidhayes03 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| import { | ||
| clickStartButton, | ||
| fillNhsLoginCredentials, | ||
| clickContinueButton, | ||
| handleOtpIfPrompted | ||
| } from '../helpers/helper'; | ||
|
|
||
| const authFile = 'playwright/.auth/user.json'; | ||
|
|
||
| setup('authenticate with NHS Login', async ({ page }) => { | ||
| // Navigate to home page | ||
| await page.goto('https://localhost:5173/home'); | ||
|
|
||
| // Perform NHS Login authentication | ||
| await clickStartButton(page); | ||
| await expect(page).toHaveURL('https://access.sandpit.signin.nhs.uk/login'); | ||
|
|
||
| await fillNhsLoginCredentials(page); | ||
| await clickContinueButton(page); | ||
|
|
||
| // Handle OTP if prompted (will remember device) | ||
| await handleOtpIfPrompted(page); | ||
|
|
||
| // Wait for redirect back to app | ||
| await page.waitForURL(/https:\/\/localhost:5173/); | ||
|
|
||
| // Save authenticated state including cookies and localStorage | ||
| await page.context().storageState({ path: authFile }); | ||
|
|
||
| console.log('? Authentication completed and saved to', authFile); | ||
davidhayes03 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| }); | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.