-
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.
PRSD-649: Landlord Search Page Integration Tests (#136)
- Loading branch information
1 parent
1464fa6
commit 5e1cb39
Showing
6 changed files
with
191 additions
and
23 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
63 changes: 63 additions & 0 deletions
63
src/test/kotlin/uk/gov/communities/prsdb/webapp/integration/SearchRegisterTests.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,63 @@ | ||
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.junit.jupiter.api.assertThrows | ||
import org.opentest4j.AssertionFailedError | ||
import org.springframework.test.context.jdbc.Sql | ||
import uk.gov.communities.prsdb.webapp.integration.pageObjects.pages.ErrorPage | ||
import uk.gov.communities.prsdb.webapp.integration.pageObjects.pages.SearchLandlordRegisterPage.Companion.ADDRESS_COL_INDEX | ||
import uk.gov.communities.prsdb.webapp.integration.pageObjects.pages.SearchLandlordRegisterPage.Companion.CONTACT_INFO_COL_INDEX | ||
import uk.gov.communities.prsdb.webapp.integration.pageObjects.pages.SearchLandlordRegisterPage.Companion.LANDLORD_COL_INDEX | ||
import uk.gov.communities.prsdb.webapp.integration.pageObjects.pages.basePages.BasePage.Companion.assertPageIs | ||
import kotlin.test.assertContains | ||
|
||
@Sql("/data-landlord-search.sql") | ||
class SearchRegisterTests : IntegrationTest() { | ||
@Test | ||
fun `results table does not show before search has been requested`() { | ||
val searchLandlordRegisterPage = navigator.goToSearchLandlordRegister() | ||
|
||
val exception = assertThrows<AssertionFailedError> { searchLandlordRegisterPage.getResultTable() } | ||
assertContains(exception.message!!, "Expected 1 instance of [email protected], found 0") | ||
} | ||
|
||
@Test | ||
fun `results table shows after search has been requested`() { | ||
val searchLandlordRegisterPage = navigator.goToSearchLandlordRegister() | ||
searchLandlordRegisterPage.searchBar.search("L-CKSQ-3SX9") | ||
val resultTable = searchLandlordRegisterPage.getResultTable() | ||
|
||
assertThat(resultTable.getHeaderCell(LANDLORD_COL_INDEX)).containsText("Landlord") | ||
assertThat(resultTable.getCell(0, LANDLORD_COL_INDEX)).containsText("Alexander Smith\nL-CKSQ-3SX9") | ||
|
||
assertThat(resultTable.getHeaderCell(ADDRESS_COL_INDEX)).containsText("Contact address") | ||
assertThat(resultTable.getCell(0, ADDRESS_COL_INDEX)).containsText("1 Fictional Road") | ||
|
||
assertThat(resultTable.getHeaderCell(CONTACT_INFO_COL_INDEX)).containsText("Contact information") | ||
assertThat(resultTable.getCell(0, CONTACT_INFO_COL_INDEX)).containsText("7111111111\n[email protected]") | ||
} | ||
|
||
@Test | ||
fun `fuzzy search functionality works`() { | ||
val searchLandlordRegisterPage = navigator.goToSearchLandlordRegister() | ||
searchLandlordRegisterPage.searchBar.search("Alex") | ||
val resultTable = searchLandlordRegisterPage.getResultTable() | ||
|
||
assertThat(resultTable.getCell(0, LANDLORD_COL_INDEX)).containsText("Alexander Smith") | ||
assertThat(resultTable.getCell(1, LANDLORD_COL_INDEX)).containsText("Alexandra Davies") | ||
assertThat(resultTable.getCell(2, LANDLORD_COL_INDEX)).containsText("Evan Alexandrescu") | ||
} | ||
|
||
@Test | ||
fun `landlord links goes to landlord details page`(page: Page) { | ||
val searchLandlordRegisterPage = navigator.goToSearchLandlordRegister() | ||
searchLandlordRegisterPage.searchBar.search("L-CKSQ-3SX9") | ||
searchLandlordRegisterPage.getLandlordLink(rowIndex = 0).click() | ||
|
||
// TODO PRSD-656: Replace with landlord details page assertion | ||
assertPageIs(page, ErrorPage::class) | ||
assertContains(page.url(), "/landlord-details/1") | ||
} | ||
} |
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
17 changes: 17 additions & 0 deletions
17
...st/kotlin/uk/gov/communities/prsdb/webapp/integration/pageObjects/components/SearchBar.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,17 @@ | ||
package uk.gov.communities.prsdb.webapp.integration.pageObjects.components | ||
|
||
import com.microsoft.playwright.Locator | ||
import com.microsoft.playwright.Page | ||
|
||
class SearchBar( | ||
private val page: Page, | ||
locator: Locator = page.locator(".moj-search"), | ||
) : BaseComponent(locator) { | ||
private val form = Form(page) | ||
private val searchInput = form.getTextInput() | ||
|
||
fun search(query: String) { | ||
searchInput.fill(query) | ||
form.submit() | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
.../gov/communities/prsdb/webapp/integration/pageObjects/pages/SearchLandlordRegisterPage.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.integration.pageObjects.pages | ||
|
||
import com.microsoft.playwright.Page | ||
import uk.gov.communities.prsdb.webapp.integration.pageObjects.components.BaseComponent.Companion.getChildComponent | ||
import uk.gov.communities.prsdb.webapp.integration.pageObjects.components.SearchBar | ||
import uk.gov.communities.prsdb.webapp.integration.pageObjects.components.Table | ||
import uk.gov.communities.prsdb.webapp.integration.pageObjects.pages.basePages.BasePage | ||
|
||
class SearchLandlordRegisterPage( | ||
page: Page, | ||
) : BasePage(page, "/search/landlord") { | ||
val searchBar = SearchBar(page) | ||
|
||
fun getResultTable() = Table(page) | ||
|
||
fun getLandlordLink(rowIndex: Int) = getChildComponent(getResultTable().getCell(rowIndex, LANDLORD_COL_INDEX), "a") | ||
|
||
companion object { | ||
const val LANDLORD_COL_INDEX: Int = 0 | ||
const val ADDRESS_COL_INDEX: Int = 1 | ||
const val CONTACT_INFO_COL_INDEX: Int = 2 | ||
} | ||
} |
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,57 @@ | ||
INSERT INTO one_login_user (id, name, email, created_date, last_modified_date) | ||
VALUES ('urn:fdc:gov.uk:2022:ABCDE', 'Bob T Builder', '[email protected]', '09/13/24', '09/13/24'), | ||
('urn:fdc:gov.uk:2022:FGHIJ', 'Anne Other', '[email protected]', '09/13/24', '09/13/24'), | ||
('urn:fdc:gov.uk:2022:KLMNO', 'Ford Prefect', '[email protected]', '10/07/24', '10/07/24'), | ||
('urn:fdc:gov.uk:2022:UVWXY', 'Mock User', '[email protected]', '10/14/24', '10/14/24'), | ||
('urn:fdc:gov.uk:2022:PQRST', 'Arthur Dent', '[email protected]', '10/09/24', '10/09/24'), | ||
('urn:fdc:gov.uk:2022:07lXHJeQwE0k5PZO7w_PQF425vT8T7e63MrvyPYNSoI', 'Jasmin Conterio', | ||
'[email protected]', '10/07/24', '10/07/24'), | ||
('urn:fdc:gov.uk:2022:mwfvbb5GgiDh0acjz9EDDQ7zwskWZzUSnWfavL70f6s', 'Isobel Ibironke', | ||
'[email protected]', '10/02/24', '10/02/24'), | ||
('urn:fdc:gov.uk:2022:mGHDySEVfCsvfvc6lVWf6Qt9Dv0ZxPQWKoEzcjnBlUo', 'PRSDB Landlord', | ||
'[email protected]', '10/15/24', '10/15/24'), | ||
('urn:fdc:gov.uk:2022:n93slCXHsxJ9rU6-AFM0jFIctYQjYf0KN9YVuJT-cao', 'PRSDB LA Admin', | ||
'[email protected]', '10/15/24', '10/15/24'), | ||
('urn:fdc:gov.uk:2022:cgVX2oJWKHMwzm8Gzx25CSoVXixVS0rw32Sar4Om8vQ', 'PRSDB La User', | ||
'[email protected]', '10/15/24', '10/15/24'); | ||
|
||
INSERT INTO local_authority (id, name, created_date, last_modified_date) | ||
VALUES (1, 'Betelgeuse', '09/13/24', '09/13/24'); | ||
|
||
INSERT INTO local_authority_user (subject_identifier, is_manager, local_authority_id, created_date, last_modified_date, | ||
name, email) | ||
VALUES ('urn:fdc:gov.uk:2022:UVWXY', true, 1, '10/14/24', '10/14/24', 'Mock User', '[email protected]'); | ||
|
||
INSERT INTO registration_number (id, created_date, number, type) | ||
VALUES (1, '09/13/24', 2001001001, 1), | ||
(2, '09/13/24', 3002001002, 1), | ||
(3, '10/07/24', 4003001003, 1), | ||
(4, '10/14/24', 5004001004, 1), | ||
(5, '10/09/24', 6005001005, 1), | ||
(6, '12/10/24', 7006001006, 0), | ||
(7, '12/19/24', 8005001005, 1); | ||
|
||
INSERT INTO address (id, created_date, last_modified_date, uprn, single_line_address) | ||
VALUES (1, '09/13/24', '09/13/24', 1, '1 Fictional Road'), | ||
(2, '09/13/24', '09/13/24', 2, '2 Fake Way'), | ||
(3, '09/13/24', '09/13/24', 3, '3 Imaginary Street'), | ||
(4, '09/13/24', '09/13/24', 4, '4 Pretend Crescent'), | ||
(5, '09/13/24', '09/13/24', 5, '5 Mythical Place'), | ||
(6, '12/10/2024', '12/10/2024', 1123456, '1, Example Road, EG'); | ||
|
||
INSERT INTO landlord (id, created_date, last_modified_date, registration_number_id, address_id, date_of_birth, | ||
is_active, phone_number, subject_identifier, name, email) | ||
VALUES (1, '09/13/24', '09/13/24', 1, 1, '09/13/2000', true, 07111111111, 'urn:fdc:gov.uk:2022:UVWXY', | ||
'Alexander Smith', '[email protected]'), | ||
(2, '09/13/24', '09/13/24', 2, 2, '08/13/2001', true, 07111111111, 'urn:fdc:gov.uk:2022:ABCDE', | ||
'Alexandra Davies', '[email protected]'), | ||
(3, '09/13/24', '09/13/24', 3, 3, '07/13/1997', true, 07111111111, 'urn:fdc:gov.uk:2022:PQRST', | ||
'Evan Alexandrescu', '[email protected]'), | ||
(4, '09/13/24', '09/13/24', 4, 4, '06/13/1989', true, 07111111111, | ||
'urn:fdc:gov.uk:2022:07lXHJeQwE0k5PZO7w_PQF425vT8T7e63MrvyPYNSoI', 'Tobias Evans', '[email protected]'), | ||
(5, '09/13/24', '09/13/24', 5, 5, '05/13/1950', true, 07111111111, | ||
'urn:fdc:gov.uk:2022:mwfvbb5GgiDh0acjz9EDDQ7zwskWZzUSnWfavL70f6s', 'Margaret Mary Smith', | ||
'[email protected]'), | ||
(6, '12/19/24', '12/19/24', 7, 5, '06/13/1989', true, 07111111111, | ||
'urn:fdc:gov.uk:2022:mGHDySEVfCsvfvc6lVWf6Qt9Dv0ZxPQWKoEzcjnBlUo', 'PRSDB Landlord', | ||
'[email protected]'); |