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.
Merge pull request #71 from ministryofjustice/CBA-111-search-by-crn
Enable searching for an applicant via CRN
- Loading branch information
Showing
39 changed files
with
1,347 additions
and
76 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
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 @@ | ||
import { BasePage } from '../basePage' | ||
|
||
export class FindByCrnPage extends BasePage { | ||
async enterCrn(crn: string) { | ||
await this.page.getByLabel("Enter the person's CRN").fill(crn) | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import { expect } from '@playwright/test' | ||
import { test } from '../test' | ||
import { | ||
completeAboutThePersonSection, | ||
completeAreaAndFundingSection, | ||
completeBeforeYouStartSection, | ||
completeCheckAnswersSection, | ||
completeOffenceInformationSection, | ||
completeRisksAndNeedsSection, | ||
completeBailInformationSection, | ||
confirmApplicant, | ||
enterCrn, | ||
selectApplicationOrigin, | ||
startAnApplication, | ||
submitApplication, | ||
viewSubmittedApplication, | ||
addNote, | ||
viewInProgressDashboard, | ||
createAnInProgressApplication, | ||
} from '../steps/apply' | ||
import { signIn } from '../steps/signIn' | ||
import { cancelAnApplication, clickCancel } from '../steps/cancelInProgressApplication' | ||
|
||
test('create a CAS-2 bail application', async ({ page, person, nomisCourtUser }) => { | ||
await signIn(page, nomisCourtUser) | ||
await startAnApplication(page) | ||
await selectApplicationOrigin(page, 'courtBail') | ||
await enterCrn(page, person.crn) | ||
await confirmApplicant(page) | ||
await completeBeforeYouStartSection(page, person.name) | ||
await completeAreaAndFundingSection(page, person.name) | ||
await completeAboutThePersonSection(page, person.name) | ||
await completeRisksAndNeedsSection(page, person.name) | ||
await completeOffenceInformationSection(page, person.name) | ||
await completeBailInformationSection(page, person.name) | ||
await completeCheckAnswersSection(page, person.name) | ||
await expect(page.getByText('You have completed 17 of 17 tasks')).toBeVisible() | ||
await submitApplication(page) | ||
}) | ||
|
||
test('add a note to a submitted application', async ({ page, person, nomisCourtUser }) => { | ||
await signIn(page, nomisCourtUser) | ||
await viewSubmittedApplication(page, person.name) | ||
await addNote(page) | ||
await expect(page.locator('.moj-timeline__title').first()).toContainText('Note') | ||
}) | ||
|
||
test('cancel an in progress application from the task list', async ({ page, nomisCourtUser, person }) => { | ||
await signIn(page, nomisCourtUser) | ||
await createAnInProgressApplication(page, person, 'courtBail') | ||
await viewInProgressDashboard(page) | ||
const numberOfApplicationsBeforeCancellation = (await page.locator('tr').all()).length | ||
await clickCancel(page, person.name) | ||
await cancelAnApplication(page, person.name) | ||
const numberOfApplicationsAfterCancellation = (await page.locator('tr').all()).length | ||
await expect(page.getByText('Your CAS-2 applications')).toBeVisible() | ||
expect(numberOfApplicationsBeforeCancellation - numberOfApplicationsAfterCancellation).toEqual(1) | ||
}) |
File renamed without changes.
File renamed without changes.
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,12 @@ | ||
import Page from '../page' | ||
|
||
export default class ApplicationOriginPage extends Page { | ||
constructor(name: string) { | ||
super(`You are applying for:`, name) | ||
} | ||
|
||
static visit(name: string): ApplicationOriginPage { | ||
cy.visit('/applications/application-type') | ||
return new ApplicationOriginPage(name) | ||
} | ||
} |
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,14 @@ | ||
import paths from '../../../server/paths/apply' | ||
import Page from '../page' | ||
|
||
export default class BeforeYouStartPage extends Page { | ||
constructor(name: string) { | ||
super('Apply for Short-Term Accommodation (CAS-2)', name) | ||
} | ||
|
||
static visit(name: string): BeforeYouStartPage { | ||
cy.visit(paths.applications.beforeYouStart({})) | ||
|
||
return new BeforeYouStartPage(name) | ||
} | ||
} |
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,37 @@ | ||
import { FullPerson } from '../../../server/@types/shared/models/FullPerson' | ||
import { DateFormats } from '../../../server/utils/dateUtils' | ||
import Page from '../page' | ||
|
||
export default class ConfirmApplicantPage extends Page { | ||
personName: string | ||
|
||
constructor(name: string) { | ||
super(`Confirm ${name}'s details`, name) | ||
} | ||
|
||
hasErrorDetails = (): void => { | ||
cy.get('.govuk-error-summary').contains('There was an error creating the application, please try again') | ||
} | ||
|
||
hasApplicantInformation = (applicant: FullPerson): void => { | ||
const expectedApplicantData = [ | ||
['Full name', applicant.name], | ||
['Date of birth', DateFormats.isoDateToUIDate(applicant.dateOfBirth, { format: 'short' })], | ||
['Nationality', applicant.nationality], | ||
['Sex', applicant.sex], | ||
['Prison number', applicant.nomsNumber], | ||
['Prison', applicant.prisonName], | ||
['PNC number', applicant.pncNumber], | ||
['CRN from NDelius', applicant.crn], | ||
['Status', applicant.status === 'InCommunity' ? 'In Community' : 'In Custody'], | ||
] | ||
cy.get('.govuk-summary-list').within(() => { | ||
cy.get('.govuk-summary-list__row').each(($el, index) => { | ||
cy.wrap($el).within(() => { | ||
cy.get('.govuk-summary-list__key').should('contain', expectedApplicantData[index][0]) | ||
cy.get('.govuk-summary-list__value').should('contain', expectedApplicantData[index][1]) | ||
}) | ||
}) | ||
}) | ||
} | ||
} |
Oops, something went wrong.