-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feat/prsd 670 landlord dashboard absolute url (#244)
- Loading branch information
1 parent
0c7861b
commit d3323eb
Showing
15 changed files
with
116 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
src/main/kotlin/uk/gov/communities/prsdb/webapp/controllers/LandlordDashboardController.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package uk.gov.communities.prsdb.webapp.controllers | ||
|
||
import org.springframework.security.access.prepost.PreAuthorize | ||
import org.springframework.stereotype.Controller | ||
import org.springframework.ui.Model | ||
import org.springframework.web.bind.annotation.GetMapping | ||
import org.springframework.web.bind.annotation.RequestMapping | ||
import uk.gov.communities.prsdb.webapp.constants.DASHBOARD_PATH_SEGMENT | ||
import uk.gov.communities.prsdb.webapp.constants.LANDLORD_PATH_SEGMENT | ||
import java.security.Principal | ||
|
||
@PreAuthorize("hasAnyRole('LANDLORD')") | ||
@Controller | ||
@RequestMapping("/$LANDLORD_PATH_SEGMENT") | ||
class LandlordDashboardController { | ||
@GetMapping | ||
fun index(): CharSequence = "redirect:$LANDLORD_DASHBOARD_URL" | ||
|
||
@GetMapping("/$DASHBOARD_PATH_SEGMENT") | ||
fun landlordDashboard( | ||
model: Model, | ||
principale: Principal, | ||
): String { | ||
model.addAttribute("title", "Landlord Dashboard") | ||
|
||
return "landlordDashboard" | ||
} | ||
|
||
companion object { | ||
const val LANDLORD_DASHBOARD_URL = "/$LANDLORD_PATH_SEGMENT/$DASHBOARD_PATH_SEGMENT" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
src/main/kotlin/uk/gov/communities/prsdb/webapp/services/AbsoluteUrlProvider.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package uk.gov.communities.prsdb.webapp.services | ||
|
||
import org.springframework.stereotype.Service | ||
import org.springframework.web.servlet.mvc.method.annotation.MvcUriComponentsBuilder | ||
import org.springframework.web.servlet.mvc.method.annotation.MvcUriComponentsBuilder.on | ||
import uk.gov.communities.prsdb.webapp.controllers.LandlordDashboardController | ||
import uk.gov.communities.prsdb.webapp.controllers.RegisterLAUserController | ||
import java.net.URI | ||
|
||
@Service | ||
class AbsoluteUrlProvider { | ||
fun buildLandlordDashboardUri(): URI = | ||
MvcUriComponentsBuilder | ||
.fromMethodCall(on(LandlordDashboardController::class.java).index()) | ||
.build() | ||
.toUri() | ||
|
||
fun buildInvitationUri(token: String): URI = | ||
MvcUriComponentsBuilder | ||
.fromMethodCall(on(RegisterLAUserController::class.java).acceptInvitation(token)) | ||
.build() | ||
.toUri() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<!DOCTYPE html> | ||
<html th:replace="~{fragments/layout :: layout(#{${title}}, ~{::main}, false)}"> | ||
<main class="govuk-main-wrapper"> | ||
<div id="page-content"> | ||
<h1>Landlord dashboard</h1> | ||
</div> | ||
</main> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,16 +3,22 @@ package uk.gov.communities.prsdb.webapp.integration | |
import com.microsoft.playwright.Page | ||
import com.microsoft.playwright.assertions.PlaywrightAssertions.assertThat | ||
import org.junit.jupiter.api.Test | ||
import org.mockito.ArgumentMatchers.anyString | ||
import org.mockito.kotlin.whenever | ||
import org.springframework.test.context.jdbc.Sql | ||
import uk.gov.communities.prsdb.webapp.integration.pageObjects.components.BaseComponent.Companion.assertThat | ||
import uk.gov.communities.prsdb.webapp.integration.pageObjects.pages.InviteNewLaUserSuccessPage | ||
import uk.gov.communities.prsdb.webapp.integration.pageObjects.pages.LocalAuthorityDashboardPage | ||
import uk.gov.communities.prsdb.webapp.integration.pageObjects.pages.basePages.BasePage.Companion.assertPageIs | ||
import java.net.URI | ||
|
||
@Sql("/data-local.sql") | ||
class InviteLaUsersTests : IntegrationTest() { | ||
@Test | ||
fun `inviting a new LA user ends with a success page with a button linking to the dashboard`(page: Page) { | ||
whenever(absoluteUrlProvider.buildInvitationUri(anyString())) | ||
.thenReturn(URI("www.prsd.gov.uk/register-la-user/test-token")) | ||
|
||
val invitePage = navigator.goToInviteNewLaUser(1) | ||
invitePage.submitMatchingEmail("[email protected]") | ||
val successPage = assertPageIs(page, InviteNewLaUserSuccessPage::class) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,7 +19,6 @@ import org.mockito.kotlin.whenever | |
import org.springframework.beans.factory.annotation.Autowired | ||
import org.springframework.boot.test.mock.mockito.SpyBean | ||
import org.springframework.test.context.jdbc.Sql | ||
import uk.gov.communities.prsdb.webapp.constants.LANDLORD_DASHBOARD_URL | ||
import uk.gov.communities.prsdb.webapp.constants.MANUAL_ADDRESS_CHOSEN | ||
import uk.gov.communities.prsdb.webapp.helpers.DateTimeHelper | ||
import uk.gov.communities.prsdb.webapp.helpers.getFormattedInternationalPhoneNumber | ||
|
@@ -50,6 +49,7 @@ import kotlin.test.assertNotNull | |
@Sql("/data-mockuser-not-landlord.sql") | ||
class LandlordRegistrationJourneyTests : IntegrationTest() { | ||
private val phoneNumberUtil = PhoneNumberUtil.getInstance() | ||
private val absoluteLandlordUrl = "www.prsd.gov.uk/landlord" | ||
|
||
@Autowired | ||
private lateinit var landlordService: LandlordService | ||
|
@@ -65,6 +65,8 @@ class LandlordRegistrationJourneyTests : IntegrationTest() { | |
"{'results':[{'DPA':{'ADDRESS':'1, Example Road, EG1 2AB'," + | ||
"'LOCAL_CUSTODIAN_CODE':28,'UPRN':'1','BUILDING_NUMBER':1,'POSTCODE':'EG1 2AB'}}]}", | ||
) | ||
|
||
whenever(absoluteUrlProvider.buildLandlordDashboardUri()).thenReturn(URI(absoluteLandlordUrl)) | ||
} | ||
|
||
@Test | ||
|
@@ -107,7 +109,7 @@ class LandlordRegistrationJourneyTests : IntegrationTest() { | |
|
||
verify(confirmationEmailSender).sendEmail( | ||
"[email protected]", | ||
LandlordRegistrationConfirmationEmail(createdLandlordRegNum.toString(), LANDLORD_DASHBOARD_URL), | ||
LandlordRegistrationConfirmationEmail(createdLandlordRegNum.toString(), absoluteLandlordUrl), | ||
) | ||
|
||
val confirmationPage = assertPageIs(page, ConfirmationPageLandlordRegistration::class) | ||
|
@@ -158,7 +160,7 @@ class LandlordRegistrationJourneyTests : IntegrationTest() { | |
|
||
verify(confirmationEmailSender).sendEmail( | ||
"[email protected]", | ||
LandlordRegistrationConfirmationEmail(createdLandlordRegNum.toString(), LANDLORD_DASHBOARD_URL), | ||
LandlordRegistrationConfirmationEmail(createdLandlordRegNum.toString(), absoluteLandlordUrl), | ||
) | ||
|
||
val confirmationPage = assertPageIs(page, ConfirmationPageLandlordRegistration::class) | ||
|
@@ -213,7 +215,7 @@ class LandlordRegistrationJourneyTests : IntegrationTest() { | |
|
||
verify(confirmationEmailSender).sendEmail( | ||
"[email protected]", | ||
LandlordRegistrationConfirmationEmail(createdLandlordRegNum.toString(), LANDLORD_DASHBOARD_URL), | ||
LandlordRegistrationConfirmationEmail(createdLandlordRegNum.toString(), absoluteLandlordUrl), | ||
) | ||
|
||
val confirmationPage = assertPageIs(page, ConfirmationPageLandlordRegistration::class) | ||
|
@@ -271,7 +273,7 @@ class LandlordRegistrationJourneyTests : IntegrationTest() { | |
|
||
verify(confirmationEmailSender).sendEmail( | ||
"[email protected]", | ||
LandlordRegistrationConfirmationEmail(createdLandlordRegNum.toString(), LANDLORD_DASHBOARD_URL), | ||
LandlordRegistrationConfirmationEmail(createdLandlordRegNum.toString(), absoluteLandlordUrl), | ||
) | ||
|
||
val confirmationPage = assertPageIs(page, ConfirmationPageLandlordRegistration::class) | ||
|
Oops, something went wrong.