Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/prsd 792 update landlord date of birth #245

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

Kiran-R-K
Copy link
Contributor

@Kiran-R-K Kiran-R-K commented Feb 27, 2025

Created the landlord update date of birth step
Ensured that a landlord with their identity verified can't update their name or date of birth

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I refactored this file to be in line with the pattern in PropertyDetailsLandlordViewModel

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bit of a nitpick, but I've had a look at the addRow extension. Couldn't we make the "addRow" logic live on a companion factory function for SummaryListRowViewModel?

Not really the focus of this PR though, so happy to leave it.

@Kiran-R-K Kiran-R-K marked this pull request as draft February 28, 2025 10:50
@Kiran-R-K Kiran-R-K marked this pull request as ready for review February 28, 2025 11:26
Copy link
Contributor

@AEPR AEPR left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couple of very small suggestions on main code. I've not looked through tests yet, but I will now as none of my suggestions would stop me approving!

Comment on lines +85 to +89
fun getValueByKey(
journeyData: JourneyData,
key: String,
): String? = journeyData[key]?.toString()

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you can probably just do this inline in getIsIdentityVerified, but if you want to keep it I think it should be getStringValueByKey

Comment on lines +109 to +116
nextAction = { journeyData, _ ->
if (UpdateLandlordDetailsJourneyDataHelper.getIsIdentityVerified(journeyData)) {
Pair(UpdateDetailsStepId.UpdatePhoneNumber, null)
} else {
Pair(UpdateDetailsStepId.UpdateDateOfBirth, null)
}
},
saveAfterSubmit = false,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need to repeat the check here - this can just go straight to date of birth because we can't reach the name step if the identity is verified.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We just discussed this, and I will add tests to ensure that date of birth is not reachable by a verified user and then will remove the conditional here

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bit of a nitpick, but I've had a look at the addRow extension. Couldn't we make the "addRow" logic live on a companion factory function for SummaryListRowViewModel?

Not really the focus of this PR though, so happy to leave it.

Comment on lines -55 to +63
SummaryListRowViewModel(
if (!landlord.isVerified) "$UPDATE_ROUTE/name" else null,
withChangeLinks,
)
addRow(
"landlordDetails.personalDetails.dateOfBirth",
landlord.dateOfBirth,
// TODO: PRSD-792 toggleChangeLink("$UPDATE_ROUTE/date-of-birth"),
null,
),
SummaryListRowViewModel(
if (!landlord.isVerified) "$UPDATE_ROUTE/date-of-birth" else null,
withChangeLinks,
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doing this whole refactor really pays off in making this more readable!

Comment on lines +97 to +116
addRow(
"landlordDetails.personalDetails.country",
landlord.countryOfResidence,
// TODO: PRSD-688 toggleChangeLink("$UPDATE_ROUTE/country-of-residence"),
null,
withChangeLinks,
)
addRow(
"landlordDetails.personalDetails.nonEnglandOrWalesAddress",
landlord.nonEnglandOrWalesAddress,
// TODO: PRSD-688 toggleChangeLink("$UPDATE_ROUTE/address"),
null,
withChangeLinks,
)
addRow(
"landlordDetails.personalDetails.englandOrWalesAddress",
landlord.address.singleLineAddress,
// TODO: PRSD-688 toggleChangeLink("$UPDATE_ROUTE/contact-address"),
null,
withChangeLinks,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you update these comments to remove the now defunct toggleChangeLink?

"$UPDATE_ROUTE/phone-number",
withChangeLinks,
)
addRow(
"landlordDetails.personalDetails.englandOrWalesResident",
isEnglandOrWalesResident,
// TODO: PRSD-688 toggleChangeLink("$UPDATE_ROUTE/country-of-residence"),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And here too.

Copy link
Contributor

@AEPR AEPR left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two more nitpicks on the tests - other than that and my comments from earlier, LGTM.

Comment on lines 325 to +362
@Test
fun `LandlordViewModel populates change links in rows that should have them`() {
fun `LandlordViewModel populates change links in rows that should have them for an unverified landlord`() {
// Arrange
val testLandlord = MockLandlordData.createLandlord()
val testLandlord = MockLandlordData.createLandlord(isVerified = false)
val changeablePersonalDetailKeys =
listOf(
"landlordDetails.personalDetails.name",
"landlordDetails.personalDetails.emailAddress",
"landlordDetails.personalDetails.telephoneNumber",
"landlordDetails.personalDetails.contactAddress",
"landlordDetails.personalDetails.dateOfBirth",
)

// Act
val viewModel = LandlordViewModel(testLandlord)

// Assert
for (i in viewModel.personalDetails.filter { detail -> detail.fieldHeading in changeablePersonalDetailKeys }) {
assertNotNull(i.changeUrl)
}

for (i in viewModel.personalDetails.filter { detail -> detail.fieldHeading !in changeablePersonalDetailKeys }) {
assertNull(i.changeUrl)
}

// TODO PRSD-746 change assertion for consentInformation once links have been added
viewModel.consentInformation.forEach { consentInformation -> assertNull(consentInformation.changeUrl) }
}

@Test
fun `LandlordViewModel populates change links in rows that should have them for a verified landlord`() {
// Arrange
val testLandlord = MockLandlordData.createLandlord(isVerified = true)
val changeablePersonalDetailKeys =
listOf(
"landlordDetails.personalDetails.emailAddress",
"landlordDetails.personalDetails.telephoneNumber",
"landlordDetails.personalDetails.contactAddress",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's probably worth commonising and parameterising these tests to reduce repetition. You can use something like:

@ValueSource(booleans = [true, false])
fun `Test name when` (isVerified: Boolean) {

Comment on lines +392 to +399
val newDateOfBirth = LocalDate.of(1992, 2, 2)
val updateModel =
LandlordUpdateModel(
"newEmail",
"newName",
"new phone number",
AddressDataModel.fromAddress(newAddress),
newDateOfBirth,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can declare this date inline in the LandlordUpdateModel constructor because we reference the updateModel in the assertion below.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants