generated from ministryofjustice/hmpps-template-typescript
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Describe E2E 'Manager creates new OOSB record' journey
We start a new `/e2e/tests/v2Manage.spec` file to compartmentalise these user journeys, starting with: > Future manager marks a bed as out of service in the V2 Manage area > > Given I am signed in as a future manager > And I am on the list of premises page > > When choose to view the detail of a particular premises > Then I should see the premises page > > When I choose to manage its beds > And I pick a particular bed to manage > Then I see the V2 Bed page > And I should be able to mark a bed as out of service > > When I fill in and submit the v2 Manage out-of-service-bed form > Then I am redirected back to the V2 bed page > And I see the success message on the 'history' pane of the bed page The differences in v2/v1 behaviour are achieved with: - a new `v2BedLink()` 'Manage (bed)' link used on the premises' bed list to link to the new v2 bed page - a new `v2BedActions()` widget which offers FUTURE_MANAGER the link to the new v2 "create out of service bed" form from the v2 bed page
- Loading branch information
Showing
12 changed files
with
196 additions
and
10 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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { Page, expect } from '@playwright/test' | ||
import { BasePage } from '../basePage' | ||
|
||
export class V2BedPage extends BasePage { | ||
static async initialize(page: Page, premisesName: string) { | ||
await expect(page.locator('h1')).toContainText('View bed information') | ||
await expect(page.locator('.moj-identity-bar__title')).toContainText(premisesName) | ||
return new V2BedPage(page) | ||
} | ||
|
||
async clickActions() { | ||
await this.page.getByRole('button', { name: 'Actions' }).click() | ||
} | ||
|
||
async clickMarkBedAsOutOfService() { | ||
await this.clickActions() | ||
await this.page.getByRole('menuitem', { name: 'Create out of service bed record' }).click() | ||
} | ||
|
||
async showsOutOfServiceBedRecordedSuccessMessage() { | ||
await expect(this.page.locator('.govuk-notification-banner')).toContainText( | ||
'The out of service bed has been recorded', | ||
) | ||
} | ||
} |
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,67 @@ | ||
import { Page, expect } from '@playwright/test' | ||
import { getDate, getMonth, getYear } from 'date-fns' | ||
import { faker } from '@faker-js/faker/locale/en_GB' | ||
import { BasePage } from '../basePage' | ||
|
||
export class V2MarkBedAsOutOfServicePage extends BasePage { | ||
startDate: Date | ||
|
||
static async initialize(page: Page, title?: string) { | ||
if (title) { | ||
await expect(page.locator('h1')).toContainText(title) | ||
} | ||
const instance = new V2MarkBedAsOutOfServicePage(page) | ||
instance.startDate = faker.date.soon({ days: 600 }) | ||
return instance | ||
} | ||
|
||
endDate() { | ||
const endDate = new Date(this.startDate) | ||
endDate.setDate(endDate.getDate() + 2) | ||
return endDate | ||
} | ||
|
||
async enterOutOfServiceFromDate() { | ||
const { startDate } = this | ||
await this.page | ||
.getByRole('group', { name: 'Out of service from' }) | ||
.getByLabel('Day') | ||
.fill(getDate(startDate).toString()) | ||
await this.page | ||
.getByRole('group', { name: 'Out of service from' }) | ||
.getByLabel('Month') | ||
.fill(getMonth(startDate).toString()) | ||
await this.page | ||
.getByRole('group', { name: 'Out of service from' }) | ||
.getByLabel('Year') | ||
.fill(getYear(startDate).toString()) | ||
} | ||
|
||
async enterOutOfServiceToDate() { | ||
const endDate = this.endDate() | ||
await this.page | ||
.getByRole('group', { name: 'Out of service to' }) | ||
.getByLabel('Day') | ||
.fill(getDate(endDate).toString()) | ||
await this.page | ||
.getByRole('group', { name: 'Out of service to' }) | ||
.getByLabel('Month') | ||
.fill(getMonth(endDate).toString()) | ||
await this.page | ||
.getByRole('group', { name: 'Out of service to' }) | ||
.getByLabel('Year') | ||
.fill(getYear(endDate).toString()) | ||
} | ||
|
||
async completeForm() { | ||
await this.enterOutOfServiceFromDate() | ||
await this.enterOutOfServiceToDate() | ||
await this.checkRadio('Planned Refurbishment') | ||
await this.page.getByLabel('Work order reference number').fill('123456789') | ||
await this.page | ||
.getByLabel( | ||
'Provide detail about why the bed is out of service. If FM works are required you should update this record with any progress on that work.', | ||
) | ||
.fill('Reasons for bed being out of service') | ||
} | ||
} |
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,52 @@ | ||
import { test } from '../test' | ||
import { visitDashboard } from '../steps/apply' | ||
import { PremisesListPage } from '../pages/manage/premisesListPage' | ||
import { PremisesPage } from '../pages/manage/premisesPage' | ||
import { BedsPage } from '../pages/manage/bedsPage' | ||
import { V2BedPage } from '../pages/manage/v2BedPage' | ||
import { V2MarkBedAsOutOfServicePage } from '../pages/manage/v2MarkBedAsOutOfServicePage' | ||
import { signIn } from '../steps/signIn' | ||
|
||
test.describe.configure({ mode: 'parallel' }) | ||
|
||
const premisesName = 'Test AP 10' | ||
|
||
test('Future manager marks a bed as out of service in the V2 Manage area', async ({ page, futureManager }) => { | ||
// Given I am signed in as a future manager | ||
await signIn(page, futureManager) | ||
|
||
// And I am on the list of premises page | ||
const dashboard = await visitDashboard(page) | ||
await dashboard.clickManage() | ||
const premisesListPage = await PremisesListPage.initialize(page, 'List of Approved Premises') | ||
|
||
// When choose to view the detail of a particular premises | ||
await premisesListPage.choosePremises(premisesName) | ||
|
||
// Then I should see the premises page | ||
const premisesPage = await PremisesPage.initialize(page, premisesName) | ||
|
||
// When I choose to manage its beds | ||
await premisesPage.viewRooms() | ||
const manageBedsPage = await BedsPage.initialize(page, 'Manage beds') | ||
|
||
// And I pick a particular bed to manage | ||
await manageBedsPage.viewAvailableBed() | ||
|
||
// Then I see the V2 Bed page | ||
const v2BedPage = await V2BedPage.initialize(page, premisesName) | ||
|
||
// And I should be able to mark a bed as out of service | ||
await v2BedPage.clickMarkBedAsOutOfService() | ||
|
||
// When I fill in and submit the v2 Manage out-of-service-bed form | ||
const v2MarkBedAsOutOfServicePage = await V2MarkBedAsOutOfServicePage.initialize(page, 'Mark a bed as out of service') | ||
await v2MarkBedAsOutOfServicePage.completeForm() | ||
await v2MarkBedAsOutOfServicePage.clickSave() | ||
|
||
// Then I am redirected back to the V2 bed page | ||
const revisitedV2BedPage = await V2BedPage.initialize(page, premisesName) | ||
|
||
// And I see the success message on the 'history' pane of the bed page | ||
await revisitedV2BedPage.showsOutOfServiceBedRecordedSuccessMessage() | ||
}) |
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
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
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