Skip to content

Commit

Permalink
add e2e test for cancellation
Browse files Browse the repository at this point in the history
  • Loading branch information
Joosakur committed Dec 3, 2024
1 parent f50c7b4 commit 06c4b0d
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ import {
MultiSelect,
Page,
Element,
ElementCollection
ElementCollection,
Radio
} from '../../../utils/page'

export default class ApplicationListView {
Expand All @@ -20,11 +21,15 @@ export default class ApplicationListView {
#unitFilter: MultiSelect
#applications: ElementCollection
actionsMenuItems: {
verify: Element
setVerified: Element
createPlacement: Element
createDecision: Element
acceptPlacementWihtoutDecision: Element
acceptPlacementWithoutDecision: Element
cancelApplication: Element
}
cancelConfirmation: {
confidentialRadioYes: Radio
confidentialRadioNo: Radio
submitButton: Element
}
specialFilterItems: {
duplicate: Element
Expand All @@ -44,13 +49,17 @@ export default class ApplicationListView {
.find('[data-qa="table-of-applications"]')
.findAll('[data-qa="table-application-row"]')
this.actionsMenuItems = {
verify: this.#actionsMenuItemSelector('verify'),
setVerified: this.#actionsMenuItemSelector('set-verified'),
createPlacement: this.#actionsMenuItemSelector('placement-draft'),
createDecision: this.#actionsMenuItemSelector('decision'),
acceptPlacementWihtoutDecision: this.#actionsMenuItemSelector(
acceptPlacementWithoutDecision: this.#actionsMenuItemSelector(
'placement-without-decision'
)
),
cancelApplication: this.#actionsMenuItemSelector('cancel-application')
}
this.cancelConfirmation = {
confidentialRadioYes: new Radio(page.findByDataQa('confidential-yes')),
confidentialRadioNo: new Radio(page.findByDataQa('confidential-no')),
submitButton: page.findByDataQa('modal-okBtn')
}
this.specialFilterItems = {
duplicate: page.findByDataQa('application-basis-DUPLICATE_APPLICATION')
Expand All @@ -71,7 +80,7 @@ export default class ApplicationListView {
.find('[data-qa="application-actions-menu"]')

#actionsMenuItemSelector = (id: string) =>
this.page.findByDataQa(`action-item-${id}`)
this.page.findByDataQa(`menu-item-${id}`)

async toggleArea(areaName: string) {
await this.#areaFilter.fillAndSelectFirst(areaName)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -293,8 +293,8 @@ describe('Application transitions', () => {
await applicationReadView.setVerifiedButton.waitUntilVisible()
await applicationReadView.setVerifiedButton.assertDisabled(true)

await applicationReadView.confidentialRadioYes.click()
await applicationReadView.confidentialRadioNo.click()
await applicationReadView.confidentialRadioYes.check()
await applicationReadView.confidentialRadioNo.check()

await applicationReadView.setVerifiedButton.assertDisabled(false)
await applicationReadView.setVerifiedButton.click()
Expand All @@ -312,6 +312,47 @@ describe('Application transitions', () => {
await placementDraftPage.waitUntilLoaded()
})

test('Confidentiality must be set on an application before cancelling if other info is the only potential source of confidentiality', async () => {
const preferredStartDate = mockedTime
const fixture: DevApplicationWithForm = {
...applicationFixture(
testChild2,
familyWithTwoGuardians.guardian,
undefined,
'DAYCARE',
null,
[testDaycare.id],
true,
'SENT',
preferredStartDate
)
}
fixture.form.otherInfo = 'Eipä ihmeempiä'

const applicationId = fixture.id

await createApplications({ body: [fixture] })

await employeeLogin(page, serviceWorker)
await page.goto(ApplicationListView.url)
await applicationWorkbench.waitUntilLoaded()

const applicationList = new ApplicationListView(page)
await applicationList.actionsMenu(applicationId).click()
await applicationList.actionsMenuItems.cancelApplication.click()

await applicationList.cancelConfirmation.submitButton.assertDisabled(true)
await applicationList.cancelConfirmation.confidentialRadioYes.waitUntilVisible()
await applicationList.cancelConfirmation.confidentialRadioYes.check()
await applicationList.cancelConfirmation.submitButton.assertDisabled(false)
await applicationList.cancelConfirmation.submitButton.click()

await applicationWorkbench.applicationsAll.click()
await applicationWorkbench
.getApplicationListItem(applicationId)
.assertText((text) => text.includes('Poistettu käsittelystä'))
})

test('Placement dialog works', async () => {
const preferredStartDate = mockedTime

Expand Down

0 comments on commit 06c4b0d

Please sign in to comment.