From 06c4b0d9c8dde3cb8adedbe5b88f2888b6a7ec64 Mon Sep 17 00:00:00 2001 From: Joosa Kurvinen Date: Tue, 3 Dec 2024 16:20:51 +0200 Subject: [PATCH] add e2e test for cancellation --- .../applications/application-list-view.ts | 27 +++++++---- .../application-transitions.spec.ts | 45 ++++++++++++++++++- 2 files changed, 61 insertions(+), 11 deletions(-) diff --git a/frontend/src/e2e-test/pages/employee/applications/application-list-view.ts b/frontend/src/e2e-test/pages/employee/applications/application-list-view.ts index d65644829bc..8eb4fed168f 100644 --- a/frontend/src/e2e-test/pages/employee/applications/application-list-view.ts +++ b/frontend/src/e2e-test/pages/employee/applications/application-list-view.ts @@ -10,7 +10,8 @@ import { MultiSelect, Page, Element, - ElementCollection + ElementCollection, + Radio } from '../../../utils/page' export default class ApplicationListView { @@ -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 @@ -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') @@ -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) diff --git a/frontend/src/e2e-test/specs/5_employee/application-transitions.spec.ts b/frontend/src/e2e-test/specs/5_employee/application-transitions.spec.ts index 7915f3c55f3..e8997f5d04f 100755 --- a/frontend/src/e2e-test/specs/5_employee/application-transitions.spec.ts +++ b/frontend/src/e2e-test/specs/5_employee/application-transitions.spec.ts @@ -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() @@ -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