From 4af54d38fb228e41750c9a72bfddb859e29a6640 Mon Sep 17 00:00:00 2001 From: Tom Hanmer Date: Thu, 4 Jun 2026 10:26:47 +0100 Subject: [PATCH 1/9] PDJB-1039: extract out shared functionality into new task --- .DS_Store | Bin 0 -> 8196 bytes .../PropertyRegistrationJourneyFactory.kt | 2 + .../states/InviteJointLandlordsTaskState.kt | 22 +++++++ .../states/JointLandlordsState.kt | 18 +----- .../steps/CheckJointLandlordsStepConfig.kt | 16 ++--- .../steps/InviteJointLandlordStepConfig.kt | 22 +++---- ...RemoveJointLandlordAreYouSureStepConfig.kt | 18 +++--- .../tasks/InviteJointLandlordsTask.kt | 53 +++++++++++++++++ .../tasks/JointLandlordsTask.kt | 56 +++++------------- .../CheckJointLandlordsStepConfigTests.kt | 4 +- .../InviteJointLandlordStepConfigTests.kt | 4 +- 11 files changed, 128 insertions(+), 87 deletions(-) create mode 100644 .DS_Store create mode 100644 src/main/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/states/InviteJointLandlordsTaskState.kt create mode 100644 src/main/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/tasks/InviteJointLandlordsTask.kt diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..972c2382419d5dae9f8cacad94ca04233095d7a1 GIT binary patch literal 8196 zcmeHM+lmuG5Ivnlv$8?5h>*wNy8-`TTz4N9)CcziG&h&HVR>O47blp$aTq*(J&gO($hF z;dQ?uZ3~8gAz%m?0)~Jga103Woh{?!z8-NeF|)SqG(OP{9F z^f)2<`;d&ax_FH%yuu~k%AER8oMP!7mds(s*xwUXIjePd_u&@nwJBTYu}Hq|ae~;2 z5zDTQnaiB}>i6-MxqRZzR#>L-2?mLU9`TJW9MWSwC3=tWj{c-p-;j=&TUP0UM558- zF5YXrWOPz_jS80vO7zaO3QA^HGuDw-?h+qa4>#(Ud8Ro^UAb=&N?m%I(#nGR4S$Mh zEd3f+wl*9BXT<)q^iP6MC3x-anid#40%2byduz@r{r+h O4*?2;O@_cfMc_BUb~ZQw literal 0 HcmV?d00001 diff --git a/src/main/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/PropertyRegistrationJourneyFactory.kt b/src/main/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/PropertyRegistrationJourneyFactory.kt index a10a906607..d03d79300c 100644 --- a/src/main/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/PropertyRegistrationJourneyFactory.kt +++ b/src/main/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/PropertyRegistrationJourneyFactory.kt @@ -103,6 +103,7 @@ import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.tasks.EpcTa import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.tasks.GasSafetyDetailsTask import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.tasks.GasSafetyTask import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.tasks.HouseholdsAndTenantsTask +import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.tasks.InviteJointLandlordsTask import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.tasks.JointLandlordsTask import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.tasks.LicensingTask import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.tasks.OccupationTask @@ -436,6 +437,7 @@ class PropertyRegistrationJourney( override val rentAmount: RentAmountStep, // Joint landlords task override val jointLandlordsTask: JointLandlordsTask, + override val inviteJointLandlordsTask: InviteJointLandlordsTask, override val hasAnyJointLandlordsInvitedStep: HasAnyJointLandlordsInvitedStep, override val hasJointLandlordsStep: HasJointLandlordsStep, override val inviteJointLandlordStep: InviteJointLandlordStep, diff --git a/src/main/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/states/InviteJointLandlordsTaskState.kt b/src/main/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/states/InviteJointLandlordsTaskState.kt new file mode 100644 index 0000000000..41e88b788b --- /dev/null +++ b/src/main/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/states/InviteJointLandlordsTaskState.kt @@ -0,0 +1,22 @@ +package uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.states + +import uk.gov.communities.prsdb.webapp.journeys.JourneyState +import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.steps.CheckJointLandlordsStep +import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.steps.InviteJointLandlordStep +import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.steps.RemoveJointLandlordAreYouSureStep + +interface InviteJointLandlordsTaskState : JourneyState { + val inviteJointLandlordStep: InviteJointLandlordStep + val inviteAnotherJointLandlordStep: InviteJointLandlordStep + val checkJointLandlordsStep: CheckJointLandlordsStep + val removeJointLandlordAreYouSureStep: RemoveJointLandlordAreYouSureStep + + var invitedJointLandlordEmailsMap: Map? + var nextJointLandlordMemberId: Int? + + val invitedJointLandlords: List + get() = invitedJointLandlordEmailsMap?.values?.toList() ?: emptyList() + + val existingPropertyLandlordEmails: List + get() = emptyList() +} diff --git a/src/main/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/states/JointLandlordsState.kt b/src/main/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/states/JointLandlordsState.kt index 4068322567..861d584e02 100644 --- a/src/main/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/states/JointLandlordsState.kt +++ b/src/main/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/states/JointLandlordsState.kt @@ -1,25 +1,13 @@ package uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.states -import uk.gov.communities.prsdb.webapp.journeys.JourneyState -import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.steps.CheckJointLandlordsStep import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.steps.HasAnyJointLandlordsInvitedStep import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.steps.HasJointLandlordsStep -import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.steps.InviteJointLandlordStep -import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.steps.RemoveJointLandlordAreYouSureStep +import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.tasks.InviteJointLandlordsTask -interface JointLandlordsState : JourneyState { +interface JointLandlordsState : InviteJointLandlordsTaskState { val hasAnyJointLandlordsInvitedStep: HasAnyJointLandlordsInvitedStep val hasJointLandlordsStep: HasJointLandlordsStep - val inviteJointLandlordStep: InviteJointLandlordStep - val inviteAnotherJointLandlordStep: InviteJointLandlordStep - val checkJointLandlordsStep: CheckJointLandlordsStep - val removeJointLandlordAreYouSureStep: RemoveJointLandlordAreYouSureStep - - var invitedJointLandlordEmailsMap: Map? - var nextJointLandlordMemberId: Int? - - val invitedJointLandlords: List - get() = invitedJointLandlordEmailsMap?.values?.toList() ?: emptyList() + val inviteJointLandlordsTask: InviteJointLandlordsTask } enum class AnyLandlordsInvited { diff --git a/src/main/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/steps/CheckJointLandlordsStepConfig.kt b/src/main/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/steps/CheckJointLandlordsStepConfig.kt index 0fef0a130d..ce1a007f2f 100644 --- a/src/main/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/steps/CheckJointLandlordsStepConfig.kt +++ b/src/main/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/steps/CheckJointLandlordsStepConfig.kt @@ -4,7 +4,7 @@ import uk.gov.communities.prsdb.webapp.annotations.webAnnotations.JourneyFramewo import uk.gov.communities.prsdb.webapp.journeys.AbstractRequestableStepConfig import uk.gov.communities.prsdb.webapp.journeys.Destination import uk.gov.communities.prsdb.webapp.journeys.JourneyStep.RequestableStep -import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.states.JointLandlordsState +import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.states.InviteJointLandlordsTaskState import uk.gov.communities.prsdb.webapp.journeys.shared.Complete import uk.gov.communities.prsdb.webapp.models.requestModels.formModels.NoInputFormModel import uk.gov.communities.prsdb.webapp.models.viewModels.summaryModels.SummaryListRowActionsInputWithDestination @@ -14,10 +14,10 @@ import uk.gov.communities.prsdb.webapp.services.CollectionKeyParameterService @JourneyFrameworkComponent class CheckJointLandlordsStepConfig( private val urlParameterService: CollectionKeyParameterService, -) : AbstractRequestableStepConfig() { +) : AbstractRequestableStepConfig() { override val formModelClass = NoInputFormModel::class - override fun getStepSpecificContent(state: JointLandlordsState) = + override fun getStepSpecificContent(state: InviteJointLandlordsTaskState) = mapOf( "addAnotherTitle" to "jointLandlords.checkJointLandlords.heading", "optionalAddAnotherTitleParam" to getJointLandlordsCount(state), @@ -29,7 +29,7 @@ class CheckJointLandlordsStepConfig( "addAnotherUrl" to Destination(state.inviteAnotherJointLandlordStep).toUrlStringOrNull(), ) - private fun getEmailRows(state: JointLandlordsState): List { + private fun getEmailRows(state: InviteJointLandlordsTaskState): List { val invitedEmails = state.invitedJointLandlordEmailsMap ?: emptyMap() return invitedEmails .toList() @@ -60,17 +60,17 @@ class CheckJointLandlordsStepConfig( } } - override fun chooseTemplate(state: JointLandlordsState): String = "forms/addAnotherForm" + override fun chooseTemplate(state: InviteJointLandlordsTaskState): String = "forms/addAnotherForm" - override fun mode(state: JointLandlordsState) = getFormModelFromStateOrNull(state)?.let { Complete.COMPLETE } + override fun mode(state: InviteJointLandlordsTaskState) = getFormModelFromStateOrNull(state)?.let { Complete.COMPLETE } - private fun getJointLandlordsCount(state: JointLandlordsState): Int = getEmailRows(state).size + private fun getJointLandlordsCount(state: InviteJointLandlordsTaskState): Int = getEmailRows(state).size } @JourneyFrameworkComponent final class CheckJointLandlordsStep( stepConfig: CheckJointLandlordsStepConfig, -) : RequestableStep(stepConfig) { +) : RequestableStep(stepConfig) { companion object { const val ROUTE_SEGMENT = "check-joint-landlords" } diff --git a/src/main/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/steps/InviteJointLandlordStepConfig.kt b/src/main/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/steps/InviteJointLandlordStepConfig.kt index 41301ee690..f82f0abf5b 100644 --- a/src/main/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/steps/InviteJointLandlordStepConfig.kt +++ b/src/main/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/steps/InviteJointLandlordStepConfig.kt @@ -5,7 +5,7 @@ import uk.gov.communities.prsdb.webapp.constants.FORM_MODEL_ATTR_NAME import uk.gov.communities.prsdb.webapp.journeys.AbstractRequestableStepConfig import uk.gov.communities.prsdb.webapp.journeys.FormData import uk.gov.communities.prsdb.webapp.journeys.JourneyStep.RequestableStep -import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.states.JointLandlordsState +import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.states.InviteJointLandlordsTaskState import uk.gov.communities.prsdb.webapp.journeys.shared.Complete import uk.gov.communities.prsdb.webapp.models.requestModels.formModels.InviteJointLandlordsFormModel import uk.gov.communities.prsdb.webapp.services.CollectionKeyParameterService @@ -13,10 +13,10 @@ import uk.gov.communities.prsdb.webapp.services.CollectionKeyParameterService @JourneyFrameworkComponent class InviteJointLandlordStepConfig( private val urlParameterService: CollectionKeyParameterService, -) : AbstractRequestableStepConfig() { +) : AbstractRequestableStepConfig() { override val formModelClass = InviteJointLandlordsFormModel::class - override fun getStepSpecificContent(state: JointLandlordsState): Map = + override fun getStepSpecificContent(state: InviteJointLandlordsTaskState): Map = mutableMapOf( "fieldSetHeading" to "jointLandlords.inviteJointLandlord.fieldSetHeading", "label" to "jointLandlords.inviteJointLandlord.email.label", @@ -24,7 +24,7 @@ class InviteJointLandlordStepConfig( ) override fun resolvePageContent( - state: JointLandlordsState, + state: InviteJointLandlordsTaskState, defaultContent: Map, ): Map { val formModel = defaultContent[FORM_MODEL_ATTR_NAME] as? InviteJointLandlordsFormModel @@ -36,16 +36,16 @@ class InviteJointLandlordStepConfig( return defaultContent + (FORM_MODEL_ATTR_NAME to prepopulatedFormModel) } - override fun chooseTemplate(state: JointLandlordsState): String = "forms/emailForm" + override fun chooseTemplate(state: InviteJointLandlordsTaskState): String = "forms/emailForm" - override fun mode(state: JointLandlordsState) = + override fun mode(state: InviteJointLandlordsTaskState) = if (state.invitedJointLandlords.isEmpty()) { null } else { Complete.COMPLETE } - override fun beforeAttemptingToReachStep(state: JointLandlordsState): Boolean { + override fun beforeAttemptingToReachStep(state: InviteJointLandlordsTaskState): Boolean { val keyToUpdate = urlParameterService.getParameterOrNull() ?: return true val currentMap = state.invitedJointLandlordEmailsMap ?: emptyMap() @@ -54,7 +54,7 @@ class InviteJointLandlordStepConfig( } override fun enrichSubmittedDataBeforeValidation( - state: JointLandlordsState, + state: InviteJointLandlordsTaskState, formData: FormData, ): FormData { val emailBeingEdited = getEmailToEditOrNull(state) @@ -64,7 +64,7 @@ class InviteJointLandlordStepConfig( (InviteJointLandlordsFormModel::emailBeingEdited.name to emailBeingEdited) } - override fun afterStepDataIsAdded(state: JointLandlordsState) { + override fun afterStepDataIsAdded(state: InviteJointLandlordsTaskState) { val formModel = getFormModelFromState(state) val currentMap = state.invitedJointLandlordEmailsMap?.toMutableMap() ?: mutableMapOf() @@ -84,7 +84,7 @@ class InviteJointLandlordStepConfig( state.inviteAnotherJointLandlordStep.clearFormData() } - private fun getEmailToEditOrNull(state: JointLandlordsState): String? { + private fun getEmailToEditOrNull(state: InviteJointLandlordsTaskState): String? { val keyToUpdate = urlParameterService.getParameterOrNull() ?: return null return state.invitedJointLandlordEmailsMap?.get(keyToUpdate) @@ -94,7 +94,7 @@ class InviteJointLandlordStepConfig( @JourneyFrameworkComponent final class InviteJointLandlordStep( stepConfig: InviteJointLandlordStepConfig, -) : RequestableStep(stepConfig) { +) : RequestableStep(stepConfig) { companion object { const val INVITE_FIRST_ROUTE_SEGMENT = "invite-joint-landlord" const val INVITE_ANOTHER_ROUTE_SEGMENT = "invite-another-joint-landlord" diff --git a/src/main/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/steps/RemoveJointLandlordAreYouSureStepConfig.kt b/src/main/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/steps/RemoveJointLandlordAreYouSureStepConfig.kt index 2c709a5ded..c1e9f64e6e 100644 --- a/src/main/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/steps/RemoveJointLandlordAreYouSureStepConfig.kt +++ b/src/main/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/steps/RemoveJointLandlordAreYouSureStepConfig.kt @@ -4,7 +4,7 @@ import uk.gov.communities.prsdb.webapp.annotations.webAnnotations.JourneyFramewo import uk.gov.communities.prsdb.webapp.journeys.AbstractRequestableStepConfig import uk.gov.communities.prsdb.webapp.journeys.JourneyStep.RequestableStep import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.states.AnyLandlordsInvited -import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.states.JointLandlordsState +import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.states.InviteJointLandlordsTaskState import uk.gov.communities.prsdb.webapp.models.requestModels.formModels.RemoveJointLandlordAreYouSureFormModel import uk.gov.communities.prsdb.webapp.models.viewModels.formModels.RadiosViewModel import uk.gov.communities.prsdb.webapp.services.CollectionKeyParameterService @@ -12,10 +12,10 @@ import uk.gov.communities.prsdb.webapp.services.CollectionKeyParameterService @JourneyFrameworkComponent class RemoveJointLandlordAreYouSureStepConfig( private val urlParameterService: CollectionKeyParameterService, -) : AbstractRequestableStepConfig() { +) : AbstractRequestableStepConfig() { override val formModelClass = RemoveJointLandlordAreYouSureFormModel::class - override fun getStepSpecificContent(state: JointLandlordsState) = + override fun getStepSpecificContent(state: InviteJointLandlordsTaskState) = mapOf( "fieldSetHeading" to "jointLandlords.removeJointLandlord.fieldSetHeading", "fieldSetHint" to "jointLandlords.removeJointLandlord.fieldSetHint", @@ -23,23 +23,23 @@ class RemoveJointLandlordAreYouSureStepConfig( "optionalFieldSetHeadingParam" to getLandlordEmailToRemove(state), ) - override fun chooseTemplate(state: JointLandlordsState): String = "forms/areYouSureForm" + override fun chooseTemplate(state: InviteJointLandlordsTaskState): String = "forms/areYouSureForm" - override fun mode(state: JointLandlordsState) = + override fun mode(state: InviteJointLandlordsTaskState) = if (state.invitedJointLandlords.isEmpty()) { AnyLandlordsInvited.NO_LANDLORDS } else { AnyLandlordsInvited.SOME_LANDLORDS } - override fun beforeAttemptingToReachStep(state: JointLandlordsState): Boolean { + override fun beforeAttemptingToReachStep(state: InviteJointLandlordsTaskState): Boolean { val keyToRemove = urlParameterService.getParameterOrNull() val currentMap = state.invitedJointLandlordEmailsMap ?: emptyMap() return keyToRemove != null && keyToRemove in currentMap.keys } - override fun afterStepDataIsAdded(state: JointLandlordsState) { + override fun afterStepDataIsAdded(state: InviteJointLandlordsTaskState) { if (getFormModelFromStateOrNull(state)?.wantsToProceed == false) { return } @@ -49,7 +49,7 @@ class RemoveJointLandlordAreYouSureStepConfig( state.invitedJointLandlordEmailsMap = currentMap } - private fun getLandlordEmailToRemove(state: JointLandlordsState): String? { + private fun getLandlordEmailToRemove(state: InviteJointLandlordsTaskState): String? { val keyToRemove = urlParameterService.getParameterOrNull() return state.invitedJointLandlordEmailsMap?.get(keyToRemove) } @@ -58,7 +58,7 @@ class RemoveJointLandlordAreYouSureStepConfig( @JourneyFrameworkComponent final class RemoveJointLandlordAreYouSureStep( stepConfig: RemoveJointLandlordAreYouSureStepConfig, -) : RequestableStep(stepConfig) { +) : RequestableStep(stepConfig) { companion object { const val ROUTE_SEGMENT = "remove-joint-landlord" } diff --git a/src/main/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/tasks/InviteJointLandlordsTask.kt b/src/main/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/tasks/InviteJointLandlordsTask.kt new file mode 100644 index 0000000000..829ca5c4ff --- /dev/null +++ b/src/main/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/tasks/InviteJointLandlordsTask.kt @@ -0,0 +1,53 @@ +package uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.tasks + +import uk.gov.communities.prsdb.webapp.annotations.webAnnotations.JourneyFrameworkComponent +import uk.gov.communities.prsdb.webapp.journeys.OrParents +import uk.gov.communities.prsdb.webapp.journeys.Task +import uk.gov.communities.prsdb.webapp.journeys.hasOutcome +import uk.gov.communities.prsdb.webapp.journeys.isComplete +import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.states.AnyLandlordsInvited +import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.states.InviteJointLandlordsTaskState +import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.steps.CheckJointLandlordsStep +import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.steps.InviteJointLandlordStep +import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.steps.RemoveJointLandlordAreYouSureStep + +@JourneyFrameworkComponent +class InviteJointLandlordsTask : Task() { + override fun makeSubJourney(state: InviteJointLandlordsTaskState) = + subJourney(state) { + step(journey.inviteJointLandlordStep) { + routeSegment(InviteJointLandlordStep.INVITE_FIRST_ROUTE_SEGMENT) + nextStep { journey.checkJointLandlordsStep } + } + step(journey.checkJointLandlordsStep) { + routeSegment(CheckJointLandlordsStep.ROUTE_SEGMENT) + parents { journey.inviteJointLandlordStep.isComplete() } + nextStep { exitStep } + } + step(journey.inviteAnotherJointLandlordStep) { + routeSegment(InviteJointLandlordStep.INVITE_ANOTHER_ROUTE_SEGMENT) + parents { journey.inviteJointLandlordStep.isComplete() } + backStep { journey.checkJointLandlordsStep } + nextStep { journey.checkJointLandlordsStep } + } + step(journey.removeJointLandlordAreYouSureStep) { + routeSegment(RemoveJointLandlordAreYouSureStep.ROUTE_SEGMENT) + parents { journey.inviteJointLandlordStep.isComplete() } + backStep { journey.checkJointLandlordsStep } + nextStep { mode -> + when (mode) { + AnyLandlordsInvited.SOME_LANDLORDS -> journey.checkJointLandlordsStep + AnyLandlordsInvited.NO_LANDLORDS -> exitStep + } + } + } + exitStep { + parents { + OrParents( + journey.checkJointLandlordsStep.isComplete(), + journey.removeJointLandlordAreYouSureStep.hasOutcome(AnyLandlordsInvited.NO_LANDLORDS), + ) + } + } + } +} diff --git a/src/main/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/tasks/JointLandlordsTask.kt b/src/main/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/tasks/JointLandlordsTask.kt index ed6c711637..9d6d05afcb 100644 --- a/src/main/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/tasks/JointLandlordsTask.kt +++ b/src/main/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/tasks/JointLandlordsTask.kt @@ -2,16 +2,14 @@ package uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.tasks import uk.gov.communities.prsdb.webapp.annotations.webAnnotations.JourneyFrameworkComponent import uk.gov.communities.prsdb.webapp.constants.enums.TaskStatus +import uk.gov.communities.prsdb.webapp.journeys.Destination import uk.gov.communities.prsdb.webapp.journeys.OrParents import uk.gov.communities.prsdb.webapp.journeys.Task import uk.gov.communities.prsdb.webapp.journeys.hasOutcome import uk.gov.communities.prsdb.webapp.journeys.isComplete import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.states.AnyLandlordsInvited import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.states.JointLandlordsState -import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.steps.CheckJointLandlordsStep import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.steps.HasJointLandlordsStep -import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.steps.InviteJointLandlordStep -import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.steps.RemoveJointLandlordAreYouSureStep import uk.gov.communities.prsdb.webapp.journeys.shared.YesOrNo @JourneyFrameworkComponent @@ -41,55 +39,33 @@ class JointLandlordsTask : Task() { parents { journey.hasAnyJointLandlordsInvitedStep.hasOutcome(AnyLandlordsInvited.NO_LANDLORDS) } nextStep { mode -> when (mode) { - YesOrNo.YES -> journey.inviteJointLandlordStep + YesOrNo.YES -> journey.inviteJointLandlordsTask.firstStep YesOrNo.NO -> exitStep } } savable() } - step(journey.inviteJointLandlordStep) { - routeSegment(InviteJointLandlordStep.INVITE_FIRST_ROUTE_SEGMENT) - parents { journey.hasJointLandlordsStep.hasOutcome(YesOrNo.YES) } - nextStep { journey.checkJointLandlordsStep } - } - step(journey.checkJointLandlordsStep) { - routeSegment(CheckJointLandlordsStep.ROUTE_SEGMENT) + task(journey.inviteJointLandlordsTask) { parents { OrParents( - journey.inviteJointLandlordStep.isComplete(), + journey.hasJointLandlordsStep.hasOutcome(YesOrNo.YES), journey.hasAnyJointLandlordsInvitedStep.hasOutcome(AnyLandlordsInvited.SOME_LANDLORDS), ) } - nextStep { exitStep } - } - step(journey.inviteAnotherJointLandlordStep) { - routeSegment(InviteJointLandlordStep.INVITE_ANOTHER_ROUTE_SEGMENT) - parents { journey.hasAnyJointLandlordsInvitedStep.hasOutcome(AnyLandlordsInvited.SOME_LANDLORDS) } - // If no back step is set, the parent is used instead. - // If an internal step is the back step, the journey will go back to the nearest visitable ancestor of the internal step. - // In this case, we want to go back to the check step, so we need to explicitly set the back step. - backStep { journey.checkJointLandlordsStep } - nextStep { journey.checkJointLandlordsStep } - } - step(journey.removeJointLandlordAreYouSureStep) { - routeSegment(RemoveJointLandlordAreYouSureStep.ROUTE_SEGMENT) - parents { - journey.hasAnyJointLandlordsInvitedStep.hasOutcome(AnyLandlordsInvited.SOME_LANDLORDS) - } - backStep { journey.checkJointLandlordsStep } - nextStep { mode -> - when (mode) { - AnyLandlordsInvited.SOME_LANDLORDS -> journey.checkJointLandlordsStep - AnyLandlordsInvited.NO_LANDLORDS -> journey.hasJointLandlordsStep + nextDestination { _ -> + if (journey.invitedJointLandlords.isEmpty()) { + Destination(journey.hasJointLandlordsStep) + } else { + Destination(exitStep) } } - exitStep { - parents { - OrParents( - journey.checkJointLandlordsStep.isComplete(), - journey.hasJointLandlordsStep.hasOutcome(YesOrNo.NO), - ) - } + } + exitStep { + parents { + OrParents( + journey.inviteJointLandlordsTask.isComplete(), + journey.hasJointLandlordsStep.hasOutcome(YesOrNo.NO), + ) } } } diff --git a/src/test/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/steps/CheckJointLandlordsStepConfigTests.kt b/src/test/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/steps/CheckJointLandlordsStepConfigTests.kt index 7d70196f4e..a2d0cfce0f 100644 --- a/src/test/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/steps/CheckJointLandlordsStepConfigTests.kt +++ b/src/test/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/steps/CheckJointLandlordsStepConfigTests.kt @@ -8,7 +8,7 @@ import org.mockito.junit.jupiter.MockitoExtension import org.mockito.kotlin.any import org.mockito.kotlin.whenever import uk.gov.communities.prsdb.webapp.journeys.JourneyIdProvider -import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.states.JointLandlordsState +import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.states.InviteJointLandlordsTaskState import uk.gov.communities.prsdb.webapp.models.viewModels.summaryModels.SummaryListRowViewModel import uk.gov.communities.prsdb.webapp.services.CollectionKeyParameterService import uk.gov.communities.prsdb.webapp.testHelpers.mockObjects.AlwaysTrueValidator @@ -16,7 +16,7 @@ import uk.gov.communities.prsdb.webapp.testHelpers.mockObjects.AlwaysTrueValidat @ExtendWith(MockitoExtension::class) class CheckJointLandlordsStepConfigTests { @Mock - lateinit var mockJourneyState: JointLandlordsState + lateinit var mockJourneyState: InviteJointLandlordsTaskState @Mock lateinit var urlParameterService: CollectionKeyParameterService diff --git a/src/test/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/steps/InviteJointLandlordStepConfigTests.kt b/src/test/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/steps/InviteJointLandlordStepConfigTests.kt index 18f31315e2..12f5c73a4b 100644 --- a/src/test/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/steps/InviteJointLandlordStepConfigTests.kt +++ b/src/test/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/steps/InviteJointLandlordStepConfigTests.kt @@ -9,14 +9,14 @@ import org.mockito.kotlin.argumentCaptor import org.mockito.kotlin.never import org.mockito.kotlin.verify import org.mockito.kotlin.whenever -import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.states.JointLandlordsState +import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.states.InviteJointLandlordsTaskState import uk.gov.communities.prsdb.webapp.services.CollectionKeyParameterService import uk.gov.communities.prsdb.webapp.testHelpers.mockObjects.AlwaysTrueValidator @ExtendWith(MockitoExtension::class) class InviteJointLandlordStepConfigTests { @Mock - lateinit var mockJourneyState: JointLandlordsState + lateinit var mockJourneyState: InviteJointLandlordsTaskState @Mock lateinit var urlParameterService: CollectionKeyParameterService From 1f5cfd6c29230200c30ecc147bfc3ff05ed4fe82 Mon Sep 17 00:00:00 2001 From: Tom Hanmer Date: Thu, 4 Jun 2026 14:53:22 +0100 Subject: [PATCH 2/9] PDJB-1039: add new joint landlord flow --- .../InviteJointLandlordController.kt | 108 ++++++++++++++++++ .../CheckInvitationsStepConfig.kt | 44 +++++++ .../InviteJointLandlordJourneyFactory.kt | 106 +++++++++++++++++ .../SendJointLandlordInvitationsStepConfig.kt | 39 +++++++ .../messages/inviteJointLandlord.yml | 14 +++ .../inviteJointLandlordConfirmation.html | 28 +++++ .../InviteJointLandlordControllerTests.kt | 82 +++++++++++++ 7 files changed, 421 insertions(+) create mode 100644 src/main/kotlin/uk/gov/communities/prsdb/webapp/controllers/InviteJointLandlordController.kt create mode 100644 src/main/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/update/inviteJointLandlord/CheckInvitationsStepConfig.kt create mode 100644 src/main/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/update/inviteJointLandlord/InviteJointLandlordJourneyFactory.kt create mode 100644 src/main/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/update/inviteJointLandlord/SendJointLandlordInvitationsStepConfig.kt create mode 100644 src/main/resources/messages/inviteJointLandlord.yml create mode 100644 src/main/resources/templates/inviteJointLandlordConfirmation.html create mode 100644 src/test/kotlin/uk/gov/communities/prsdb/webapp/controllers/InviteJointLandlordControllerTests.kt diff --git a/src/main/kotlin/uk/gov/communities/prsdb/webapp/controllers/InviteJointLandlordController.kt b/src/main/kotlin/uk/gov/communities/prsdb/webapp/controllers/InviteJointLandlordController.kt new file mode 100644 index 0000000000..db1b8ce282 --- /dev/null +++ b/src/main/kotlin/uk/gov/communities/prsdb/webapp/controllers/InviteJointLandlordController.kt @@ -0,0 +1,108 @@ +package uk.gov.communities.prsdb.webapp.controllers + +import org.springframework.http.HttpStatus +import org.springframework.security.access.prepost.PreAuthorize +import org.springframework.ui.Model +import org.springframework.web.bind.annotation.GetMapping +import org.springframework.web.bind.annotation.PathVariable +import org.springframework.web.bind.annotation.PostMapping +import org.springframework.web.bind.annotation.RequestMapping +import org.springframework.web.bind.annotation.RequestParam +import org.springframework.web.server.ResponseStatusException +import org.springframework.web.servlet.ModelAndView +import uk.gov.communities.prsdb.webapp.annotations.webAnnotations.AvailableWhenFeatureEnabled +import uk.gov.communities.prsdb.webapp.annotations.webAnnotations.PrsdbController +import uk.gov.communities.prsdb.webapp.constants.CONFIRMATION_PATH_SEGMENT +import uk.gov.communities.prsdb.webapp.constants.JOINT_LANDLORDS +import uk.gov.communities.prsdb.webapp.constants.LANDLORD_PATH_SEGMENT +import uk.gov.communities.prsdb.webapp.constants.PROPERTY_DETAILS_SEGMENT +import uk.gov.communities.prsdb.webapp.controllers.InviteJointLandlordController.Companion.INVITE_JOINT_LANDLORD_ROUTE +import uk.gov.communities.prsdb.webapp.journeys.FormData +import uk.gov.communities.prsdb.webapp.journeys.JourneyStateService +import uk.gov.communities.prsdb.webapp.journeys.NoSuchJourneyException +import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.update.inviteJointLandlord.InviteJointLandlordJourneyFactory +import uk.gov.communities.prsdb.webapp.services.PropertyOwnershipService +import java.security.Principal + +@PrsdbController +@RequestMapping(INVITE_JOINT_LANDLORD_ROUTE) +@PreAuthorize("hasRole('LANDLORD')") +class InviteJointLandlordController( + private val journeyFactory: InviteJointLandlordJourneyFactory, + private val propertyOwnershipService: PropertyOwnershipService, +) { + @GetMapping("{stepName}") + @AvailableWhenFeatureEnabled(JOINT_LANDLORDS) + fun getUpdateStep( + principal: Principal, + @PathVariable propertyOwnershipId: Long, + @PathVariable("stepName") stepName: String, + ): ModelAndView { + throwErrorIfUserIsNotAuthorized(principal.name, propertyOwnershipId) + return try { + val journeyMap = journeyFactory.createJourneySteps(propertyOwnershipId) + journeyMap[stepName]?.getStepModelAndView() + ?: throw ResponseStatusException(HttpStatus.NOT_FOUND, "Step not found") + } catch (_: NoSuchJourneyException) { + val journeyId = journeyFactory.initializeJourneyState(propertyOwnershipId, principal) + val redirectUrl = JourneyStateService.urlWithJourneyState(stepName, journeyId) + ModelAndView("redirect:$redirectUrl") + } + } + + @PostMapping("{stepName}") + @AvailableWhenFeatureEnabled(JOINT_LANDLORDS) + fun postUpdateStep( + model: Model, + principal: Principal, + @PathVariable propertyOwnershipId: Long, + @PathVariable("stepName") stepName: String, + @RequestParam formData: FormData, + ): ModelAndView { + throwErrorIfUserIsNotAuthorized(principal.name, propertyOwnershipId) + return try { + val journeyMap = journeyFactory.createJourneySteps(propertyOwnershipId) + journeyMap[stepName]?.postStepModelAndView(formData) + ?: throw ResponseStatusException(HttpStatus.NOT_FOUND, "Step not found") + } catch (_: NoSuchJourneyException) { + val journeyId = journeyFactory.initializeJourneyState(propertyOwnershipId, principal) + val redirectUrl = JourneyStateService.urlWithJourneyState(stepName, journeyId) + ModelAndView("redirect:$redirectUrl") + } + } + + @GetMapping(CONFIRMATION_PATH_SEGMENT) + @AvailableWhenFeatureEnabled(JOINT_LANDLORDS) + fun getConfirmation( + model: Model, + principal: Principal, + @PathVariable propertyOwnershipId: Long, + ): String { + throwErrorIfUserIsNotAuthorized(principal.name, propertyOwnershipId) + model.addAttribute( + "propertyDetailsUrl", + PropertyDetailsController.getPropertyDetailsPath(propertyOwnershipId), + ) + return "inviteJointLandlordConfirmation" + } + + private fun throwErrorIfUserIsNotAuthorized( + baseUserId: String, + propertyOwnershipId: Long, + ) { + if (!propertyOwnershipService.getIsAuthorizedToEditRecord(propertyOwnershipId, baseUserId)) { + throw ResponseStatusException( + HttpStatus.NOT_FOUND, + "User $baseUserId is not authorized to update property ownership $propertyOwnershipId", + ) + } + } + + companion object { + const val INVITE_JOINT_LANDLORD_ROUTE = + "/$LANDLORD_PATH_SEGMENT/$PROPERTY_DETAILS_SEGMENT/{propertyOwnershipId}/invite-joint-landlord" + + fun getInviteJointLandlordRoute(propertyOwnershipId: Long): String = + INVITE_JOINT_LANDLORD_ROUTE.replace("{propertyOwnershipId}", propertyOwnershipId.toString()) + } +} diff --git a/src/main/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/update/inviteJointLandlord/CheckInvitationsStepConfig.kt b/src/main/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/update/inviteJointLandlord/CheckInvitationsStepConfig.kt new file mode 100644 index 0000000000..7ba8ea8d5c --- /dev/null +++ b/src/main/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/update/inviteJointLandlord/CheckInvitationsStepConfig.kt @@ -0,0 +1,44 @@ +package uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.update.inviteJointLandlord + +import uk.gov.communities.prsdb.webapp.annotations.webAnnotations.JourneyFrameworkComponent +import uk.gov.communities.prsdb.webapp.journeys.AbstractRequestableStepConfig +import uk.gov.communities.prsdb.webapp.journeys.Destination +import uk.gov.communities.prsdb.webapp.journeys.JourneyStep.RequestableStep +import uk.gov.communities.prsdb.webapp.journeys.shared.Complete +import uk.gov.communities.prsdb.webapp.models.requestModels.formModels.NoInputFormModel +import uk.gov.communities.prsdb.webapp.models.viewModels.summaryModels.SummaryListRowViewModel + +@JourneyFrameworkComponent +class CheckInvitationsStepConfig : + AbstractRequestableStepConfig() { + override val formModelClass = NoInputFormModel::class + + override fun chooseTemplate(state: InviteJointLandlordJourneyState): String = "forms/checkAnswersForm" + + override fun mode(state: InviteJointLandlordJourneyState) = getFormModelFromStateOrNull(state)?.let { Complete.COMPLETE } + + override fun getStepSpecificContent(state: InviteJointLandlordJourneyState) = + mapOf( + "summaryName" to "inviteJointLandlord.checkInvitations.summaryName", + "summaryListData" to getInvitationsSummaryRow(state), + "submitButtonText" to "inviteJointLandlord.checkInvitations.submitButtonText", + ) + + private fun getInvitationsSummaryRow(state: InviteJointLandlordJourneyState): List = + listOf( + SummaryListRowViewModel.forCheckYourAnswersPage( + "forms.checkPropertyAnswers.jointLandlordsDetails.invitations", + state.invitedJointLandlords, + destination = Destination(state.checkJointLandlordsStep), + ), + ) +} + +@JourneyFrameworkComponent +class CheckInvitationsStep( + stepConfig: CheckInvitationsStepConfig, +) : RequestableStep(stepConfig) { + companion object { + const val ROUTE_SEGMENT = "check-invitations" + } +} diff --git a/src/main/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/update/inviteJointLandlord/InviteJointLandlordJourneyFactory.kt b/src/main/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/update/inviteJointLandlord/InviteJointLandlordJourneyFactory.kt new file mode 100644 index 0000000000..b928551060 --- /dev/null +++ b/src/main/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/update/inviteJointLandlord/InviteJointLandlordJourneyFactory.kt @@ -0,0 +1,106 @@ +package uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.update.inviteJointLandlord + +import org.springframework.beans.factory.ObjectFactory +import uk.gov.communities.prsdb.webapp.annotations.webAnnotations.JourneyFrameworkComponent +import uk.gov.communities.prsdb.webapp.annotations.webAnnotations.PrsdbWebService +import uk.gov.communities.prsdb.webapp.controllers.InviteJointLandlordController +import uk.gov.communities.prsdb.webapp.controllers.PropertyDetailsController +import uk.gov.communities.prsdb.webapp.exceptions.PrsdbWebException +import uk.gov.communities.prsdb.webapp.journeys.AbstractPropertyOwnershipUpdateJourneyState +import uk.gov.communities.prsdb.webapp.journeys.Destination +import uk.gov.communities.prsdb.webapp.journeys.JourneyState +import uk.gov.communities.prsdb.webapp.journeys.JourneyStateDelegateProvider +import uk.gov.communities.prsdb.webapp.journeys.JourneyStateService +import uk.gov.communities.prsdb.webapp.journeys.StepLifecycleOrchestrator +import uk.gov.communities.prsdb.webapp.journeys.builders.JourneyBuilder.Companion.journey +import uk.gov.communities.prsdb.webapp.journeys.isComplete +import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.states.InviteJointLandlordsTaskState +import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.steps.CheckJointLandlordsStep +import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.steps.InviteJointLandlordStep +import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.steps.RemoveJointLandlordAreYouSureStep +import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.tasks.InviteJointLandlordsTask +import uk.gov.communities.prsdb.webapp.services.PropertyOwnershipService +import java.security.Principal + +@PrsdbWebService +class InviteJointLandlordJourneyFactory( + private val stateFactory: ObjectFactory, + private val propertyOwnershipService: PropertyOwnershipService, +) { + fun createJourneySteps(propertyId: Long): Map { + val state = stateFactory.getObject() + + if (!state.isStateInitialized) { + state.propertyId = propertyId + state.lastModifiedDate = propertyOwnershipService.getPropertyOwnership(propertyId).getMostRecentlyUpdated().toString() + state.isStateInitialized = true + } + + if (state.propertyId != propertyId) { + throw PrsdbWebException("Journey state propertyId ${state.propertyId} does not match provided propertyId $propertyId") + } + + val propertyDetailsRoute = PropertyDetailsController.getPropertyDetailsPath(propertyId) + val confirmationRoute = + InviteJointLandlordController.getInviteJointLandlordRoute(propertyId) + "/confirmation" + + return journey(state) { + unreachableStepUrl { propertyDetailsRoute } + task(journey.inviteJointLandlordsTask) { + initialStep() + backUrl { propertyDetailsRoute } + nextDestination { _ -> + if (journey.invitedJointLandlords.isEmpty()) { + Destination.ExternalUrl(propertyDetailsRoute) + } else { + Destination(journey.checkInvitationsStep) + } + } + } + step(journey.checkInvitationsStep) { + routeSegment(CheckInvitationsStep.ROUTE_SEGMENT) + parents { journey.inviteJointLandlordsTask.isComplete() } + nextStep { journey.sendJointLandlordInvitationsStep } + } + step(journey.sendJointLandlordInvitationsStep) { + parents { journey.checkInvitationsStep.isComplete() } + nextUrl { confirmationRoute } + } + } + } + + fun initializeJourneyState( + ownershipId: Long, + user: Principal, + ): String = stateFactory.getObject().initializeOrRestoreState(Pair(ownershipId, user)) +} + +@JourneyFrameworkComponent +class InviteJointLandlordJourney( + override val inviteJointLandlordStep: InviteJointLandlordStep, + override val inviteAnotherJointLandlordStep: InviteJointLandlordStep, + override val checkJointLandlordsStep: CheckJointLandlordsStep, + override val removeJointLandlordAreYouSureStep: RemoveJointLandlordAreYouSureStep, + override val inviteJointLandlordsTask: InviteJointLandlordsTask, + override val checkInvitationsStep: CheckInvitationsStep, + override val sendJointLandlordInvitationsStep: SendJointLandlordInvitationsStep, + journeyStateService: JourneyStateService, + journeyName: String = "inviteJointLandlord", +) : AbstractPropertyOwnershipUpdateJourneyState(journeyStateService, journeyName), + InviteJointLandlordJourneyState { + private val delegateProvider = JourneyStateDelegateProvider(journeyStateService) + override var propertyId: Long by delegateProvider.requiredImmutableDelegate("propertyId") + override var lastModifiedDate: String by delegateProvider.requiredImmutableDelegate("lastModifiedDate") + override var invitedJointLandlordEmailsMap: Map? by delegateProvider.nullableDelegate("invitedJointLandlordEmailsMap") + override var nextJointLandlordMemberId: Int? by delegateProvider.nullableDelegate("nextJointLandlordMemberId") +} + +interface InviteJointLandlordJourneyState : + JourneyState, + InviteJointLandlordsTaskState { + val inviteJointLandlordsTask: InviteJointLandlordsTask + val checkInvitationsStep: CheckInvitationsStep + val sendJointLandlordInvitationsStep: SendJointLandlordInvitationsStep + val propertyId: Long + val lastModifiedDate: String +} diff --git a/src/main/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/update/inviteJointLandlord/SendJointLandlordInvitationsStepConfig.kt b/src/main/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/update/inviteJointLandlord/SendJointLandlordInvitationsStepConfig.kt new file mode 100644 index 0000000000..dc1b8fc48b --- /dev/null +++ b/src/main/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/update/inviteJointLandlord/SendJointLandlordInvitationsStepConfig.kt @@ -0,0 +1,39 @@ +package uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.update.inviteJointLandlord + +import uk.gov.communities.prsdb.webapp.annotations.webAnnotations.JourneyFrameworkComponent +import uk.gov.communities.prsdb.webapp.journeys.AbstractInternalStepConfig +import uk.gov.communities.prsdb.webapp.journeys.Destination +import uk.gov.communities.prsdb.webapp.journeys.JourneyStep +import uk.gov.communities.prsdb.webapp.journeys.shared.Complete +import uk.gov.communities.prsdb.webapp.services.JointLandlordInvitationService +import uk.gov.communities.prsdb.webapp.services.PropertyOwnershipService + +@JourneyFrameworkComponent +class SendJointLandlordInvitationsStepConfig( + private val jointLandlordInvitationService: JointLandlordInvitationService, + private val propertyOwnershipService: PropertyOwnershipService, +) : AbstractInternalStepConfig() { + override fun mode(state: InviteJointLandlordJourneyState): Complete = Complete.COMPLETE + + override fun afterStepIsReached(state: InviteJointLandlordJourneyState) { + val propertyOwnership = propertyOwnershipService.getPropertyOwnership(state.propertyId) + jointLandlordInvitationService.sendInvitationEmails( + jointLandlordEmails = state.invitedJointLandlords, + propertyOwnership = propertyOwnership, + invitingLandlord = propertyOwnership.primaryLandlord, + ) + } + + override fun resolveNextDestination( + state: InviteJointLandlordJourneyState, + defaultDestination: Destination, + ): Destination { + state.deleteJourney() + return defaultDestination + } +} + +@JourneyFrameworkComponent +class SendJointLandlordInvitationsStep( + stepConfig: SendJointLandlordInvitationsStepConfig, +) : JourneyStep.InternalStep(stepConfig) diff --git a/src/main/resources/messages/inviteJointLandlord.yml b/src/main/resources/messages/inviteJointLandlord.yml new file mode 100644 index 0000000000..dba9cb91fe --- /dev/null +++ b/src/main/resources/messages/inviteJointLandlord.yml @@ -0,0 +1,14 @@ +inviteJointLandlord: + title: Invite joint landlords + checkInvitations: + heading: Check your invitations + paragraph: We'll send invitations to these email addresses. + summaryName: Invited email addresses + submitButtonText: Confirm and sendb + confirmation: + banner: + heading: Joint landlord invitations sent + body: + one: The joint landlords you’ve invited have 28 days to join the property. + two: We’ll email you when they accept or reject your invitation. + goBackToPropertyRecord: Go back to the property record diff --git a/src/main/resources/templates/inviteJointLandlordConfirmation.html b/src/main/resources/templates/inviteJointLandlordConfirmation.html new file mode 100644 index 0000000000..d25cad4c72 --- /dev/null +++ b/src/main/resources/templates/inviteJointLandlordConfirmation.html @@ -0,0 +1,28 @@ + + +
+
+ +
+

inviteJointLandlord.confirmation.banner.heading

+
+ +

+ inviteJointLandlord.confirmation.body.one +

+

+ inviteJointLandlord.confirmation.body.two +

+ +

+ inviteJointLandlord.confirmation.goBackToPropertyRecord +

+ +
+
+ diff --git a/src/test/kotlin/uk/gov/communities/prsdb/webapp/controllers/InviteJointLandlordControllerTests.kt b/src/test/kotlin/uk/gov/communities/prsdb/webapp/controllers/InviteJointLandlordControllerTests.kt new file mode 100644 index 0000000000..7fe9fd67ec --- /dev/null +++ b/src/test/kotlin/uk/gov/communities/prsdb/webapp/controllers/InviteJointLandlordControllerTests.kt @@ -0,0 +1,82 @@ +package uk.gov.communities.prsdb.webapp.controllers + +import org.junit.jupiter.api.Test +import org.mockito.kotlin.whenever +import org.springframework.beans.factory.annotation.Autowired +import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest +import org.springframework.security.test.context.support.WithMockUser +import org.springframework.test.context.bean.override.mockito.MockitoBean +import org.springframework.test.web.servlet.get +import org.springframework.web.context.WebApplicationContext +import uk.gov.communities.prsdb.webapp.journeys.StepLifecycleOrchestrator +import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.steps.InviteJointLandlordStep +import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.update.inviteJointLandlord.InviteJointLandlordJourneyFactory +import uk.gov.communities.prsdb.webapp.services.PropertyOwnershipService + +@WebMvcTest(InviteJointLandlordController::class) +class InviteJointLandlordControllerTests( + @Autowired webContext: WebApplicationContext, +) : BasePropertyDetailsUpdateControllerTests(webContext) { + @MockitoBean + private lateinit var journeyFactory: InviteJointLandlordJourneyFactory + + @MockitoBean + override lateinit var propertyOwnershipService: PropertyOwnershipService + + @MockitoBean + override lateinit var stepLifecycleOrchestrator: StepLifecycleOrchestrator.VisitableStepLifecycleOrchestrator + + override val propertyOwnershipId = 1L + + override val updateStepRoute = + InviteJointLandlordController.getInviteJointLandlordRoute(propertyOwnershipId) + + "/${InviteJointLandlordStep.INVITE_FIRST_ROUTE_SEGMENT}" + + override val formContent = "email=test@example.com" + + override fun stubCreateJourneySteps() { + whenever(journeyFactory.createJourneySteps(propertyOwnershipId)) + .thenReturn(mapOf(InviteJointLandlordStep.INVITE_FIRST_ROUTE_SEGMENT to stepLifecycleOrchestrator)) + } + + @Test + fun `getConfirmation returns a redirect for unauthenticated user`() { + mvc.get(confirmationRoute).andExpect { + status { is3xxRedirection() } + } + } + + @Test + @WithMockUser + fun `getConfirmation returns 403 for an unauthorised user`() { + mvc.get(confirmationRoute).andExpect { + status { isForbidden() } + } + } + + @Test + @WithMockUser(roles = ["LANDLORD"], value = LANDLORD_USER) + fun `getConfirmation returns 404 for a landlord user not authorised to edit the property`() { + whenever(propertyOwnershipService.getIsAuthorizedToEditRecord(propertyOwnershipId, LANDLORD_USER)) + .thenReturn(false) + + mvc.get(confirmationRoute).andExpect { + status { isNotFound() } + } + } + + @Test + @WithMockUser(roles = ["LANDLORD"], value = LANDLORD_USER) + fun `getConfirmation returns 200 for an authorised landlord user`() { + whenever(propertyOwnershipService.getIsAuthorizedToEditRecord(propertyOwnershipId, LANDLORD_USER)) + .thenReturn(true) + + mvc.get(confirmationRoute).andExpect { + status { isOk() } + model { attributeExists("propertyDetailsUrl") } + } + } + + private val confirmationRoute = + InviteJointLandlordController.getInviteJointLandlordRoute(propertyOwnershipId) + "/confirmation" +} From 1a0419156d2874d7a8dfa7364f3b9a4fc7a67e59 Mon Sep 17 00:00:00 2001 From: Tom Hanmer Date: Fri, 5 Jun 2026 09:51:21 +0100 Subject: [PATCH 3/9] PDJB-1039: cleanup --- .../states/InviteJointLandlordsTaskState.kt | 3 --- src/main/resources/messages/inviteJointLandlord.yml | 2 +- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/src/main/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/states/InviteJointLandlordsTaskState.kt b/src/main/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/states/InviteJointLandlordsTaskState.kt index 41e88b788b..68d826b868 100644 --- a/src/main/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/states/InviteJointLandlordsTaskState.kt +++ b/src/main/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/states/InviteJointLandlordsTaskState.kt @@ -16,7 +16,4 @@ interface InviteJointLandlordsTaskState : JourneyState { val invitedJointLandlords: List get() = invitedJointLandlordEmailsMap?.values?.toList() ?: emptyList() - - val existingPropertyLandlordEmails: List - get() = emptyList() } diff --git a/src/main/resources/messages/inviteJointLandlord.yml b/src/main/resources/messages/inviteJointLandlord.yml index dba9cb91fe..79497623b8 100644 --- a/src/main/resources/messages/inviteJointLandlord.yml +++ b/src/main/resources/messages/inviteJointLandlord.yml @@ -4,7 +4,7 @@ inviteJointLandlord: heading: Check your invitations paragraph: We'll send invitations to these email addresses. summaryName: Invited email addresses - submitButtonText: Confirm and sendb + submitButtonText: Confirm and send confirmation: banner: heading: Joint landlord invitations sent From dd5ea2b1944447f27fd38c46489912a39e099b5d Mon Sep 17 00:00:00 2001 From: Tom Hanmer Date: Fri, 5 Jun 2026 11:17:55 +0100 Subject: [PATCH 4/9] PDJB-1039: clean up names across PR --- .DS_Store | Bin 8196 -> 0 bytes .../PropertyRegistrationJourneyFactory.kt | 8 +++---- ...JointLandlordPropertyRegistrationState.kt} | 6 ++--- ...e.kt => SharedInviteJointLandlordState.kt} | 2 +- .../steps/CheckJointLandlordsStepConfig.kt | 16 ++++++------- .../HasAnyJointLandlordsInvitedStepConfig.kt | 9 +++---- .../steps/HasJointLandlordsConfig.kt | 13 ++++++----- .../steps/InviteJointLandlordStepConfig.kt | 22 +++++++++--------- ...RemoveJointLandlordAreYouSureStepConfig.kt | 18 +++++++------- .../tasks/JointLandlordsTask.kt | 6 ++--- ...k.kt => SharedInviteJointLandlordsTask.kt} | 6 ++--- ... CompleteInviteJointLandlordStepConfig.kt} | 6 ++--- .../InviteJointLandlordJourneyFactory.kt | 22 +++++++++--------- .../CheckJointLandlordsStepConfigTests.kt | 4 ++-- .../InviteJointLandlordStepConfigTests.kt | 4 ++-- 15 files changed, 72 insertions(+), 70 deletions(-) delete mode 100644 .DS_Store rename src/main/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/states/{JointLandlordsState.kt => InviteJointLandlordPropertyRegistrationState.kt} (73%) rename src/main/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/states/{InviteJointLandlordsTaskState.kt => SharedInviteJointLandlordState.kt} (94%) rename src/main/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/tasks/{InviteJointLandlordsTask.kt => SharedInviteJointLandlordsTask.kt} (93%) rename src/main/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/update/inviteJointLandlord/{SendJointLandlordInvitationsStepConfig.kt => CompleteInviteJointLandlordStepConfig.kt} (92%) diff --git a/.DS_Store b/.DS_Store deleted file mode 100644 index 972c2382419d5dae9f8cacad94ca04233095d7a1..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 8196 zcmeHM+lmuG5Ivnlv$8?5h>*wNy8-`TTz4N9)CcziG&h&HVR>O47blp$aTq*(J&gO($hF z;dQ?uZ3~8gAz%m?0)~Jga103Woh{?!z8-NeF|)SqG(OP{9F z^f)2<`;d&ax_FH%yuu~k%AER8oMP!7mds(s*xwUXIjePd_u&@nwJBTYu}Hq|ae~;2 z5zDTQnaiB}>i6-MxqRZzR#>L-2?mLU9`TJW9MWSwC3=tWj{c-p-;j=&TUP0UM558- zF5YXrWOPz_jS80vO7zaO3QA^HGuDw-?h+qa4>#(Ud8Ro^UAb=&N?m%I(#nGR4S$Mh zEd3f+wl*9BXT<)q^iP6MC3x-anid#40%2byduz@r{r+h O4*?2;O@_cfMc_BUb~ZQw diff --git a/src/main/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/PropertyRegistrationJourneyFactory.kt b/src/main/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/PropertyRegistrationJourneyFactory.kt index d03d79300c..9b5079a91d 100644 --- a/src/main/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/PropertyRegistrationJourneyFactory.kt +++ b/src/main/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/PropertyRegistrationJourneyFactory.kt @@ -20,7 +20,7 @@ import uk.gov.communities.prsdb.webapp.journeys.hasOutcome import uk.gov.communities.prsdb.webapp.journeys.isComplete import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.states.CertificateUpload import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.states.CombinedComplianceCheckState -import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.states.JointLandlordsState +import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.states.InviteJointLandlordPropertyRegistrationState import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.states.LicensingState import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.states.OccupationState import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.states.PropertyRegistrationAddressState @@ -103,13 +103,13 @@ import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.tasks.EpcTa import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.tasks.GasSafetyDetailsTask import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.tasks.GasSafetyTask import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.tasks.HouseholdsAndTenantsTask -import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.tasks.InviteJointLandlordsTask import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.tasks.JointLandlordsTask import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.tasks.LicensingTask import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.tasks.OccupationTask import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.tasks.PropertyRegistrationAddressTask import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.tasks.RentFrequencyAndAmountTask import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.tasks.RentIncludesBillsTask +import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.tasks.SharedInviteJointLandlordsTask import uk.gov.communities.prsdb.webapp.journeys.shared.states.CheckYourAnswersJourneyState import uk.gov.communities.prsdb.webapp.journeys.shared.states.CheckYourAnswersJourneyState.Companion.checkAnswerStep import uk.gov.communities.prsdb.webapp.journeys.shared.states.CheckYourAnswersJourneyState.Companion.checkAnswerTask @@ -437,7 +437,7 @@ class PropertyRegistrationJourney( override val rentAmount: RentAmountStep, // Joint landlords task override val jointLandlordsTask: JointLandlordsTask, - override val inviteJointLandlordsTask: InviteJointLandlordsTask, + override val inviteJointLandlordsTask: SharedInviteJointLandlordsTask, override val hasAnyJointLandlordsInvitedStep: HasAnyJointLandlordsInvitedStep, override val hasJointLandlordsStep: HasJointLandlordsStep, override val inviteJointLandlordStep: InviteJointLandlordStep, @@ -574,7 +574,7 @@ interface PropertyRegistrationJourneyState : PropertyRegistrationAddressState, LicensingState, OccupationState, - JointLandlordsState, + InviteJointLandlordPropertyRegistrationState, CombinedComplianceCheckState, CheckYourAnswersJourneyState { val taskListStep: PropertyRegistrationTaskListStep diff --git a/src/main/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/states/JointLandlordsState.kt b/src/main/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/states/InviteJointLandlordPropertyRegistrationState.kt similarity index 73% rename from src/main/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/states/JointLandlordsState.kt rename to src/main/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/states/InviteJointLandlordPropertyRegistrationState.kt index 861d584e02..34e605f44d 100644 --- a/src/main/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/states/JointLandlordsState.kt +++ b/src/main/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/states/InviteJointLandlordPropertyRegistrationState.kt @@ -2,12 +2,12 @@ package uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.states import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.steps.HasAnyJointLandlordsInvitedStep import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.steps.HasJointLandlordsStep -import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.tasks.InviteJointLandlordsTask +import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.tasks.SharedInviteJointLandlordsTask -interface JointLandlordsState : InviteJointLandlordsTaskState { +interface InviteJointLandlordPropertyRegistrationState : SharedInviteJointLandlordState { val hasAnyJointLandlordsInvitedStep: HasAnyJointLandlordsInvitedStep val hasJointLandlordsStep: HasJointLandlordsStep - val inviteJointLandlordsTask: InviteJointLandlordsTask + val inviteJointLandlordsTask: SharedInviteJointLandlordsTask } enum class AnyLandlordsInvited { diff --git a/src/main/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/states/InviteJointLandlordsTaskState.kt b/src/main/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/states/SharedInviteJointLandlordState.kt similarity index 94% rename from src/main/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/states/InviteJointLandlordsTaskState.kt rename to src/main/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/states/SharedInviteJointLandlordState.kt index 68d826b868..603044a56e 100644 --- a/src/main/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/states/InviteJointLandlordsTaskState.kt +++ b/src/main/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/states/SharedInviteJointLandlordState.kt @@ -5,7 +5,7 @@ import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.steps.Check import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.steps.InviteJointLandlordStep import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.steps.RemoveJointLandlordAreYouSureStep -interface InviteJointLandlordsTaskState : JourneyState { +interface SharedInviteJointLandlordState : JourneyState { val inviteJointLandlordStep: InviteJointLandlordStep val inviteAnotherJointLandlordStep: InviteJointLandlordStep val checkJointLandlordsStep: CheckJointLandlordsStep diff --git a/src/main/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/steps/CheckJointLandlordsStepConfig.kt b/src/main/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/steps/CheckJointLandlordsStepConfig.kt index ce1a007f2f..9579b1f9fa 100644 --- a/src/main/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/steps/CheckJointLandlordsStepConfig.kt +++ b/src/main/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/steps/CheckJointLandlordsStepConfig.kt @@ -4,7 +4,7 @@ import uk.gov.communities.prsdb.webapp.annotations.webAnnotations.JourneyFramewo import uk.gov.communities.prsdb.webapp.journeys.AbstractRequestableStepConfig import uk.gov.communities.prsdb.webapp.journeys.Destination import uk.gov.communities.prsdb.webapp.journeys.JourneyStep.RequestableStep -import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.states.InviteJointLandlordsTaskState +import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.states.SharedInviteJointLandlordState import uk.gov.communities.prsdb.webapp.journeys.shared.Complete import uk.gov.communities.prsdb.webapp.models.requestModels.formModels.NoInputFormModel import uk.gov.communities.prsdb.webapp.models.viewModels.summaryModels.SummaryListRowActionsInputWithDestination @@ -14,10 +14,10 @@ import uk.gov.communities.prsdb.webapp.services.CollectionKeyParameterService @JourneyFrameworkComponent class CheckJointLandlordsStepConfig( private val urlParameterService: CollectionKeyParameterService, -) : AbstractRequestableStepConfig() { +) : AbstractRequestableStepConfig() { override val formModelClass = NoInputFormModel::class - override fun getStepSpecificContent(state: InviteJointLandlordsTaskState) = + override fun getStepSpecificContent(state: SharedInviteJointLandlordState) = mapOf( "addAnotherTitle" to "jointLandlords.checkJointLandlords.heading", "optionalAddAnotherTitleParam" to getJointLandlordsCount(state), @@ -29,7 +29,7 @@ class CheckJointLandlordsStepConfig( "addAnotherUrl" to Destination(state.inviteAnotherJointLandlordStep).toUrlStringOrNull(), ) - private fun getEmailRows(state: InviteJointLandlordsTaskState): List { + private fun getEmailRows(state: SharedInviteJointLandlordState): List { val invitedEmails = state.invitedJointLandlordEmailsMap ?: emptyMap() return invitedEmails .toList() @@ -60,17 +60,17 @@ class CheckJointLandlordsStepConfig( } } - override fun chooseTemplate(state: InviteJointLandlordsTaskState): String = "forms/addAnotherForm" + override fun chooseTemplate(state: SharedInviteJointLandlordState): String = "forms/addAnotherForm" - override fun mode(state: InviteJointLandlordsTaskState) = getFormModelFromStateOrNull(state)?.let { Complete.COMPLETE } + override fun mode(state: SharedInviteJointLandlordState) = getFormModelFromStateOrNull(state)?.let { Complete.COMPLETE } - private fun getJointLandlordsCount(state: InviteJointLandlordsTaskState): Int = getEmailRows(state).size + private fun getJointLandlordsCount(state: SharedInviteJointLandlordState): Int = getEmailRows(state).size } @JourneyFrameworkComponent final class CheckJointLandlordsStep( stepConfig: CheckJointLandlordsStepConfig, -) : RequestableStep(stepConfig) { +) : RequestableStep(stepConfig) { companion object { const val ROUTE_SEGMENT = "check-joint-landlords" } diff --git a/src/main/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/steps/HasAnyJointLandlordsInvitedStepConfig.kt b/src/main/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/steps/HasAnyJointLandlordsInvitedStepConfig.kt index c6114deb87..786ae72faa 100644 --- a/src/main/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/steps/HasAnyJointLandlordsInvitedStepConfig.kt +++ b/src/main/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/steps/HasAnyJointLandlordsInvitedStepConfig.kt @@ -4,15 +4,16 @@ import uk.gov.communities.prsdb.webapp.annotations.webAnnotations.JourneyFramewo import uk.gov.communities.prsdb.webapp.journeys.AbstractInternalStepConfig import uk.gov.communities.prsdb.webapp.journeys.JourneyStep import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.states.AnyLandlordsInvited -import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.states.JointLandlordsState +import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.states.InviteJointLandlordPropertyRegistrationState @JourneyFrameworkComponent -class HasAnyJointLandlordsInvitedStepConfig : AbstractInternalStepConfig() { - override fun mode(state: JointLandlordsState) = +class HasAnyJointLandlordsInvitedStepConfig : + AbstractInternalStepConfig() { + override fun mode(state: InviteJointLandlordPropertyRegistrationState) = if (state.invitedJointLandlords.isNotEmpty()) AnyLandlordsInvited.SOME_LANDLORDS else AnyLandlordsInvited.NO_LANDLORDS } @JourneyFrameworkComponent final class HasAnyJointLandlordsInvitedStep( stepConfig: HasAnyJointLandlordsInvitedStepConfig, -) : JourneyStep.InternalStep(stepConfig) +) : JourneyStep.InternalStep(stepConfig) diff --git a/src/main/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/steps/HasJointLandlordsConfig.kt b/src/main/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/steps/HasJointLandlordsConfig.kt index 43a473999e..de508f3941 100644 --- a/src/main/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/steps/HasJointLandlordsConfig.kt +++ b/src/main/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/steps/HasJointLandlordsConfig.kt @@ -4,16 +4,17 @@ import uk.gov.communities.prsdb.webapp.annotations.webAnnotations.JourneyFramewo import uk.gov.communities.prsdb.webapp.constants.GOV_LEGAL_ADVICE_URL import uk.gov.communities.prsdb.webapp.journeys.AbstractRequestableStepConfig import uk.gov.communities.prsdb.webapp.journeys.JourneyStep.RequestableStep -import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.states.JointLandlordsState +import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.states.InviteJointLandlordPropertyRegistrationState import uk.gov.communities.prsdb.webapp.journeys.shared.YesOrNo import uk.gov.communities.prsdb.webapp.models.requestModels.formModels.HasJointLandlordsFormModel import uk.gov.communities.prsdb.webapp.models.viewModels.formModels.RadiosButtonViewModel @JourneyFrameworkComponent -class HasJointLandlordsConfig : AbstractRequestableStepConfig() { +class HasJointLandlordsConfig : + AbstractRequestableStepConfig() { override val formModelClass = HasJointLandlordsFormModel::class - override fun getStepSpecificContent(state: JointLandlordsState) = + override fun getStepSpecificContent(state: InviteJointLandlordPropertyRegistrationState) = mapOf( "title" to "registerProperty.title", "fieldSetHeading" to "jointLandlords.hasJointLandlords.heading", @@ -32,9 +33,9 @@ class HasJointLandlordsConfig : AbstractRequestableStepConfig YesOrNo.YES @@ -46,7 +47,7 @@ class HasJointLandlordsConfig : AbstractRequestableStepConfig(stepConfig) { +) : RequestableStep(stepConfig) { companion object { const val ROUTE_SEGMENT = "has-joint-landlords" } diff --git a/src/main/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/steps/InviteJointLandlordStepConfig.kt b/src/main/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/steps/InviteJointLandlordStepConfig.kt index f82f0abf5b..8455ee7e80 100644 --- a/src/main/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/steps/InviteJointLandlordStepConfig.kt +++ b/src/main/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/steps/InviteJointLandlordStepConfig.kt @@ -5,7 +5,7 @@ import uk.gov.communities.prsdb.webapp.constants.FORM_MODEL_ATTR_NAME import uk.gov.communities.prsdb.webapp.journeys.AbstractRequestableStepConfig import uk.gov.communities.prsdb.webapp.journeys.FormData import uk.gov.communities.prsdb.webapp.journeys.JourneyStep.RequestableStep -import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.states.InviteJointLandlordsTaskState +import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.states.SharedInviteJointLandlordState import uk.gov.communities.prsdb.webapp.journeys.shared.Complete import uk.gov.communities.prsdb.webapp.models.requestModels.formModels.InviteJointLandlordsFormModel import uk.gov.communities.prsdb.webapp.services.CollectionKeyParameterService @@ -13,10 +13,10 @@ import uk.gov.communities.prsdb.webapp.services.CollectionKeyParameterService @JourneyFrameworkComponent class InviteJointLandlordStepConfig( private val urlParameterService: CollectionKeyParameterService, -) : AbstractRequestableStepConfig() { +) : AbstractRequestableStepConfig() { override val formModelClass = InviteJointLandlordsFormModel::class - override fun getStepSpecificContent(state: InviteJointLandlordsTaskState): Map = + override fun getStepSpecificContent(state: SharedInviteJointLandlordState): Map = mutableMapOf( "fieldSetHeading" to "jointLandlords.inviteJointLandlord.fieldSetHeading", "label" to "jointLandlords.inviteJointLandlord.email.label", @@ -24,7 +24,7 @@ class InviteJointLandlordStepConfig( ) override fun resolvePageContent( - state: InviteJointLandlordsTaskState, + state: SharedInviteJointLandlordState, defaultContent: Map, ): Map { val formModel = defaultContent[FORM_MODEL_ATTR_NAME] as? InviteJointLandlordsFormModel @@ -36,16 +36,16 @@ class InviteJointLandlordStepConfig( return defaultContent + (FORM_MODEL_ATTR_NAME to prepopulatedFormModel) } - override fun chooseTemplate(state: InviteJointLandlordsTaskState): String = "forms/emailForm" + override fun chooseTemplate(state: SharedInviteJointLandlordState): String = "forms/emailForm" - override fun mode(state: InviteJointLandlordsTaskState) = + override fun mode(state: SharedInviteJointLandlordState) = if (state.invitedJointLandlords.isEmpty()) { null } else { Complete.COMPLETE } - override fun beforeAttemptingToReachStep(state: InviteJointLandlordsTaskState): Boolean { + override fun beforeAttemptingToReachStep(state: SharedInviteJointLandlordState): Boolean { val keyToUpdate = urlParameterService.getParameterOrNull() ?: return true val currentMap = state.invitedJointLandlordEmailsMap ?: emptyMap() @@ -54,7 +54,7 @@ class InviteJointLandlordStepConfig( } override fun enrichSubmittedDataBeforeValidation( - state: InviteJointLandlordsTaskState, + state: SharedInviteJointLandlordState, formData: FormData, ): FormData { val emailBeingEdited = getEmailToEditOrNull(state) @@ -64,7 +64,7 @@ class InviteJointLandlordStepConfig( (InviteJointLandlordsFormModel::emailBeingEdited.name to emailBeingEdited) } - override fun afterStepDataIsAdded(state: InviteJointLandlordsTaskState) { + override fun afterStepDataIsAdded(state: SharedInviteJointLandlordState) { val formModel = getFormModelFromState(state) val currentMap = state.invitedJointLandlordEmailsMap?.toMutableMap() ?: mutableMapOf() @@ -84,7 +84,7 @@ class InviteJointLandlordStepConfig( state.inviteAnotherJointLandlordStep.clearFormData() } - private fun getEmailToEditOrNull(state: InviteJointLandlordsTaskState): String? { + private fun getEmailToEditOrNull(state: SharedInviteJointLandlordState): String? { val keyToUpdate = urlParameterService.getParameterOrNull() ?: return null return state.invitedJointLandlordEmailsMap?.get(keyToUpdate) @@ -94,7 +94,7 @@ class InviteJointLandlordStepConfig( @JourneyFrameworkComponent final class InviteJointLandlordStep( stepConfig: InviteJointLandlordStepConfig, -) : RequestableStep(stepConfig) { +) : RequestableStep(stepConfig) { companion object { const val INVITE_FIRST_ROUTE_SEGMENT = "invite-joint-landlord" const val INVITE_ANOTHER_ROUTE_SEGMENT = "invite-another-joint-landlord" diff --git a/src/main/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/steps/RemoveJointLandlordAreYouSureStepConfig.kt b/src/main/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/steps/RemoveJointLandlordAreYouSureStepConfig.kt index c1e9f64e6e..b9dba2d4b0 100644 --- a/src/main/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/steps/RemoveJointLandlordAreYouSureStepConfig.kt +++ b/src/main/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/steps/RemoveJointLandlordAreYouSureStepConfig.kt @@ -4,7 +4,7 @@ import uk.gov.communities.prsdb.webapp.annotations.webAnnotations.JourneyFramewo import uk.gov.communities.prsdb.webapp.journeys.AbstractRequestableStepConfig import uk.gov.communities.prsdb.webapp.journeys.JourneyStep.RequestableStep import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.states.AnyLandlordsInvited -import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.states.InviteJointLandlordsTaskState +import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.states.SharedInviteJointLandlordState import uk.gov.communities.prsdb.webapp.models.requestModels.formModels.RemoveJointLandlordAreYouSureFormModel import uk.gov.communities.prsdb.webapp.models.viewModels.formModels.RadiosViewModel import uk.gov.communities.prsdb.webapp.services.CollectionKeyParameterService @@ -12,10 +12,10 @@ import uk.gov.communities.prsdb.webapp.services.CollectionKeyParameterService @JourneyFrameworkComponent class RemoveJointLandlordAreYouSureStepConfig( private val urlParameterService: CollectionKeyParameterService, -) : AbstractRequestableStepConfig() { +) : AbstractRequestableStepConfig() { override val formModelClass = RemoveJointLandlordAreYouSureFormModel::class - override fun getStepSpecificContent(state: InviteJointLandlordsTaskState) = + override fun getStepSpecificContent(state: SharedInviteJointLandlordState) = mapOf( "fieldSetHeading" to "jointLandlords.removeJointLandlord.fieldSetHeading", "fieldSetHint" to "jointLandlords.removeJointLandlord.fieldSetHint", @@ -23,23 +23,23 @@ class RemoveJointLandlordAreYouSureStepConfig( "optionalFieldSetHeadingParam" to getLandlordEmailToRemove(state), ) - override fun chooseTemplate(state: InviteJointLandlordsTaskState): String = "forms/areYouSureForm" + override fun chooseTemplate(state: SharedInviteJointLandlordState): String = "forms/areYouSureForm" - override fun mode(state: InviteJointLandlordsTaskState) = + override fun mode(state: SharedInviteJointLandlordState) = if (state.invitedJointLandlords.isEmpty()) { AnyLandlordsInvited.NO_LANDLORDS } else { AnyLandlordsInvited.SOME_LANDLORDS } - override fun beforeAttemptingToReachStep(state: InviteJointLandlordsTaskState): Boolean { + override fun beforeAttemptingToReachStep(state: SharedInviteJointLandlordState): Boolean { val keyToRemove = urlParameterService.getParameterOrNull() val currentMap = state.invitedJointLandlordEmailsMap ?: emptyMap() return keyToRemove != null && keyToRemove in currentMap.keys } - override fun afterStepDataIsAdded(state: InviteJointLandlordsTaskState) { + override fun afterStepDataIsAdded(state: SharedInviteJointLandlordState) { if (getFormModelFromStateOrNull(state)?.wantsToProceed == false) { return } @@ -49,7 +49,7 @@ class RemoveJointLandlordAreYouSureStepConfig( state.invitedJointLandlordEmailsMap = currentMap } - private fun getLandlordEmailToRemove(state: InviteJointLandlordsTaskState): String? { + private fun getLandlordEmailToRemove(state: SharedInviteJointLandlordState): String? { val keyToRemove = urlParameterService.getParameterOrNull() return state.invitedJointLandlordEmailsMap?.get(keyToRemove) } @@ -58,7 +58,7 @@ class RemoveJointLandlordAreYouSureStepConfig( @JourneyFrameworkComponent final class RemoveJointLandlordAreYouSureStep( stepConfig: RemoveJointLandlordAreYouSureStepConfig, -) : RequestableStep(stepConfig) { +) : RequestableStep(stepConfig) { companion object { const val ROUTE_SEGMENT = "remove-joint-landlord" } diff --git a/src/main/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/tasks/JointLandlordsTask.kt b/src/main/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/tasks/JointLandlordsTask.kt index 9d6d05afcb..eca1086146 100644 --- a/src/main/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/tasks/JointLandlordsTask.kt +++ b/src/main/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/tasks/JointLandlordsTask.kt @@ -8,13 +8,13 @@ import uk.gov.communities.prsdb.webapp.journeys.Task import uk.gov.communities.prsdb.webapp.journeys.hasOutcome import uk.gov.communities.prsdb.webapp.journeys.isComplete import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.states.AnyLandlordsInvited -import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.states.JointLandlordsState +import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.states.InviteJointLandlordPropertyRegistrationState import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.steps.HasJointLandlordsStep import uk.gov.communities.prsdb.webapp.journeys.shared.YesOrNo @JourneyFrameworkComponent -class JointLandlordsTask : Task() { - override fun makeSubJourney(state: JointLandlordsState) = +class JointLandlordsTask : Task() { + override fun makeSubJourney(state: InviteJointLandlordPropertyRegistrationState) = subJourney(state) { taskStatus { when { diff --git a/src/main/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/tasks/InviteJointLandlordsTask.kt b/src/main/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/tasks/SharedInviteJointLandlordsTask.kt similarity index 93% rename from src/main/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/tasks/InviteJointLandlordsTask.kt rename to src/main/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/tasks/SharedInviteJointLandlordsTask.kt index 829ca5c4ff..81f7acb695 100644 --- a/src/main/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/tasks/InviteJointLandlordsTask.kt +++ b/src/main/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/tasks/SharedInviteJointLandlordsTask.kt @@ -6,14 +6,14 @@ import uk.gov.communities.prsdb.webapp.journeys.Task import uk.gov.communities.prsdb.webapp.journeys.hasOutcome import uk.gov.communities.prsdb.webapp.journeys.isComplete import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.states.AnyLandlordsInvited -import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.states.InviteJointLandlordsTaskState +import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.states.SharedInviteJointLandlordState import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.steps.CheckJointLandlordsStep import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.steps.InviteJointLandlordStep import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.steps.RemoveJointLandlordAreYouSureStep @JourneyFrameworkComponent -class InviteJointLandlordsTask : Task() { - override fun makeSubJourney(state: InviteJointLandlordsTaskState) = +class SharedInviteJointLandlordsTask : Task() { + override fun makeSubJourney(state: SharedInviteJointLandlordState) = subJourney(state) { step(journey.inviteJointLandlordStep) { routeSegment(InviteJointLandlordStep.INVITE_FIRST_ROUTE_SEGMENT) diff --git a/src/main/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/update/inviteJointLandlord/SendJointLandlordInvitationsStepConfig.kt b/src/main/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/update/inviteJointLandlord/CompleteInviteJointLandlordStepConfig.kt similarity index 92% rename from src/main/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/update/inviteJointLandlord/SendJointLandlordInvitationsStepConfig.kt rename to src/main/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/update/inviteJointLandlord/CompleteInviteJointLandlordStepConfig.kt index dc1b8fc48b..0c31b7d2a3 100644 --- a/src/main/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/update/inviteJointLandlord/SendJointLandlordInvitationsStepConfig.kt +++ b/src/main/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/update/inviteJointLandlord/CompleteInviteJointLandlordStepConfig.kt @@ -9,7 +9,7 @@ import uk.gov.communities.prsdb.webapp.services.JointLandlordInvitationService import uk.gov.communities.prsdb.webapp.services.PropertyOwnershipService @JourneyFrameworkComponent -class SendJointLandlordInvitationsStepConfig( +class CompleteInviteJointLandlordStepConfig( private val jointLandlordInvitationService: JointLandlordInvitationService, private val propertyOwnershipService: PropertyOwnershipService, ) : AbstractInternalStepConfig() { @@ -34,6 +34,6 @@ class SendJointLandlordInvitationsStepConfig( } @JourneyFrameworkComponent -class SendJointLandlordInvitationsStep( - stepConfig: SendJointLandlordInvitationsStepConfig, +class CompleteInviteJointLandlordStep( + stepConfig: CompleteInviteJointLandlordStepConfig, ) : JourneyStep.InternalStep(stepConfig) diff --git a/src/main/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/update/inviteJointLandlord/InviteJointLandlordJourneyFactory.kt b/src/main/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/update/inviteJointLandlord/InviteJointLandlordJourneyFactory.kt index b928551060..96224db05b 100644 --- a/src/main/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/update/inviteJointLandlord/InviteJointLandlordJourneyFactory.kt +++ b/src/main/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/update/inviteJointLandlord/InviteJointLandlordJourneyFactory.kt @@ -14,11 +14,11 @@ import uk.gov.communities.prsdb.webapp.journeys.JourneyStateService import uk.gov.communities.prsdb.webapp.journeys.StepLifecycleOrchestrator import uk.gov.communities.prsdb.webapp.journeys.builders.JourneyBuilder.Companion.journey import uk.gov.communities.prsdb.webapp.journeys.isComplete -import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.states.InviteJointLandlordsTaskState +import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.states.SharedInviteJointLandlordState import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.steps.CheckJointLandlordsStep import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.steps.InviteJointLandlordStep import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.steps.RemoveJointLandlordAreYouSureStep -import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.tasks.InviteJointLandlordsTask +import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.tasks.SharedInviteJointLandlordsTask import uk.gov.communities.prsdb.webapp.services.PropertyOwnershipService import java.security.Principal @@ -27,7 +27,7 @@ class InviteJointLandlordJourneyFactory( private val stateFactory: ObjectFactory, private val propertyOwnershipService: PropertyOwnershipService, ) { - fun createJourneySteps(propertyId: Long): Map { + final fun createJourneySteps(propertyId: Long): Map { val state = stateFactory.getObject() if (!state.isStateInitialized) { @@ -60,9 +60,9 @@ class InviteJointLandlordJourneyFactory( step(journey.checkInvitationsStep) { routeSegment(CheckInvitationsStep.ROUTE_SEGMENT) parents { journey.inviteJointLandlordsTask.isComplete() } - nextStep { journey.sendJointLandlordInvitationsStep } + nextStep { journey.completeInviteJointLandlordStep } } - step(journey.sendJointLandlordInvitationsStep) { + step(journey.completeInviteJointLandlordStep) { parents { journey.checkInvitationsStep.isComplete() } nextUrl { confirmationRoute } } @@ -81,9 +81,9 @@ class InviteJointLandlordJourney( override val inviteAnotherJointLandlordStep: InviteJointLandlordStep, override val checkJointLandlordsStep: CheckJointLandlordsStep, override val removeJointLandlordAreYouSureStep: RemoveJointLandlordAreYouSureStep, - override val inviteJointLandlordsTask: InviteJointLandlordsTask, + override val inviteJointLandlordsTask: SharedInviteJointLandlordsTask, override val checkInvitationsStep: CheckInvitationsStep, - override val sendJointLandlordInvitationsStep: SendJointLandlordInvitationsStep, + override val completeInviteJointLandlordStep: CompleteInviteJointLandlordStep, journeyStateService: JourneyStateService, journeyName: String = "inviteJointLandlord", ) : AbstractPropertyOwnershipUpdateJourneyState(journeyStateService, journeyName), @@ -91,16 +91,16 @@ class InviteJointLandlordJourney( private val delegateProvider = JourneyStateDelegateProvider(journeyStateService) override var propertyId: Long by delegateProvider.requiredImmutableDelegate("propertyId") override var lastModifiedDate: String by delegateProvider.requiredImmutableDelegate("lastModifiedDate") - override var invitedJointLandlordEmailsMap: Map? by delegateProvider.nullableDelegate("invitedJointLandlordEmailsMap") + override var invitedJointLandlordEmailsMap: Map? by delegateProvider.nullableDelegate("invitedJointLandlordEmails") override var nextJointLandlordMemberId: Int? by delegateProvider.nullableDelegate("nextJointLandlordMemberId") } interface InviteJointLandlordJourneyState : JourneyState, - InviteJointLandlordsTaskState { - val inviteJointLandlordsTask: InviteJointLandlordsTask + SharedInviteJointLandlordState { + val inviteJointLandlordsTask: SharedInviteJointLandlordsTask val checkInvitationsStep: CheckInvitationsStep - val sendJointLandlordInvitationsStep: SendJointLandlordInvitationsStep + val completeInviteJointLandlordStep: CompleteInviteJointLandlordStep val propertyId: Long val lastModifiedDate: String } diff --git a/src/test/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/steps/CheckJointLandlordsStepConfigTests.kt b/src/test/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/steps/CheckJointLandlordsStepConfigTests.kt index a2d0cfce0f..363522cb58 100644 --- a/src/test/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/steps/CheckJointLandlordsStepConfigTests.kt +++ b/src/test/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/steps/CheckJointLandlordsStepConfigTests.kt @@ -8,7 +8,7 @@ import org.mockito.junit.jupiter.MockitoExtension import org.mockito.kotlin.any import org.mockito.kotlin.whenever import uk.gov.communities.prsdb.webapp.journeys.JourneyIdProvider -import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.states.InviteJointLandlordsTaskState +import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.states.SharedInviteJointLandlordState import uk.gov.communities.prsdb.webapp.models.viewModels.summaryModels.SummaryListRowViewModel import uk.gov.communities.prsdb.webapp.services.CollectionKeyParameterService import uk.gov.communities.prsdb.webapp.testHelpers.mockObjects.AlwaysTrueValidator @@ -16,7 +16,7 @@ import uk.gov.communities.prsdb.webapp.testHelpers.mockObjects.AlwaysTrueValidat @ExtendWith(MockitoExtension::class) class CheckJointLandlordsStepConfigTests { @Mock - lateinit var mockJourneyState: InviteJointLandlordsTaskState + lateinit var mockJourneyState: SharedInviteJointLandlordState @Mock lateinit var urlParameterService: CollectionKeyParameterService diff --git a/src/test/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/steps/InviteJointLandlordStepConfigTests.kt b/src/test/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/steps/InviteJointLandlordStepConfigTests.kt index 12f5c73a4b..743117bd8d 100644 --- a/src/test/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/steps/InviteJointLandlordStepConfigTests.kt +++ b/src/test/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/steps/InviteJointLandlordStepConfigTests.kt @@ -9,14 +9,14 @@ import org.mockito.kotlin.argumentCaptor import org.mockito.kotlin.never import org.mockito.kotlin.verify import org.mockito.kotlin.whenever -import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.states.InviteJointLandlordsTaskState +import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.states.SharedInviteJointLandlordState import uk.gov.communities.prsdb.webapp.services.CollectionKeyParameterService import uk.gov.communities.prsdb.webapp.testHelpers.mockObjects.AlwaysTrueValidator @ExtendWith(MockitoExtension::class) class InviteJointLandlordStepConfigTests { @Mock - lateinit var mockJourneyState: InviteJointLandlordsTaskState + lateinit var mockJourneyState: SharedInviteJointLandlordState @Mock lateinit var urlParameterService: CollectionKeyParameterService From 4f3e927998fe27d6ee68f628851aeedfbedf12bd Mon Sep 17 00:00:00 2001 From: Tom Hanmer Date: Fri, 5 Jun 2026 12:31:13 +0100 Subject: [PATCH 5/9] PDJB-1039: fix tests --- .../webapp/integration/PropertyRegistrationJourneyTests.kt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/test/kotlin/uk/gov/communities/prsdb/webapp/integration/PropertyRegistrationJourneyTests.kt b/src/test/kotlin/uk/gov/communities/prsdb/webapp/integration/PropertyRegistrationJourneyTests.kt index 255909be95..9ad817099e 100644 --- a/src/test/kotlin/uk/gov/communities/prsdb/webapp/integration/PropertyRegistrationJourneyTests.kt +++ b/src/test/kotlin/uk/gov/communities/prsdb/webapp/integration/PropertyRegistrationJourneyTests.kt @@ -139,6 +139,9 @@ class PropertyRegistrationJourneyTests : IntegrationTestWithMutableData("data-lo whenever( absoluteUrlProvider.buildJointLandlordInvitationUri(org.mockito.kotlin.any()), ).thenReturn(URI("http://localhost/invite/test-token")) + whenever( + absoluteUrlProvider.buildPropertyDetailsUri(org.mockito.kotlin.any()), + ).thenReturn(URI("http://localhost/property-details/1")) } @Test From 31f5a992c83a6038b7e4aed186ec66df3914953b Mon Sep 17 00:00:00 2001 From: Tom Hanmer Date: Fri, 5 Jun 2026 14:29:06 +0100 Subject: [PATCH 6/9] PDJB-1039: individual flow fixups --- .../InviteJointLandlordController.kt | 3 ++- .../InviteJointLandlordJourneyFactory.kt | 11 +++++--- .../messages/inviteJointLandlord.yml | 25 ++++++++----------- .../inviteJointLandlordConfirmation.html | 8 ++---- 4 files changed, 23 insertions(+), 24 deletions(-) diff --git a/src/main/kotlin/uk/gov/communities/prsdb/webapp/controllers/InviteJointLandlordController.kt b/src/main/kotlin/uk/gov/communities/prsdb/webapp/controllers/InviteJointLandlordController.kt index db1b8ce282..e88c0b10d1 100644 --- a/src/main/kotlin/uk/gov/communities/prsdb/webapp/controllers/InviteJointLandlordController.kt +++ b/src/main/kotlin/uk/gov/communities/prsdb/webapp/controllers/InviteJointLandlordController.kt @@ -14,6 +14,7 @@ import uk.gov.communities.prsdb.webapp.annotations.webAnnotations.AvailableWhenF import uk.gov.communities.prsdb.webapp.annotations.webAnnotations.PrsdbController import uk.gov.communities.prsdb.webapp.constants.CONFIRMATION_PATH_SEGMENT import uk.gov.communities.prsdb.webapp.constants.JOINT_LANDLORDS +import uk.gov.communities.prsdb.webapp.constants.LANDLORD_DETAILS_FRAGMENT import uk.gov.communities.prsdb.webapp.constants.LANDLORD_PATH_SEGMENT import uk.gov.communities.prsdb.webapp.constants.PROPERTY_DETAILS_SEGMENT import uk.gov.communities.prsdb.webapp.controllers.InviteJointLandlordController.Companion.INVITE_JOINT_LANDLORD_ROUTE @@ -81,7 +82,7 @@ class InviteJointLandlordController( throwErrorIfUserIsNotAuthorized(principal.name, propertyOwnershipId) model.addAttribute( "propertyDetailsUrl", - PropertyDetailsController.getPropertyDetailsPath(propertyOwnershipId), + PropertyDetailsController.getPropertyDetailsPath(propertyOwnershipId) + "#$LANDLORD_DETAILS_FRAGMENT", ) return "inviteJointLandlordConfirmation" } diff --git a/src/main/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/update/inviteJointLandlord/InviteJointLandlordJourneyFactory.kt b/src/main/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/update/inviteJointLandlord/InviteJointLandlordJourneyFactory.kt index 96224db05b..27b36da84e 100644 --- a/src/main/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/update/inviteJointLandlord/InviteJointLandlordJourneyFactory.kt +++ b/src/main/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/update/inviteJointLandlord/InviteJointLandlordJourneyFactory.kt @@ -3,6 +3,7 @@ package uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.update.inv import org.springframework.beans.factory.ObjectFactory import uk.gov.communities.prsdb.webapp.annotations.webAnnotations.JourneyFrameworkComponent import uk.gov.communities.prsdb.webapp.annotations.webAnnotations.PrsdbWebService +import uk.gov.communities.prsdb.webapp.constants.LANDLORD_DETAILS_FRAGMENT import uk.gov.communities.prsdb.webapp.controllers.InviteJointLandlordController import uk.gov.communities.prsdb.webapp.controllers.PropertyDetailsController import uk.gov.communities.prsdb.webapp.exceptions.PrsdbWebException @@ -41,17 +42,21 @@ class InviteJointLandlordJourneyFactory( } val propertyDetailsRoute = PropertyDetailsController.getPropertyDetailsPath(propertyId) + val propertyDetailsLandlordTab = "$propertyDetailsRoute#$LANDLORD_DETAILS_FRAGMENT" val confirmationRoute = InviteJointLandlordController.getInviteJointLandlordRoute(propertyId) + "/confirmation" return journey(state) { - unreachableStepUrl { propertyDetailsRoute } + unreachableStepUrl { propertyDetailsLandlordTab } + configure { + withAdditionalContentProperty { "title" to "inviteJointLandlord.title" } + } task(journey.inviteJointLandlordsTask) { initialStep() - backUrl { propertyDetailsRoute } + backUrl { propertyDetailsLandlordTab } nextDestination { _ -> if (journey.invitedJointLandlords.isEmpty()) { - Destination.ExternalUrl(propertyDetailsRoute) + Destination.ExternalUrl(propertyDetailsLandlordTab) } else { Destination(journey.checkInvitationsStep) } diff --git a/src/main/resources/messages/inviteJointLandlord.yml b/src/main/resources/messages/inviteJointLandlord.yml index 79497623b8..ef3e0e5cff 100644 --- a/src/main/resources/messages/inviteJointLandlord.yml +++ b/src/main/resources/messages/inviteJointLandlord.yml @@ -1,14 +1,11 @@ -inviteJointLandlord: - title: Invite joint landlords - checkInvitations: - heading: Check your invitations - paragraph: We'll send invitations to these email addresses. - summaryName: Invited email addresses - submitButtonText: Confirm and send - confirmation: - banner: - heading: Joint landlord invitations sent - body: - one: The joint landlords you’ve invited have 28 days to join the property. - two: We’ll email you when they accept or reject your invitation. - goBackToPropertyRecord: Go back to the property record +title: Invite joint landlords +checkInvitations: + heading: Check your invitations + paragraph: We'll send invitations to these email addresses. + summaryName: Invited email addresses + submitButtonText: Confirm and send +confirmation: + banner: + heading: Joint landlord invitations sent + body: The joint landlords you've invited have 28 days to join the property. We'll email you when they accept or reject your invitation. + goBackToPropertyRecord: Go back to the property record diff --git a/src/main/resources/templates/inviteJointLandlordConfirmation.html b/src/main/resources/templates/inviteJointLandlordConfirmation.html index d25cad4c72..763a0ab683 100644 --- a/src/main/resources/templates/inviteJointLandlordConfirmation.html +++ b/src/main/resources/templates/inviteJointLandlordConfirmation.html @@ -9,12 +9,8 @@

- inviteJointLandlord.confirmation.body.one -

-

- inviteJointLandlord.confirmation.body.two + th:text="#{inviteJointLandlord.confirmation.body}"> + inviteJointLandlord.confirmation.body

From 2238c7d35d3983862bad0966afc06796e6479c25 Mon Sep 17 00:00:00 2001 From: Tom Hanmer Date: Fri, 5 Jun 2026 15:24:05 +0100 Subject: [PATCH 7/9] PDJB-1039: add tests --- .../InviteJointLandlordJourneyTests.kt | 68 ++++++++++++++ .../PropertyRegistrationJourneyTests.kt | 3 - ...CheckInvitationsPageInviteJointLandlord.kt | 30 +++++++ ...intLandlordsFormPageInviteJointLandlord.kt | 39 ++++++++ ...ointLandlordFormPageInviteJointLandlord.kt | 18 ++++ .../InviteJointLandlordConfirmationPage.kt | 20 +++++ ...ointLandlordFormPageInviteJointLandlord.kt | 18 ++++ .../CheckInvitationsStepConfigTests.kt | 88 +++++++++++++++++++ ...pleteInviteJointLandlordStepConfigTests.kt | 65 ++++++++++++++ 9 files changed, 346 insertions(+), 3 deletions(-) create mode 100644 src/test/kotlin/uk/gov/communities/prsdb/webapp/integration/InviteJointLandlordJourneyTests.kt create mode 100644 src/test/kotlin/uk/gov/communities/prsdb/webapp/integration/pageObjects/pages/inviteJointLandlordJourneyPages/CheckInvitationsPageInviteJointLandlord.kt create mode 100644 src/test/kotlin/uk/gov/communities/prsdb/webapp/integration/pageObjects/pages/inviteJointLandlordJourneyPages/CheckJointLandlordsFormPageInviteJointLandlord.kt create mode 100644 src/test/kotlin/uk/gov/communities/prsdb/webapp/integration/pageObjects/pages/inviteJointLandlordJourneyPages/InviteAnotherJointLandlordFormPageInviteJointLandlord.kt create mode 100644 src/test/kotlin/uk/gov/communities/prsdb/webapp/integration/pageObjects/pages/inviteJointLandlordJourneyPages/InviteJointLandlordConfirmationPage.kt create mode 100644 src/test/kotlin/uk/gov/communities/prsdb/webapp/integration/pageObjects/pages/inviteJointLandlordJourneyPages/InviteJointLandlordFormPageInviteJointLandlord.kt create mode 100644 src/test/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/update/inviteJointLandlord/CheckInvitationsStepConfigTests.kt create mode 100644 src/test/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/update/inviteJointLandlord/CompleteInviteJointLandlordStepConfigTests.kt diff --git a/src/test/kotlin/uk/gov/communities/prsdb/webapp/integration/InviteJointLandlordJourneyTests.kt b/src/test/kotlin/uk/gov/communities/prsdb/webapp/integration/InviteJointLandlordJourneyTests.kt new file mode 100644 index 0000000000..3afae2219f --- /dev/null +++ b/src/test/kotlin/uk/gov/communities/prsdb/webapp/integration/InviteJointLandlordJourneyTests.kt @@ -0,0 +1,68 @@ +package uk.gov.communities.prsdb.webapp.integration + +import com.microsoft.playwright.Page +import com.microsoft.playwright.assertions.PlaywrightAssertions.assertThat +import org.junit.jupiter.api.BeforeEach +import org.junit.jupiter.api.Test +import org.mockito.kotlin.any +import org.mockito.kotlin.whenever +import uk.gov.communities.prsdb.webapp.constants.JOINT_LANDLORDS +import uk.gov.communities.prsdb.webapp.controllers.InviteJointLandlordController +import uk.gov.communities.prsdb.webapp.integration.pageObjects.components.BaseComponent.Companion.assertThat +import uk.gov.communities.prsdb.webapp.integration.pageObjects.pages.basePages.BasePage.Companion.assertPageIs +import uk.gov.communities.prsdb.webapp.integration.pageObjects.pages.inviteJointLandlordJourneyPages.CheckInvitationsPageInviteJointLandlord +import uk.gov.communities.prsdb.webapp.integration.pageObjects.pages.inviteJointLandlordJourneyPages.CheckJointLandlordsFormPageInviteJointLandlord +import uk.gov.communities.prsdb.webapp.integration.pageObjects.pages.inviteJointLandlordJourneyPages.InviteAnotherJointLandlordFormPageInviteJointLandlord +import uk.gov.communities.prsdb.webapp.integration.pageObjects.pages.inviteJointLandlordJourneyPages.InviteJointLandlordConfirmationPage +import uk.gov.communities.prsdb.webapp.integration.pageObjects.pages.inviteJointLandlordJourneyPages.InviteJointLandlordFormPageInviteJointLandlord +import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.steps.InviteJointLandlordStep +import java.net.URI + +class InviteJointLandlordJourneyTests : IntegrationTestWithMutableData("data-local.sql") { + private val propertyOwnershipId = 1L + private val urlArguments = mapOf("propertyOwnershipId" to propertyOwnershipId.toString()) + + @BeforeEach + fun setUp() { + featureFlagManager.enableFeature(JOINT_LANDLORDS) + whenever(absoluteUrlProvider.buildLandlordDashboardUri()).thenReturn(URI("http://localhost:$port/landlord")) + whenever(absoluteUrlProvider.buildJointLandlordInvitationUri(any())) + .thenReturn(URI("http://localhost:$port/invite/test-token")) + } + + @Test + fun `Landlord can complete the standalone invite joint landlord journey`(page: Page) { + val firstStepUrl = + "http://localhost:$port${InviteJointLandlordController.getInviteJointLandlordRoute(propertyOwnershipId)}/" + + InviteJointLandlordStep.INVITE_FIRST_ROUTE_SEGMENT + page.navigate(firstStepUrl) + + val inviteJointLandlordPage = assertPageIs(page, InviteJointLandlordFormPageInviteJointLandlord::class, urlArguments) + assertThat(inviteJointLandlordPage.heading).containsText("Invite a joint landlord to this property") + inviteJointLandlordPage.submitEmail("first@example.com") + + var checkJointLandlordsPage = assertPageIs(page, CheckJointLandlordsFormPageInviteJointLandlord::class, urlArguments) + assertThat(checkJointLandlordsPage.summaryList.firstRow.value).containsText("first@example.com") + checkJointLandlordsPage.form.addAnotherButton.clickAndWait() + + val inviteAnotherJointLandlordPage = + assertPageIs(page, InviteAnotherJointLandlordFormPageInviteJointLandlord::class, urlArguments) + inviteAnotherJointLandlordPage.submitEmail("second@example.com") + + checkJointLandlordsPage = assertPageIs(page, CheckJointLandlordsFormPageInviteJointLandlord::class, urlArguments) + assertThat(checkJointLandlordsPage.summaryList.firstRow.value).containsText("first@example.com") + assertThat(checkJointLandlordsPage.summaryList.getRowByIndex(1).value).containsText("second@example.com") + checkJointLandlordsPage.form.submit() + + val checkInvitationsPage = assertPageIs(page, CheckInvitationsPageInviteJointLandlord::class, urlArguments) + assertThat(checkInvitationsPage.summaryName).containsText("Invited email addresses") + assertThat(checkInvitationsPage.summaryList.invitationsRow.value).containsText("first@example.com") + assertThat(checkInvitationsPage.summaryList.invitationsRow.value).containsText("second@example.com") + checkInvitationsPage.confirm() + + val confirmationPage = assertPageIs(page, InviteJointLandlordConfirmationPage::class, urlArguments) + assertThat(confirmationPage.confirmationBanner.title).containsText("Joint landlord invitations sent") + assertThat(confirmationPage.goBackToPropertyRecordLink).containsText("Go back to the property record") + assertThat(page.locator("main")).containsText("The joint landlords you’ve invited have 28 days to join the property") + } +} diff --git a/src/test/kotlin/uk/gov/communities/prsdb/webapp/integration/PropertyRegistrationJourneyTests.kt b/src/test/kotlin/uk/gov/communities/prsdb/webapp/integration/PropertyRegistrationJourneyTests.kt index 9ad817099e..255909be95 100644 --- a/src/test/kotlin/uk/gov/communities/prsdb/webapp/integration/PropertyRegistrationJourneyTests.kt +++ b/src/test/kotlin/uk/gov/communities/prsdb/webapp/integration/PropertyRegistrationJourneyTests.kt @@ -139,9 +139,6 @@ class PropertyRegistrationJourneyTests : IntegrationTestWithMutableData("data-lo whenever( absoluteUrlProvider.buildJointLandlordInvitationUri(org.mockito.kotlin.any()), ).thenReturn(URI("http://localhost/invite/test-token")) - whenever( - absoluteUrlProvider.buildPropertyDetailsUri(org.mockito.kotlin.any()), - ).thenReturn(URI("http://localhost/property-details/1")) } @Test diff --git a/src/test/kotlin/uk/gov/communities/prsdb/webapp/integration/pageObjects/pages/inviteJointLandlordJourneyPages/CheckInvitationsPageInviteJointLandlord.kt b/src/test/kotlin/uk/gov/communities/prsdb/webapp/integration/pageObjects/pages/inviteJointLandlordJourneyPages/CheckInvitationsPageInviteJointLandlord.kt new file mode 100644 index 0000000000..10572c8783 --- /dev/null +++ b/src/test/kotlin/uk/gov/communities/prsdb/webapp/integration/pageObjects/pages/inviteJointLandlordJourneyPages/CheckInvitationsPageInviteJointLandlord.kt @@ -0,0 +1,30 @@ +package uk.gov.communities.prsdb.webapp.integration.pageObjects.pages.inviteJointLandlordJourneyPages + +import com.microsoft.playwright.Page +import uk.gov.communities.prsdb.webapp.controllers.InviteJointLandlordController +import uk.gov.communities.prsdb.webapp.integration.pageObjects.components.Form +import uk.gov.communities.prsdb.webapp.integration.pageObjects.components.Heading +import uk.gov.communities.prsdb.webapp.integration.pageObjects.components.SummaryList +import uk.gov.communities.prsdb.webapp.integration.pageObjects.pages.basePages.BasePage +import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.update.inviteJointLandlord.CheckInvitationsStep + +class CheckInvitationsPageInviteJointLandlord( + page: Page, + urlArguments: Map, +) : BasePage( + page, + InviteJointLandlordController.getInviteJointLandlordRoute(urlArguments["propertyOwnershipId"]!!.toLong()) + + "/${CheckInvitationsStep.ROUTE_SEGMENT}", + ) { + val form = Form(page) + val summaryName = Heading(page.locator("#summary-name")) + val summaryList = CheckInvitationsSummaryList(page) + + fun confirm() = form.submit() + + class CheckInvitationsSummaryList( + page: Page, + ) : SummaryList(page) { + val invitationsRow = getRow(0) + } +} diff --git a/src/test/kotlin/uk/gov/communities/prsdb/webapp/integration/pageObjects/pages/inviteJointLandlordJourneyPages/CheckJointLandlordsFormPageInviteJointLandlord.kt b/src/test/kotlin/uk/gov/communities/prsdb/webapp/integration/pageObjects/pages/inviteJointLandlordJourneyPages/CheckJointLandlordsFormPageInviteJointLandlord.kt new file mode 100644 index 0000000000..d27bf202b8 --- /dev/null +++ b/src/test/kotlin/uk/gov/communities/prsdb/webapp/integration/pageObjects/pages/inviteJointLandlordJourneyPages/CheckJointLandlordsFormPageInviteJointLandlord.kt @@ -0,0 +1,39 @@ +package uk.gov.communities.prsdb.webapp.integration.pageObjects.pages.inviteJointLandlordJourneyPages + +import com.microsoft.playwright.Page +import uk.gov.communities.prsdb.webapp.controllers.InviteJointLandlordController +import uk.gov.communities.prsdb.webapp.integration.pageObjects.components.FormWithSectionHeader.SectionHeader +import uk.gov.communities.prsdb.webapp.integration.pageObjects.components.Heading +import uk.gov.communities.prsdb.webapp.integration.pageObjects.components.PostForm +import uk.gov.communities.prsdb.webapp.integration.pageObjects.components.SecondaryButton +import uk.gov.communities.prsdb.webapp.integration.pageObjects.components.SummaryList +import uk.gov.communities.prsdb.webapp.integration.pageObjects.pages.basePages.BasePage +import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.steps.CheckJointLandlordsStep + +class CheckJointLandlordsFormPageInviteJointLandlord( + page: Page, + urlArguments: Map, +) : BasePage( + page, + InviteJointLandlordController.getInviteJointLandlordRoute(urlArguments["propertyOwnershipId"]!!.toLong()) + + "/${CheckJointLandlordsStep.ROUTE_SEGMENT}", + ) { + val title = Heading(page.locator("h1")) + val form = CheckJointLandlordsForm(page) + val sectionHeader = SectionHeader(page.locator("main")) + val summaryList = CheckJointLandlordsSummaryList(page) + + class CheckJointLandlordsForm( + page: Page, + ) : PostForm(page) { + val addAnotherButton = SecondaryButton(locator) + } + + class CheckJointLandlordsSummaryList( + page: Page, + ) : SummaryList(page) { + val firstRow = getRow(0) + + fun getRowByIndex(number: Int) = getRow(number) + } +} diff --git a/src/test/kotlin/uk/gov/communities/prsdb/webapp/integration/pageObjects/pages/inviteJointLandlordJourneyPages/InviteAnotherJointLandlordFormPageInviteJointLandlord.kt b/src/test/kotlin/uk/gov/communities/prsdb/webapp/integration/pageObjects/pages/inviteJointLandlordJourneyPages/InviteAnotherJointLandlordFormPageInviteJointLandlord.kt new file mode 100644 index 0000000000..48d678ebbd --- /dev/null +++ b/src/test/kotlin/uk/gov/communities/prsdb/webapp/integration/pageObjects/pages/inviteJointLandlordJourneyPages/InviteAnotherJointLandlordFormPageInviteJointLandlord.kt @@ -0,0 +1,18 @@ +package uk.gov.communities.prsdb.webapp.integration.pageObjects.pages.inviteJointLandlordJourneyPages + +import com.microsoft.playwright.Page +import uk.gov.communities.prsdb.webapp.controllers.InviteJointLandlordController +import uk.gov.communities.prsdb.webapp.integration.pageObjects.components.Heading +import uk.gov.communities.prsdb.webapp.integration.pageObjects.pages.basePages.EmailFormPage +import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.steps.InviteJointLandlordStep + +class InviteAnotherJointLandlordFormPageInviteJointLandlord( + page: Page, + urlArguments: Map, +) : EmailFormPage( + page, + InviteJointLandlordController.getInviteJointLandlordRoute(urlArguments["propertyOwnershipId"]!!.toLong()) + + "/${InviteJointLandlordStep.INVITE_ANOTHER_ROUTE_SEGMENT}", + ) { + val heading = Heading(page.locator("h1")) +} diff --git a/src/test/kotlin/uk/gov/communities/prsdb/webapp/integration/pageObjects/pages/inviteJointLandlordJourneyPages/InviteJointLandlordConfirmationPage.kt b/src/test/kotlin/uk/gov/communities/prsdb/webapp/integration/pageObjects/pages/inviteJointLandlordJourneyPages/InviteJointLandlordConfirmationPage.kt new file mode 100644 index 0000000000..d7d0d0ce31 --- /dev/null +++ b/src/test/kotlin/uk/gov/communities/prsdb/webapp/integration/pageObjects/pages/inviteJointLandlordJourneyPages/InviteJointLandlordConfirmationPage.kt @@ -0,0 +1,20 @@ +package uk.gov.communities.prsdb.webapp.integration.pageObjects.pages.inviteJointLandlordJourneyPages + +import com.microsoft.playwright.Page +import uk.gov.communities.prsdb.webapp.constants.CONFIRMATION_PATH_SEGMENT +import uk.gov.communities.prsdb.webapp.controllers.InviteJointLandlordController +import uk.gov.communities.prsdb.webapp.integration.pageObjects.components.ConfirmationBanner +import uk.gov.communities.prsdb.webapp.integration.pageObjects.components.Link +import uk.gov.communities.prsdb.webapp.integration.pageObjects.pages.basePages.BasePage + +class InviteJointLandlordConfirmationPage( + page: Page, + urlArguments: Map, +) : BasePage( + page, + InviteJointLandlordController.getInviteJointLandlordRoute(urlArguments["propertyOwnershipId"]!!.toLong()) + + "/$CONFIRMATION_PATH_SEGMENT", + ) { + val confirmationBanner = ConfirmationBanner(page) + val goBackToPropertyRecordLink = Link.byText(page, "Go back to the property record") +} diff --git a/src/test/kotlin/uk/gov/communities/prsdb/webapp/integration/pageObjects/pages/inviteJointLandlordJourneyPages/InviteJointLandlordFormPageInviteJointLandlord.kt b/src/test/kotlin/uk/gov/communities/prsdb/webapp/integration/pageObjects/pages/inviteJointLandlordJourneyPages/InviteJointLandlordFormPageInviteJointLandlord.kt new file mode 100644 index 0000000000..a219ea7ba4 --- /dev/null +++ b/src/test/kotlin/uk/gov/communities/prsdb/webapp/integration/pageObjects/pages/inviteJointLandlordJourneyPages/InviteJointLandlordFormPageInviteJointLandlord.kt @@ -0,0 +1,18 @@ +package uk.gov.communities.prsdb.webapp.integration.pageObjects.pages.inviteJointLandlordJourneyPages + +import com.microsoft.playwright.Page +import uk.gov.communities.prsdb.webapp.controllers.InviteJointLandlordController +import uk.gov.communities.prsdb.webapp.integration.pageObjects.components.Heading +import uk.gov.communities.prsdb.webapp.integration.pageObjects.pages.basePages.EmailFormPage +import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.steps.InviteJointLandlordStep + +class InviteJointLandlordFormPageInviteJointLandlord( + page: Page, + urlArguments: Map, +) : EmailFormPage( + page, + InviteJointLandlordController.getInviteJointLandlordRoute(urlArguments["propertyOwnershipId"]!!.toLong()) + + "/${InviteJointLandlordStep.INVITE_FIRST_ROUTE_SEGMENT}", + ) { + val heading = Heading(page.locator("h1")) +} diff --git a/src/test/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/update/inviteJointLandlord/CheckInvitationsStepConfigTests.kt b/src/test/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/update/inviteJointLandlord/CheckInvitationsStepConfigTests.kt new file mode 100644 index 0000000000..f3e934d468 --- /dev/null +++ b/src/test/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/update/inviteJointLandlord/CheckInvitationsStepConfigTests.kt @@ -0,0 +1,88 @@ +package uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.update.inviteJointLandlord + +import org.junit.jupiter.api.Assertions.assertEquals +import org.junit.jupiter.api.Assertions.assertNull +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith +import org.mockito.Mock +import org.mockito.junit.jupiter.MockitoExtension +import org.mockito.kotlin.whenever +import uk.gov.communities.prsdb.webapp.journeys.JourneyIdProvider +import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.steps.CheckJointLandlordsStep +import uk.gov.communities.prsdb.webapp.journeys.shared.Complete +import uk.gov.communities.prsdb.webapp.models.viewModels.summaryModels.SummaryListRowViewModel +import uk.gov.communities.prsdb.webapp.testHelpers.mockObjects.AlwaysTrueValidator + +@ExtendWith(MockitoExtension::class) +class CheckInvitationsStepConfigTests { + @Mock + private lateinit var mockJourneyState: InviteJointLandlordJourneyState + + @Mock + private lateinit var mockCheckJointLandlordsStep: CheckJointLandlordsStep + + private val journeyId = "journey-123" + + @Test + fun `getStepSpecificContent returns summary rows with invited emails`() { + val stepConfig = setupStepConfig() + whenever(mockJourneyState.invitedJointLandlords).thenReturn(listOf("first@example.com", "second@example.com")) + + val content = stepConfig.getStepSpecificContent(mockJourneyState) + val rows = content["summaryListData"] as List + + assertEquals(1, rows.size) + assertEquals( + listOf("first@example.com", "second@example.com"), + rows.first().fieldValue, + ) + assertEquals("forms.links.change", rows.first().actions.single().text) + assertEquals( + "${CheckJointLandlordsStep.ROUTE_SEGMENT}?${JourneyIdProvider.PARAMETER_NAME}=$journeyId", + rows.first().actions.single().url, + ) + } + + @Test + fun `getStepSpecificContent returns correct summary name and submit button text`() { + val stepConfig = setupStepConfig() + + val content = stepConfig.getStepSpecificContent(mockJourneyState) + + assertEquals("inviteJointLandlord.checkInvitations.summaryName", content["summaryName"]) + assertEquals("inviteJointLandlord.checkInvitations.submitButtonText", content["submitButtonText"]) + } + + @Test + fun `mode returns null when form model is not saved`() { + val stepConfig = CheckInvitationsStepConfig() + stepConfig.routeSegment = CheckInvitationsStep.ROUTE_SEGMENT + stepConfig.validator = AlwaysTrueValidator() + whenever(mockJourneyState.getStepData(CheckInvitationsStep.ROUTE_SEGMENT)).thenReturn(null) + + assertNull(stepConfig.mode(mockJourneyState)) + } + + @Test + fun `mode returns COMPLETE when form model is saved`() { + val stepConfig = CheckInvitationsStepConfig() + stepConfig.routeSegment = CheckInvitationsStep.ROUTE_SEGMENT + stepConfig.validator = AlwaysTrueValidator() + whenever(mockJourneyState.getStepData(CheckInvitationsStep.ROUTE_SEGMENT)).thenReturn(emptyMap()) + + assertEquals(Complete.COMPLETE, stepConfig.mode(mockJourneyState)) + } + + private fun setupStepConfig(): CheckInvitationsStepConfig { + val stepConfig = CheckInvitationsStepConfig() + stepConfig.routeSegment = CheckInvitationsStep.ROUTE_SEGMENT + stepConfig.validator = AlwaysTrueValidator() + + whenever(mockJourneyState.checkJointLandlordsStep).thenReturn(mockCheckJointLandlordsStep) + whenever(mockCheckJointLandlordsStep.routeSegment).thenReturn(CheckJointLandlordsStep.ROUTE_SEGMENT) + whenever(mockCheckJointLandlordsStep.currentJourneyId).thenReturn(journeyId) + whenever(mockCheckJointLandlordsStep.isStepReachable).thenReturn(true) + + return stepConfig + } +} diff --git a/src/test/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/update/inviteJointLandlord/CompleteInviteJointLandlordStepConfigTests.kt b/src/test/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/update/inviteJointLandlord/CompleteInviteJointLandlordStepConfigTests.kt new file mode 100644 index 0000000000..0bff4faca4 --- /dev/null +++ b/src/test/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/update/inviteJointLandlord/CompleteInviteJointLandlordStepConfigTests.kt @@ -0,0 +1,65 @@ +package uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.update.inviteJointLandlord + +import org.junit.jupiter.api.Assertions.assertEquals +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith +import org.mockito.Mock +import org.mockito.junit.jupiter.MockitoExtension +import org.mockito.kotlin.eq +import org.mockito.kotlin.verify +import org.mockito.kotlin.whenever +import uk.gov.communities.prsdb.webapp.journeys.Destination +import uk.gov.communities.prsdb.webapp.journeys.shared.Complete +import uk.gov.communities.prsdb.webapp.services.JointLandlordInvitationService +import uk.gov.communities.prsdb.webapp.services.PropertyOwnershipService +import uk.gov.communities.prsdb.webapp.testHelpers.mockObjects.MockLandlordData + +@ExtendWith(MockitoExtension::class) +class CompleteInviteJointLandlordStepConfigTests { + @Mock + private lateinit var mockJointLandlordInvitationService: JointLandlordInvitationService + + @Mock + private lateinit var mockPropertyOwnershipService: PropertyOwnershipService + + @Mock + private lateinit var mockState: InviteJointLandlordJourneyState + + private val propertyId = 123L + private val invitedEmails = listOf("first@example.com", "second@example.com") + + @Test + fun `afterStepIsReached calls sendInvitationEmails with correct parameters`() { + val propertyOwnership = MockLandlordData.createPropertyOwnership(id = propertyId) + val stepConfig = CompleteInviteJointLandlordStepConfig(mockJointLandlordInvitationService, mockPropertyOwnershipService) + whenever(mockState.propertyId).thenReturn(propertyId) + whenever(mockState.invitedJointLandlords).thenReturn(invitedEmails) + whenever(mockPropertyOwnershipService.getPropertyOwnership(propertyId)).thenReturn(propertyOwnership) + + stepConfig.afterStepIsReached(mockState) + + verify(mockJointLandlordInvitationService).sendInvitationEmails( + jointLandlordEmails = eq(invitedEmails), + propertyOwnership = eq(propertyOwnership), + invitingLandlord = eq(propertyOwnership.primaryLandlord), + ) + } + + @Test + fun `resolveNextDestination deletes the journey and returns the default destination`() { + val stepConfig = CompleteInviteJointLandlordStepConfig(mockJointLandlordInvitationService, mockPropertyOwnershipService) + val defaultDestination = Destination.ExternalUrl("/redirect") + + val result = stepConfig.resolveNextDestination(mockState, defaultDestination) + + verify(mockState).deleteJourney() + assertEquals(defaultDestination, result) + } + + @Test + fun `mode always returns COMPLETE`() { + val stepConfig = CompleteInviteJointLandlordStepConfig(mockJointLandlordInvitationService, mockPropertyOwnershipService) + + assertEquals(Complete.COMPLETE, stepConfig.mode(mockState)) + } +} From 4176516bdc9acabc2d74c2396a63bbc2887b5cce Mon Sep 17 00:00:00 2001 From: Tom Hanmer Date: Fri, 5 Jun 2026 16:18:33 +0100 Subject: [PATCH 8/9] PDJB-1039: fix tests --- src/main/resources/messages/inviteJointLandlord.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/resources/messages/inviteJointLandlord.yml b/src/main/resources/messages/inviteJointLandlord.yml index ef3e0e5cff..6451eb0a69 100644 --- a/src/main/resources/messages/inviteJointLandlord.yml +++ b/src/main/resources/messages/inviteJointLandlord.yml @@ -1,11 +1,11 @@ title: Invite joint landlords checkInvitations: heading: Check your invitations - paragraph: We'll send invitations to these email addresses. + paragraph: We’ll send invitations to these email addresses. summaryName: Invited email addresses submitButtonText: Confirm and send confirmation: banner: heading: Joint landlord invitations sent - body: The joint landlords you've invited have 28 days to join the property. We'll email you when they accept or reject your invitation. + body: The joint landlords you’ve invited have 28 days to join the property. We’ll email you when they accept or reject your invitation. goBackToPropertyRecord: Go back to the property record From 6b795eee78f3e56483e5de3069212036ca35b967 Mon Sep 17 00:00:00 2001 From: Tom Hanmer Date: Fri, 5 Jun 2026 17:16:35 +0100 Subject: [PATCH 9/9] PDJB-1039: move files to shared, and fix uneccesary code --- .../PropertyRegistrationJourneyFactory.kt | 8 ++++---- ...teJointLandlordPropertyRegistrationState.kt | 3 ++- .../InviteJointLandlordJourneyFactory.kt | 18 +++++++----------- .../CheckJointLandlordsStepConfig.kt | 4 ++-- .../InviteJointLandlordStepConfig.kt | 4 ++-- .../RemoveJointLandlordAreYouSureStepConfig.kt | 4 ++-- .../SharedInviteJointLandlordsTask.kt | 7 ++----- .../states/SharedInviteJointLandlordState.kt | 8 ++++---- .../resources/messages/inviteJointLandlord.yml | 2 -- .../InviteJointLandlordControllerTests.kt | 2 +- .../InviteJointLandlordJourneyTests.kt | 2 +- .../integration/pageObjects/Navigator.kt | 2 +- ...ointLandlordsFormPageInviteJointLandlord.kt | 2 +- ...JointLandlordFormPageInviteJointLandlord.kt | 2 +- ...JointLandlordFormPageInviteJointLandlord.kt | 2 +- ...intLandlordsFormPagePropertyRegistration.kt | 2 +- ...ointLandlordFormPagePropertyRegistration.kt | 2 +- ...rdAreYouSureFormPagePropertyRegistration.kt | 2 +- .../CheckInvitationsStepConfigTests.kt | 2 +- .../CheckJointLandlordsStepConfigTests.kt | 4 ++-- .../InviteJointLandlordStepConfigTests.kt | 4 ++-- .../builders/JointLandlordsStateBuilder.kt | 2 +- 22 files changed, 40 insertions(+), 48 deletions(-) rename src/main/kotlin/uk/gov/communities/prsdb/webapp/journeys/{propertyRegistration/steps => shared/inviteJointLandlord}/CheckJointLandlordsStepConfig.kt (95%) rename src/main/kotlin/uk/gov/communities/prsdb/webapp/journeys/{propertyRegistration/steps => shared/inviteJointLandlord}/InviteJointLandlordStepConfig.kt (96%) rename src/main/kotlin/uk/gov/communities/prsdb/webapp/journeys/{propertyRegistration/steps => shared/inviteJointLandlord}/RemoveJointLandlordAreYouSureStepConfig.kt (94%) rename src/main/kotlin/uk/gov/communities/prsdb/webapp/journeys/{propertyRegistration/tasks => shared/inviteJointLandlord}/SharedInviteJointLandlordsTask.kt (82%) rename src/main/kotlin/uk/gov/communities/prsdb/webapp/journeys/{propertyRegistration => shared}/states/SharedInviteJointLandlordState.kt (60%) rename src/test/kotlin/uk/gov/communities/prsdb/webapp/journeys/{propertyRegistration/steps => shared/inviteJointLandlord}/CheckJointLandlordsStepConfigTests.kt (96%) rename src/test/kotlin/uk/gov/communities/prsdb/webapp/journeys/{propertyRegistration/steps => shared/inviteJointLandlord}/InviteJointLandlordStepConfigTests.kt (95%) diff --git a/src/main/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/PropertyRegistrationJourneyFactory.kt b/src/main/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/PropertyRegistrationJourneyFactory.kt index 9b5079a91d..920d1fac84 100644 --- a/src/main/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/PropertyRegistrationJourneyFactory.kt +++ b/src/main/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/PropertyRegistrationJourneyFactory.kt @@ -33,7 +33,6 @@ import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.steps.Check import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.steps.CheckEpcAnswersStep import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.steps.CheckGasCertUploadsStep import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.steps.CheckGasSafetyAnswersStep -import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.steps.CheckJointLandlordsStep import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.steps.ConfirmEpcDetailsRetrievedByCertificateNumberStep import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.steps.ConfirmEpcRetrievedByUprnStep import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.steps.ConfirmMissingComplianceCheckResult @@ -69,7 +68,6 @@ import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.steps.HasMi import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.steps.HmoAdditionalLicenceStep import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.steps.HmoMandatoryLicenceStep import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.steps.HouseholdStep -import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.steps.InviteJointLandlordStep import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.steps.IsEpcRequiredStep import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.steps.LicensingTypeStep import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.steps.LocalCouncilStep @@ -86,7 +84,6 @@ import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.steps.Provi import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.steps.ProvideGasCertLaterStep import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.steps.RemoveElectricalCertUploadStep import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.steps.RemoveGasCertUploadStep -import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.steps.RemoveJointLandlordAreYouSureStep import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.steps.RentAmountStep import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.steps.RentFrequencyStep import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.steps.RentIncludesBillsStep @@ -109,7 +106,10 @@ import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.tasks.Occup import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.tasks.PropertyRegistrationAddressTask import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.tasks.RentFrequencyAndAmountTask import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.tasks.RentIncludesBillsTask -import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.tasks.SharedInviteJointLandlordsTask +import uk.gov.communities.prsdb.webapp.journeys.shared.inviteJointLandlord.CheckJointLandlordsStep +import uk.gov.communities.prsdb.webapp.journeys.shared.inviteJointLandlord.InviteJointLandlordStep +import uk.gov.communities.prsdb.webapp.journeys.shared.inviteJointLandlord.RemoveJointLandlordAreYouSureStep +import uk.gov.communities.prsdb.webapp.journeys.shared.inviteJointLandlord.SharedInviteJointLandlordsTask import uk.gov.communities.prsdb.webapp.journeys.shared.states.CheckYourAnswersJourneyState import uk.gov.communities.prsdb.webapp.journeys.shared.states.CheckYourAnswersJourneyState.Companion.checkAnswerStep import uk.gov.communities.prsdb.webapp.journeys.shared.states.CheckYourAnswersJourneyState.Companion.checkAnswerTask diff --git a/src/main/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/states/InviteJointLandlordPropertyRegistrationState.kt b/src/main/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/states/InviteJointLandlordPropertyRegistrationState.kt index 34e605f44d..1816f35a8a 100644 --- a/src/main/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/states/InviteJointLandlordPropertyRegistrationState.kt +++ b/src/main/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/states/InviteJointLandlordPropertyRegistrationState.kt @@ -2,7 +2,8 @@ package uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.states import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.steps.HasAnyJointLandlordsInvitedStep import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.steps.HasJointLandlordsStep -import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.tasks.SharedInviteJointLandlordsTask +import uk.gov.communities.prsdb.webapp.journeys.shared.inviteJointLandlord.SharedInviteJointLandlordsTask +import uk.gov.communities.prsdb.webapp.journeys.shared.states.SharedInviteJointLandlordState interface InviteJointLandlordPropertyRegistrationState : SharedInviteJointLandlordState { val hasAnyJointLandlordsInvitedStep: HasAnyJointLandlordsInvitedStep diff --git a/src/main/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/update/inviteJointLandlord/InviteJointLandlordJourneyFactory.kt b/src/main/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/update/inviteJointLandlord/InviteJointLandlordJourneyFactory.kt index 27b36da84e..d06288a533 100644 --- a/src/main/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/update/inviteJointLandlord/InviteJointLandlordJourneyFactory.kt +++ b/src/main/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/update/inviteJointLandlord/InviteJointLandlordJourneyFactory.kt @@ -3,6 +3,7 @@ package uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.update.inv import org.springframework.beans.factory.ObjectFactory import uk.gov.communities.prsdb.webapp.annotations.webAnnotations.JourneyFrameworkComponent import uk.gov.communities.prsdb.webapp.annotations.webAnnotations.PrsdbWebService +import uk.gov.communities.prsdb.webapp.constants.CONFIRMATION_PATH_SEGMENT import uk.gov.communities.prsdb.webapp.constants.LANDLORD_DETAILS_FRAGMENT import uk.gov.communities.prsdb.webapp.controllers.InviteJointLandlordController import uk.gov.communities.prsdb.webapp.controllers.PropertyDetailsController @@ -15,25 +16,22 @@ import uk.gov.communities.prsdb.webapp.journeys.JourneyStateService import uk.gov.communities.prsdb.webapp.journeys.StepLifecycleOrchestrator import uk.gov.communities.prsdb.webapp.journeys.builders.JourneyBuilder.Companion.journey import uk.gov.communities.prsdb.webapp.journeys.isComplete -import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.states.SharedInviteJointLandlordState -import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.steps.CheckJointLandlordsStep -import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.steps.InviteJointLandlordStep -import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.steps.RemoveJointLandlordAreYouSureStep -import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.tasks.SharedInviteJointLandlordsTask -import uk.gov.communities.prsdb.webapp.services.PropertyOwnershipService +import uk.gov.communities.prsdb.webapp.journeys.shared.inviteJointLandlord.CheckJointLandlordsStep +import uk.gov.communities.prsdb.webapp.journeys.shared.inviteJointLandlord.InviteJointLandlordStep +import uk.gov.communities.prsdb.webapp.journeys.shared.inviteJointLandlord.RemoveJointLandlordAreYouSureStep +import uk.gov.communities.prsdb.webapp.journeys.shared.inviteJointLandlord.SharedInviteJointLandlordsTask +import uk.gov.communities.prsdb.webapp.journeys.shared.states.SharedInviteJointLandlordState import java.security.Principal @PrsdbWebService class InviteJointLandlordJourneyFactory( private val stateFactory: ObjectFactory, - private val propertyOwnershipService: PropertyOwnershipService, ) { final fun createJourneySteps(propertyId: Long): Map { val state = stateFactory.getObject() if (!state.isStateInitialized) { state.propertyId = propertyId - state.lastModifiedDate = propertyOwnershipService.getPropertyOwnership(propertyId).getMostRecentlyUpdated().toString() state.isStateInitialized = true } @@ -44,7 +42,7 @@ class InviteJointLandlordJourneyFactory( val propertyDetailsRoute = PropertyDetailsController.getPropertyDetailsPath(propertyId) val propertyDetailsLandlordTab = "$propertyDetailsRoute#$LANDLORD_DETAILS_FRAGMENT" val confirmationRoute = - InviteJointLandlordController.getInviteJointLandlordRoute(propertyId) + "/confirmation" + InviteJointLandlordController.getInviteJointLandlordRoute(propertyId) + "/$CONFIRMATION_PATH_SEGMENT" return journey(state) { unreachableStepUrl { propertyDetailsLandlordTab } @@ -95,7 +93,6 @@ class InviteJointLandlordJourney( InviteJointLandlordJourneyState { private val delegateProvider = JourneyStateDelegateProvider(journeyStateService) override var propertyId: Long by delegateProvider.requiredImmutableDelegate("propertyId") - override var lastModifiedDate: String by delegateProvider.requiredImmutableDelegate("lastModifiedDate") override var invitedJointLandlordEmailsMap: Map? by delegateProvider.nullableDelegate("invitedJointLandlordEmails") override var nextJointLandlordMemberId: Int? by delegateProvider.nullableDelegate("nextJointLandlordMemberId") } @@ -107,5 +104,4 @@ interface InviteJointLandlordJourneyState : val checkInvitationsStep: CheckInvitationsStep val completeInviteJointLandlordStep: CompleteInviteJointLandlordStep val propertyId: Long - val lastModifiedDate: String } diff --git a/src/main/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/steps/CheckJointLandlordsStepConfig.kt b/src/main/kotlin/uk/gov/communities/prsdb/webapp/journeys/shared/inviteJointLandlord/CheckJointLandlordsStepConfig.kt similarity index 95% rename from src/main/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/steps/CheckJointLandlordsStepConfig.kt rename to src/main/kotlin/uk/gov/communities/prsdb/webapp/journeys/shared/inviteJointLandlord/CheckJointLandlordsStepConfig.kt index 9579b1f9fa..f20e9e62c0 100644 --- a/src/main/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/steps/CheckJointLandlordsStepConfig.kt +++ b/src/main/kotlin/uk/gov/communities/prsdb/webapp/journeys/shared/inviteJointLandlord/CheckJointLandlordsStepConfig.kt @@ -1,11 +1,11 @@ -package uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.steps +package uk.gov.communities.prsdb.webapp.journeys.shared.inviteJointLandlord import uk.gov.communities.prsdb.webapp.annotations.webAnnotations.JourneyFrameworkComponent import uk.gov.communities.prsdb.webapp.journeys.AbstractRequestableStepConfig import uk.gov.communities.prsdb.webapp.journeys.Destination import uk.gov.communities.prsdb.webapp.journeys.JourneyStep.RequestableStep -import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.states.SharedInviteJointLandlordState import uk.gov.communities.prsdb.webapp.journeys.shared.Complete +import uk.gov.communities.prsdb.webapp.journeys.shared.states.SharedInviteJointLandlordState import uk.gov.communities.prsdb.webapp.models.requestModels.formModels.NoInputFormModel import uk.gov.communities.prsdb.webapp.models.viewModels.summaryModels.SummaryListRowActionsInputWithDestination import uk.gov.communities.prsdb.webapp.models.viewModels.summaryModels.SummaryListRowViewModel diff --git a/src/main/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/steps/InviteJointLandlordStepConfig.kt b/src/main/kotlin/uk/gov/communities/prsdb/webapp/journeys/shared/inviteJointLandlord/InviteJointLandlordStepConfig.kt similarity index 96% rename from src/main/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/steps/InviteJointLandlordStepConfig.kt rename to src/main/kotlin/uk/gov/communities/prsdb/webapp/journeys/shared/inviteJointLandlord/InviteJointLandlordStepConfig.kt index 8455ee7e80..7636882068 100644 --- a/src/main/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/steps/InviteJointLandlordStepConfig.kt +++ b/src/main/kotlin/uk/gov/communities/prsdb/webapp/journeys/shared/inviteJointLandlord/InviteJointLandlordStepConfig.kt @@ -1,12 +1,12 @@ -package uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.steps +package uk.gov.communities.prsdb.webapp.journeys.shared.inviteJointLandlord import uk.gov.communities.prsdb.webapp.annotations.webAnnotations.JourneyFrameworkComponent import uk.gov.communities.prsdb.webapp.constants.FORM_MODEL_ATTR_NAME import uk.gov.communities.prsdb.webapp.journeys.AbstractRequestableStepConfig import uk.gov.communities.prsdb.webapp.journeys.FormData import uk.gov.communities.prsdb.webapp.journeys.JourneyStep.RequestableStep -import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.states.SharedInviteJointLandlordState import uk.gov.communities.prsdb.webapp.journeys.shared.Complete +import uk.gov.communities.prsdb.webapp.journeys.shared.states.SharedInviteJointLandlordState import uk.gov.communities.prsdb.webapp.models.requestModels.formModels.InviteJointLandlordsFormModel import uk.gov.communities.prsdb.webapp.services.CollectionKeyParameterService diff --git a/src/main/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/steps/RemoveJointLandlordAreYouSureStepConfig.kt b/src/main/kotlin/uk/gov/communities/prsdb/webapp/journeys/shared/inviteJointLandlord/RemoveJointLandlordAreYouSureStepConfig.kt similarity index 94% rename from src/main/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/steps/RemoveJointLandlordAreYouSureStepConfig.kt rename to src/main/kotlin/uk/gov/communities/prsdb/webapp/journeys/shared/inviteJointLandlord/RemoveJointLandlordAreYouSureStepConfig.kt index b9dba2d4b0..3972fd4159 100644 --- a/src/main/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/steps/RemoveJointLandlordAreYouSureStepConfig.kt +++ b/src/main/kotlin/uk/gov/communities/prsdb/webapp/journeys/shared/inviteJointLandlord/RemoveJointLandlordAreYouSureStepConfig.kt @@ -1,10 +1,10 @@ -package uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.steps +package uk.gov.communities.prsdb.webapp.journeys.shared.inviteJointLandlord import uk.gov.communities.prsdb.webapp.annotations.webAnnotations.JourneyFrameworkComponent import uk.gov.communities.prsdb.webapp.journeys.AbstractRequestableStepConfig import uk.gov.communities.prsdb.webapp.journeys.JourneyStep.RequestableStep import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.states.AnyLandlordsInvited -import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.states.SharedInviteJointLandlordState +import uk.gov.communities.prsdb.webapp.journeys.shared.states.SharedInviteJointLandlordState import uk.gov.communities.prsdb.webapp.models.requestModels.formModels.RemoveJointLandlordAreYouSureFormModel import uk.gov.communities.prsdb.webapp.models.viewModels.formModels.RadiosViewModel import uk.gov.communities.prsdb.webapp.services.CollectionKeyParameterService diff --git a/src/main/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/tasks/SharedInviteJointLandlordsTask.kt b/src/main/kotlin/uk/gov/communities/prsdb/webapp/journeys/shared/inviteJointLandlord/SharedInviteJointLandlordsTask.kt similarity index 82% rename from src/main/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/tasks/SharedInviteJointLandlordsTask.kt rename to src/main/kotlin/uk/gov/communities/prsdb/webapp/journeys/shared/inviteJointLandlord/SharedInviteJointLandlordsTask.kt index 81f7acb695..c1578b55fd 100644 --- a/src/main/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/tasks/SharedInviteJointLandlordsTask.kt +++ b/src/main/kotlin/uk/gov/communities/prsdb/webapp/journeys/shared/inviteJointLandlord/SharedInviteJointLandlordsTask.kt @@ -1,4 +1,4 @@ -package uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.tasks +package uk.gov.communities.prsdb.webapp.journeys.shared.inviteJointLandlord import uk.gov.communities.prsdb.webapp.annotations.webAnnotations.JourneyFrameworkComponent import uk.gov.communities.prsdb.webapp.journeys.OrParents @@ -6,10 +6,7 @@ import uk.gov.communities.prsdb.webapp.journeys.Task import uk.gov.communities.prsdb.webapp.journeys.hasOutcome import uk.gov.communities.prsdb.webapp.journeys.isComplete import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.states.AnyLandlordsInvited -import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.states.SharedInviteJointLandlordState -import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.steps.CheckJointLandlordsStep -import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.steps.InviteJointLandlordStep -import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.steps.RemoveJointLandlordAreYouSureStep +import uk.gov.communities.prsdb.webapp.journeys.shared.states.SharedInviteJointLandlordState @JourneyFrameworkComponent class SharedInviteJointLandlordsTask : Task() { diff --git a/src/main/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/states/SharedInviteJointLandlordState.kt b/src/main/kotlin/uk/gov/communities/prsdb/webapp/journeys/shared/states/SharedInviteJointLandlordState.kt similarity index 60% rename from src/main/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/states/SharedInviteJointLandlordState.kt rename to src/main/kotlin/uk/gov/communities/prsdb/webapp/journeys/shared/states/SharedInviteJointLandlordState.kt index 603044a56e..4d88d05308 100644 --- a/src/main/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/states/SharedInviteJointLandlordState.kt +++ b/src/main/kotlin/uk/gov/communities/prsdb/webapp/journeys/shared/states/SharedInviteJointLandlordState.kt @@ -1,9 +1,9 @@ -package uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.states +package uk.gov.communities.prsdb.webapp.journeys.shared.states import uk.gov.communities.prsdb.webapp.journeys.JourneyState -import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.steps.CheckJointLandlordsStep -import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.steps.InviteJointLandlordStep -import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.steps.RemoveJointLandlordAreYouSureStep +import uk.gov.communities.prsdb.webapp.journeys.shared.inviteJointLandlord.CheckJointLandlordsStep +import uk.gov.communities.prsdb.webapp.journeys.shared.inviteJointLandlord.InviteJointLandlordStep +import uk.gov.communities.prsdb.webapp.journeys.shared.inviteJointLandlord.RemoveJointLandlordAreYouSureStep interface SharedInviteJointLandlordState : JourneyState { val inviteJointLandlordStep: InviteJointLandlordStep diff --git a/src/main/resources/messages/inviteJointLandlord.yml b/src/main/resources/messages/inviteJointLandlord.yml index 6451eb0a69..bcbd82a9d2 100644 --- a/src/main/resources/messages/inviteJointLandlord.yml +++ b/src/main/resources/messages/inviteJointLandlord.yml @@ -1,7 +1,5 @@ title: Invite joint landlords checkInvitations: - heading: Check your invitations - paragraph: We’ll send invitations to these email addresses. summaryName: Invited email addresses submitButtonText: Confirm and send confirmation: diff --git a/src/test/kotlin/uk/gov/communities/prsdb/webapp/controllers/InviteJointLandlordControllerTests.kt b/src/test/kotlin/uk/gov/communities/prsdb/webapp/controllers/InviteJointLandlordControllerTests.kt index 7fe9fd67ec..046331f0f2 100644 --- a/src/test/kotlin/uk/gov/communities/prsdb/webapp/controllers/InviteJointLandlordControllerTests.kt +++ b/src/test/kotlin/uk/gov/communities/prsdb/webapp/controllers/InviteJointLandlordControllerTests.kt @@ -9,8 +9,8 @@ import org.springframework.test.context.bean.override.mockito.MockitoBean import org.springframework.test.web.servlet.get import org.springframework.web.context.WebApplicationContext import uk.gov.communities.prsdb.webapp.journeys.StepLifecycleOrchestrator -import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.steps.InviteJointLandlordStep import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.update.inviteJointLandlord.InviteJointLandlordJourneyFactory +import uk.gov.communities.prsdb.webapp.journeys.shared.inviteJointLandlord.InviteJointLandlordStep import uk.gov.communities.prsdb.webapp.services.PropertyOwnershipService @WebMvcTest(InviteJointLandlordController::class) diff --git a/src/test/kotlin/uk/gov/communities/prsdb/webapp/integration/InviteJointLandlordJourneyTests.kt b/src/test/kotlin/uk/gov/communities/prsdb/webapp/integration/InviteJointLandlordJourneyTests.kt index 3afae2219f..c8350594b8 100644 --- a/src/test/kotlin/uk/gov/communities/prsdb/webapp/integration/InviteJointLandlordJourneyTests.kt +++ b/src/test/kotlin/uk/gov/communities/prsdb/webapp/integration/InviteJointLandlordJourneyTests.kt @@ -15,7 +15,7 @@ import uk.gov.communities.prsdb.webapp.integration.pageObjects.pages.inviteJoint import uk.gov.communities.prsdb.webapp.integration.pageObjects.pages.inviteJointLandlordJourneyPages.InviteAnotherJointLandlordFormPageInviteJointLandlord import uk.gov.communities.prsdb.webapp.integration.pageObjects.pages.inviteJointLandlordJourneyPages.InviteJointLandlordConfirmationPage import uk.gov.communities.prsdb.webapp.integration.pageObjects.pages.inviteJointLandlordJourneyPages.InviteJointLandlordFormPageInviteJointLandlord -import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.steps.InviteJointLandlordStep +import uk.gov.communities.prsdb.webapp.journeys.shared.inviteJointLandlord.InviteJointLandlordStep import java.net.URI class InviteJointLandlordJourneyTests : IntegrationTestWithMutableData("data-local.sql") { diff --git a/src/test/kotlin/uk/gov/communities/prsdb/webapp/integration/pageObjects/Navigator.kt b/src/test/kotlin/uk/gov/communities/prsdb/webapp/integration/pageObjects/Navigator.kt index cdd6991954..d2f5c39e6f 100644 --- a/src/test/kotlin/uk/gov/communities/prsdb/webapp/integration/pageObjects/Navigator.kt +++ b/src/test/kotlin/uk/gov/communities/prsdb/webapp/integration/pageObjects/Navigator.kt @@ -175,7 +175,6 @@ import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.steps.HasMe import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.steps.HmoAdditionalLicenceStep import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.steps.HmoMandatoryLicenceStep import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.steps.HouseholdStep -import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.steps.InviteJointLandlordStep import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.steps.IsEpcRequiredStep import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.steps.LicensingTypeStep import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.steps.LocalCouncilStep @@ -190,6 +189,7 @@ import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.steps.RentF import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.steps.RentIncludesBillsStep import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.steps.SelectiveLicenceStep import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.steps.TenantsStep +import uk.gov.communities.prsdb.webapp.journeys.shared.inviteJointLandlord.InviteJointLandlordStep import uk.gov.communities.prsdb.webapp.journeys.shared.stepConfig.AbstractCheckYourAnswersStep import uk.gov.communities.prsdb.webapp.journeys.shared.stepConfig.LookupAddressStep import uk.gov.communities.prsdb.webapp.journeys.shared.stepConfig.ManualAddressStep diff --git a/src/test/kotlin/uk/gov/communities/prsdb/webapp/integration/pageObjects/pages/inviteJointLandlordJourneyPages/CheckJointLandlordsFormPageInviteJointLandlord.kt b/src/test/kotlin/uk/gov/communities/prsdb/webapp/integration/pageObjects/pages/inviteJointLandlordJourneyPages/CheckJointLandlordsFormPageInviteJointLandlord.kt index d27bf202b8..8a4b85ed06 100644 --- a/src/test/kotlin/uk/gov/communities/prsdb/webapp/integration/pageObjects/pages/inviteJointLandlordJourneyPages/CheckJointLandlordsFormPageInviteJointLandlord.kt +++ b/src/test/kotlin/uk/gov/communities/prsdb/webapp/integration/pageObjects/pages/inviteJointLandlordJourneyPages/CheckJointLandlordsFormPageInviteJointLandlord.kt @@ -8,7 +8,7 @@ import uk.gov.communities.prsdb.webapp.integration.pageObjects.components.PostFo import uk.gov.communities.prsdb.webapp.integration.pageObjects.components.SecondaryButton import uk.gov.communities.prsdb.webapp.integration.pageObjects.components.SummaryList import uk.gov.communities.prsdb.webapp.integration.pageObjects.pages.basePages.BasePage -import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.steps.CheckJointLandlordsStep +import uk.gov.communities.prsdb.webapp.journeys.shared.inviteJointLandlord.CheckJointLandlordsStep class CheckJointLandlordsFormPageInviteJointLandlord( page: Page, diff --git a/src/test/kotlin/uk/gov/communities/prsdb/webapp/integration/pageObjects/pages/inviteJointLandlordJourneyPages/InviteAnotherJointLandlordFormPageInviteJointLandlord.kt b/src/test/kotlin/uk/gov/communities/prsdb/webapp/integration/pageObjects/pages/inviteJointLandlordJourneyPages/InviteAnotherJointLandlordFormPageInviteJointLandlord.kt index 48d678ebbd..73a72cda60 100644 --- a/src/test/kotlin/uk/gov/communities/prsdb/webapp/integration/pageObjects/pages/inviteJointLandlordJourneyPages/InviteAnotherJointLandlordFormPageInviteJointLandlord.kt +++ b/src/test/kotlin/uk/gov/communities/prsdb/webapp/integration/pageObjects/pages/inviteJointLandlordJourneyPages/InviteAnotherJointLandlordFormPageInviteJointLandlord.kt @@ -4,7 +4,7 @@ import com.microsoft.playwright.Page import uk.gov.communities.prsdb.webapp.controllers.InviteJointLandlordController import uk.gov.communities.prsdb.webapp.integration.pageObjects.components.Heading import uk.gov.communities.prsdb.webapp.integration.pageObjects.pages.basePages.EmailFormPage -import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.steps.InviteJointLandlordStep +import uk.gov.communities.prsdb.webapp.journeys.shared.inviteJointLandlord.InviteJointLandlordStep class InviteAnotherJointLandlordFormPageInviteJointLandlord( page: Page, diff --git a/src/test/kotlin/uk/gov/communities/prsdb/webapp/integration/pageObjects/pages/inviteJointLandlordJourneyPages/InviteJointLandlordFormPageInviteJointLandlord.kt b/src/test/kotlin/uk/gov/communities/prsdb/webapp/integration/pageObjects/pages/inviteJointLandlordJourneyPages/InviteJointLandlordFormPageInviteJointLandlord.kt index a219ea7ba4..c0c66012d5 100644 --- a/src/test/kotlin/uk/gov/communities/prsdb/webapp/integration/pageObjects/pages/inviteJointLandlordJourneyPages/InviteJointLandlordFormPageInviteJointLandlord.kt +++ b/src/test/kotlin/uk/gov/communities/prsdb/webapp/integration/pageObjects/pages/inviteJointLandlordJourneyPages/InviteJointLandlordFormPageInviteJointLandlord.kt @@ -4,7 +4,7 @@ import com.microsoft.playwright.Page import uk.gov.communities.prsdb.webapp.controllers.InviteJointLandlordController import uk.gov.communities.prsdb.webapp.integration.pageObjects.components.Heading import uk.gov.communities.prsdb.webapp.integration.pageObjects.pages.basePages.EmailFormPage -import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.steps.InviteJointLandlordStep +import uk.gov.communities.prsdb.webapp.journeys.shared.inviteJointLandlord.InviteJointLandlordStep class InviteJointLandlordFormPageInviteJointLandlord( page: Page, diff --git a/src/test/kotlin/uk/gov/communities/prsdb/webapp/integration/pageObjects/pages/propertyRegistrationJourneyPages/CheckJointLandlordsFormPagePropertyRegistration.kt b/src/test/kotlin/uk/gov/communities/prsdb/webapp/integration/pageObjects/pages/propertyRegistrationJourneyPages/CheckJointLandlordsFormPagePropertyRegistration.kt index 97cb3b6966..b57191c5fe 100644 --- a/src/test/kotlin/uk/gov/communities/prsdb/webapp/integration/pageObjects/pages/propertyRegistrationJourneyPages/CheckJointLandlordsFormPagePropertyRegistration.kt +++ b/src/test/kotlin/uk/gov/communities/prsdb/webapp/integration/pageObjects/pages/propertyRegistrationJourneyPages/CheckJointLandlordsFormPagePropertyRegistration.kt @@ -8,7 +8,7 @@ import uk.gov.communities.prsdb.webapp.integration.pageObjects.components.PostFo import uk.gov.communities.prsdb.webapp.integration.pageObjects.components.SecondaryButton import uk.gov.communities.prsdb.webapp.integration.pageObjects.components.SummaryList import uk.gov.communities.prsdb.webapp.integration.pageObjects.pages.basePages.BasePage -import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.steps.CheckJointLandlordsStep +import uk.gov.communities.prsdb.webapp.journeys.shared.inviteJointLandlord.CheckJointLandlordsStep class CheckJointLandlordsFormPagePropertyRegistration( page: Page, diff --git a/src/test/kotlin/uk/gov/communities/prsdb/webapp/integration/pageObjects/pages/propertyRegistrationJourneyPages/InviteJointLandlordFormPagePropertyRegistration.kt b/src/test/kotlin/uk/gov/communities/prsdb/webapp/integration/pageObjects/pages/propertyRegistrationJourneyPages/InviteJointLandlordFormPagePropertyRegistration.kt index 63922e0292..471e071457 100644 --- a/src/test/kotlin/uk/gov/communities/prsdb/webapp/integration/pageObjects/pages/propertyRegistrationJourneyPages/InviteJointLandlordFormPagePropertyRegistration.kt +++ b/src/test/kotlin/uk/gov/communities/prsdb/webapp/integration/pageObjects/pages/propertyRegistrationJourneyPages/InviteJointLandlordFormPagePropertyRegistration.kt @@ -4,7 +4,7 @@ import com.microsoft.playwright.Page import uk.gov.communities.prsdb.webapp.controllers.RegisterPropertyController import uk.gov.communities.prsdb.webapp.integration.pageObjects.components.Heading import uk.gov.communities.prsdb.webapp.integration.pageObjects.pages.basePages.EmailFormPage -import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.steps.InviteJointLandlordStep +import uk.gov.communities.prsdb.webapp.journeys.shared.inviteJointLandlord.InviteJointLandlordStep class InviteJointLandlordFormPagePropertyRegistration( page: Page, diff --git a/src/test/kotlin/uk/gov/communities/prsdb/webapp/integration/pageObjects/pages/propertyRegistrationJourneyPages/RemoveJointLandlordAreYouSureFormPagePropertyRegistration.kt b/src/test/kotlin/uk/gov/communities/prsdb/webapp/integration/pageObjects/pages/propertyRegistrationJourneyPages/RemoveJointLandlordAreYouSureFormPagePropertyRegistration.kt index 93506f556b..e0cf634909 100644 --- a/src/test/kotlin/uk/gov/communities/prsdb/webapp/integration/pageObjects/pages/propertyRegistrationJourneyPages/RemoveJointLandlordAreYouSureFormPagePropertyRegistration.kt +++ b/src/test/kotlin/uk/gov/communities/prsdb/webapp/integration/pageObjects/pages/propertyRegistrationJourneyPages/RemoveJointLandlordAreYouSureFormPagePropertyRegistration.kt @@ -3,7 +3,7 @@ package uk.gov.communities.prsdb.webapp.integration.pageObjects.pages.propertyRe import com.microsoft.playwright.Page import uk.gov.communities.prsdb.webapp.controllers.RegisterPropertyController import uk.gov.communities.prsdb.webapp.integration.pageObjects.pages.basePages.AreYouSureFormBasePage -import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.steps.RemoveJointLandlordAreYouSureStep +import uk.gov.communities.prsdb.webapp.journeys.shared.inviteJointLandlord.RemoveJointLandlordAreYouSureStep class RemoveJointLandlordAreYouSureFormPagePropertyRegistration( page: Page, diff --git a/src/test/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/update/inviteJointLandlord/CheckInvitationsStepConfigTests.kt b/src/test/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/update/inviteJointLandlord/CheckInvitationsStepConfigTests.kt index f3e934d468..cdd15b5b3d 100644 --- a/src/test/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/update/inviteJointLandlord/CheckInvitationsStepConfigTests.kt +++ b/src/test/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/update/inviteJointLandlord/CheckInvitationsStepConfigTests.kt @@ -8,8 +8,8 @@ import org.mockito.Mock import org.mockito.junit.jupiter.MockitoExtension import org.mockito.kotlin.whenever import uk.gov.communities.prsdb.webapp.journeys.JourneyIdProvider -import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.steps.CheckJointLandlordsStep import uk.gov.communities.prsdb.webapp.journeys.shared.Complete +import uk.gov.communities.prsdb.webapp.journeys.shared.inviteJointLandlord.CheckJointLandlordsStep import uk.gov.communities.prsdb.webapp.models.viewModels.summaryModels.SummaryListRowViewModel import uk.gov.communities.prsdb.webapp.testHelpers.mockObjects.AlwaysTrueValidator diff --git a/src/test/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/steps/CheckJointLandlordsStepConfigTests.kt b/src/test/kotlin/uk/gov/communities/prsdb/webapp/journeys/shared/inviteJointLandlord/CheckJointLandlordsStepConfigTests.kt similarity index 96% rename from src/test/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/steps/CheckJointLandlordsStepConfigTests.kt rename to src/test/kotlin/uk/gov/communities/prsdb/webapp/journeys/shared/inviteJointLandlord/CheckJointLandlordsStepConfigTests.kt index 363522cb58..a259c42ef5 100644 --- a/src/test/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/steps/CheckJointLandlordsStepConfigTests.kt +++ b/src/test/kotlin/uk/gov/communities/prsdb/webapp/journeys/shared/inviteJointLandlord/CheckJointLandlordsStepConfigTests.kt @@ -1,4 +1,4 @@ -package uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.steps +package uk.gov.communities.prsdb.webapp.journeys.shared.inviteJointLandlord import org.junit.jupiter.api.Assertions.assertEquals import org.junit.jupiter.api.Test @@ -8,7 +8,7 @@ import org.mockito.junit.jupiter.MockitoExtension import org.mockito.kotlin.any import org.mockito.kotlin.whenever import uk.gov.communities.prsdb.webapp.journeys.JourneyIdProvider -import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.states.SharedInviteJointLandlordState +import uk.gov.communities.prsdb.webapp.journeys.shared.states.SharedInviteJointLandlordState import uk.gov.communities.prsdb.webapp.models.viewModels.summaryModels.SummaryListRowViewModel import uk.gov.communities.prsdb.webapp.services.CollectionKeyParameterService import uk.gov.communities.prsdb.webapp.testHelpers.mockObjects.AlwaysTrueValidator diff --git a/src/test/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/steps/InviteJointLandlordStepConfigTests.kt b/src/test/kotlin/uk/gov/communities/prsdb/webapp/journeys/shared/inviteJointLandlord/InviteJointLandlordStepConfigTests.kt similarity index 95% rename from src/test/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/steps/InviteJointLandlordStepConfigTests.kt rename to src/test/kotlin/uk/gov/communities/prsdb/webapp/journeys/shared/inviteJointLandlord/InviteJointLandlordStepConfigTests.kt index 743117bd8d..91999974aa 100644 --- a/src/test/kotlin/uk/gov/communities/prsdb/webapp/journeys/propertyRegistration/steps/InviteJointLandlordStepConfigTests.kt +++ b/src/test/kotlin/uk/gov/communities/prsdb/webapp/journeys/shared/inviteJointLandlord/InviteJointLandlordStepConfigTests.kt @@ -1,4 +1,4 @@ -package uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.steps +package uk.gov.communities.prsdb.webapp.journeys.shared.inviteJointLandlord import org.junit.jupiter.api.Assertions.assertEquals import org.junit.jupiter.api.Test @@ -9,7 +9,7 @@ import org.mockito.kotlin.argumentCaptor import org.mockito.kotlin.never import org.mockito.kotlin.verify import org.mockito.kotlin.whenever -import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.states.SharedInviteJointLandlordState +import uk.gov.communities.prsdb.webapp.journeys.shared.states.SharedInviteJointLandlordState import uk.gov.communities.prsdb.webapp.services.CollectionKeyParameterService import uk.gov.communities.prsdb.webapp.testHelpers.mockObjects.AlwaysTrueValidator diff --git a/src/test/kotlin/uk/gov/communities/prsdb/webapp/testHelpers/builders/JointLandlordsStateBuilder.kt b/src/test/kotlin/uk/gov/communities/prsdb/webapp/testHelpers/builders/JointLandlordsStateBuilder.kt index 1d4bc26716..120d041a1d 100644 --- a/src/test/kotlin/uk/gov/communities/prsdb/webapp/testHelpers/builders/JointLandlordsStateBuilder.kt +++ b/src/test/kotlin/uk/gov/communities/prsdb/webapp/testHelpers/builders/JointLandlordsStateBuilder.kt @@ -3,7 +3,7 @@ package uk.gov.communities.prsdb.webapp.testHelpers.builders import kotlinx.serialization.json.Json import kotlinx.serialization.serializer import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.steps.HasJointLandlordsStep -import uk.gov.communities.prsdb.webapp.journeys.propertyRegistration.steps.InviteJointLandlordStep +import uk.gov.communities.prsdb.webapp.journeys.shared.inviteJointLandlord.InviteJointLandlordStep import uk.gov.communities.prsdb.webapp.models.requestModels.formModels.FormModel import uk.gov.communities.prsdb.webapp.models.requestModels.formModels.HasJointLandlordsFormModel import uk.gov.communities.prsdb.webapp.models.requestModels.formModels.InviteJointLandlordsFormModel