-
Notifications
You must be signed in to change notification settings - Fork 0
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this 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!
fun getValueByKey( | ||
journeyData: JourneyData, | ||
key: String, | ||
): String? = journeyData[key]?.toString() | ||
|
There was a problem hiding this comment.
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
nextAction = { journeyData, _ -> | ||
if (UpdateLandlordDetailsJourneyDataHelper.getIsIdentityVerified(journeyData)) { | ||
Pair(UpdateDetailsStepId.UpdatePhoneNumber, null) | ||
} else { | ||
Pair(UpdateDetailsStepId.UpdateDateOfBirth, null) | ||
} | ||
}, | ||
saveAfterSubmit = false, |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
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, | ||
) |
There was a problem hiding this comment.
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!
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, |
There was a problem hiding this comment.
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"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And here too.
There was a problem hiding this 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.
@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", |
There was a problem hiding this comment.
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) {
val newDateOfBirth = LocalDate.of(1992, 2, 2) | ||
val updateModel = | ||
LandlordUpdateModel( | ||
"newEmail", | ||
"newName", | ||
"new phone number", | ||
AddressDataModel.fromAddress(newAddress), | ||
newDateOfBirth, |
There was a problem hiding this comment.
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.
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