-
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-NONE: Adds Playwright dependency * PRSD-NONE: Adds integration test set-up * PRSD-NONE: Replaces Selenium integration tests with Playwright ones * PRSD-NONE: Bypasses Spring Security for integration tests * PRSD-NONE: Re-enables method security in controller tests
- Loading branch information
1 parent
1be241f
commit 310e433
Showing
14 changed files
with
114 additions
and
125 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
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
22 changes: 0 additions & 22 deletions
22
src/test/kotlin/uk/gov/communities/prsdb/webapp/frontend/CheckHomePageTests.kt
This file was deleted.
Oops, something went wrong.
22 changes: 0 additions & 22 deletions
22
src/test/kotlin/uk/gov/communities/prsdb/webapp/frontend/ErrorPageTests.kt
This file was deleted.
Oops, something went wrong.
34 changes: 0 additions & 34 deletions
34
src/test/kotlin/uk/gov/communities/prsdb/webapp/frontend/FrontendTest.kt
This file was deleted.
Oops, something went wrong.
22 changes: 0 additions & 22 deletions
22
src/test/kotlin/uk/gov/communities/prsdb/webapp/frontend/RegisterHomePageTests.kt
This file was deleted.
Oops, something went wrong.
22 changes: 0 additions & 22 deletions
22
src/test/kotlin/uk/gov/communities/prsdb/webapp/frontend/SearchRegisterPageTests.kt
This file was deleted.
Oops, something went wrong.
14 changes: 14 additions & 0 deletions
14
src/test/kotlin/uk/gov/communities/prsdb/webapp/integration/CheckHomePageTests.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,14 @@ | ||
package uk.gov.communities.prsdb.webapp.integration | ||
|
||
import com.microsoft.playwright.Page | ||
import com.microsoft.playwright.assertions.PlaywrightAssertions.assertThat | ||
import com.microsoft.playwright.options.AriaRole | ||
import org.junit.jupiter.api.Test | ||
|
||
class CheckHomePageTests : IntegrationTest() { | ||
@Test | ||
fun `check a home for rent page renders`(page: Page) { | ||
page.navigate("http://localhost:$port/check") | ||
assertThat(page.getByRole(AriaRole.HEADING)).containsText("Check a home to rent") | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
src/test/kotlin/uk/gov/communities/prsdb/webapp/integration/ErrorPageTests.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,14 @@ | ||
package uk.gov.communities.prsdb.webapp.integration | ||
|
||
import com.microsoft.playwright.Page | ||
import com.microsoft.playwright.assertions.PlaywrightAssertions.assertThat | ||
import com.microsoft.playwright.options.AriaRole | ||
import org.junit.jupiter.api.Test | ||
|
||
class ErrorPageTests : IntegrationTest() { | ||
@Test | ||
fun `500 page renders when error controller path called`(page: Page) { | ||
page.navigate("http://localhost:$port/error") | ||
assertThat(page.getByRole(AriaRole.HEADING)).containsText("Sorry, there is a problem with the service") | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
src/test/kotlin/uk/gov/communities/prsdb/webapp/integration/IntegrationTest.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,39 @@ | ||
package uk.gov.communities.prsdb.webapp.integration | ||
|
||
import com.microsoft.playwright.junit.UsePlaywright | ||
import org.springframework.boot.test.context.SpringBootTest | ||
import org.springframework.boot.test.mock.mockito.MockBean | ||
import org.springframework.boot.test.web.server.LocalServerPort | ||
import org.springframework.context.annotation.Import | ||
import org.springframework.security.oauth2.client.endpoint.DefaultAuthorizationCodeTokenResponseClient | ||
import org.springframework.security.oauth2.client.registration.ClientRegistration | ||
import org.springframework.security.oauth2.client.registration.ClientRegistrationRepository | ||
import org.springframework.security.oauth2.jwt.JwtDecoderFactory | ||
import org.springframework.security.web.SecurityFilterChain | ||
import org.springframework.test.context.ActiveProfiles | ||
import uk.gov.communities.prsdb.webapp.TestcontainersConfiguration | ||
import uk.gov.communities.prsdb.webapp.config.OneLoginConfig | ||
|
||
@Import(TestcontainersConfiguration::class) | ||
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) | ||
@UsePlaywright | ||
@ActiveProfiles("INTEGRATION_TEST") | ||
abstract class IntegrationTest { | ||
@LocalServerPort | ||
val port: Int = 0 | ||
|
||
@MockBean | ||
lateinit var mockClientRegistrationRepository: ClientRegistrationRepository | ||
|
||
@MockBean | ||
lateinit var mockDefaultAuthorizationCodeTokenResponseClient: DefaultAuthorizationCodeTokenResponseClient | ||
|
||
@MockBean | ||
lateinit var jwtDecoderFactory: JwtDecoderFactory<ClientRegistration?> | ||
|
||
@MockBean | ||
lateinit var oneLoginConfig: OneLoginConfig | ||
|
||
@MockBean | ||
lateinit var securityFilterChain: SecurityFilterChain | ||
} |
14 changes: 14 additions & 0 deletions
14
src/test/kotlin/uk/gov/communities/prsdb/webapp/integration/RegisterHomePageTests.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,14 @@ | ||
package uk.gov.communities.prsdb.webapp.integration | ||
|
||
import com.microsoft.playwright.Page | ||
import com.microsoft.playwright.assertions.PlaywrightAssertions.assertThat | ||
import com.microsoft.playwright.options.AriaRole | ||
import org.junit.jupiter.api.Test | ||
|
||
class RegisterHomePageTests : IntegrationTest() { | ||
@Test | ||
fun `register a home to rent page renders`(page: Page) { | ||
page.navigate("http://localhost:$port/registration") | ||
assertThat(page.getByRole(AriaRole.HEADING)).containsText("Register a home to rent") | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
src/test/kotlin/uk/gov/communities/prsdb/webapp/integration/SearchRegisterPageTests.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,14 @@ | ||
package uk.gov.communities.prsdb.webapp.integration | ||
|
||
import com.microsoft.playwright.Page | ||
import com.microsoft.playwright.assertions.PlaywrightAssertions.assertThat | ||
import com.microsoft.playwright.options.AriaRole | ||
import org.junit.jupiter.api.Test | ||
|
||
class SearchRegisterPageTests : IntegrationTest() { | ||
@Test | ||
fun `search for private rented sector information page renders`(page: Page) { | ||
page.navigate("http://localhost:$port/search") | ||
assertThat(page.getByRole(AriaRole.HEADING)).containsText("Search for Private Rented Sector information") | ||
} | ||
} |