-
Notifications
You must be signed in to change notification settings - Fork 2
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: E2E Testing for Planning Constraints #4063
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
c083dbb
add in mock data
RODO94 a25f5f5
setup mocks for network intercepts
RODO94 26a3a80
add checks up to the first constraint displaying for listed building
RODO94 680a1b2
lint:fix
RODO94 ac3314d
add extra request checks
RODO94 a27c02f
add geoSpatial user actions
RODO94 56e8cc0
refine data mocks
RODO94 1d0f807
refine imports and mock naming
RODO94 717eeaf
fix answerFindProp
RODO94 e371275
add true includes to gis request url check
RODO94 a43684e
add changes from comments
RODO94 236b043
refine prop constraints response
RODO94 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { expect, Page } from "@playwright/test"; | ||
import { setupOSMockResponse } from "../mocks/osPlacesResponse"; | ||
|
||
export async function answerFindProperty(page: Page) { | ||
await setupOSMockResponse(page); | ||
await page.getByLabel("Postcode").fill("SW1 1AA"); | ||
await page.getByLabel("Select an address").click(); | ||
await page.getByRole("option").first().click(); | ||
} | ||
|
||
export const userChallengesPlanningConstraint = async (page: Page) => { | ||
const thisDoesNotApplyConstraintButton = page.getByRole("button", { | ||
name: "I don't think this constraint applies to this property", | ||
}); | ||
|
||
await thisDoesNotApplyConstraintButton.click(); | ||
|
||
const constraintDoesNotApplyDialog = page.getByRole("heading", { | ||
name: "I don't think this constraint applies to this property", | ||
}); | ||
await constraintDoesNotApplyDialog.isVisible(); | ||
|
||
const noAddressSuppliedButton = page.getByTestId("entity-checkbox-42103309"); | ||
await noAddressSuppliedButton.click(); | ||
|
||
const tellUsWhyText = page.getByRole("textbox"); | ||
await tellUsWhyText.fill("This is the reason why"); | ||
|
||
const submitConstraintChallenge = page.getByTestId( | ||
"override-modal-submit-button", | ||
); | ||
await submitConstraintChallenge.click(); | ||
|
||
await expect( | ||
page.getByTestId("error-message-checklist-error-inaccurate-entities"), | ||
).toBeHidden(); | ||
await expect( | ||
page.getByTestId("error-message-input-error-inaccurate-entities"), | ||
).toBeHidden(); | ||
}; |
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 |
---|---|---|
@@ -1,6 +1,5 @@ | ||
import type { Locator, Page } from "@playwright/test"; | ||
import { expect } from "@playwright/test"; | ||
import { setupOSMockResponse } from "../mocks/osPlacesResponse"; | ||
import { findSessionId, getGraphQLClient } from "./context"; | ||
import { TEST_EMAIL, log, waitForDebugLog } from "./globalHelpers"; | ||
import { TestContext } from "./types"; | ||
|
@@ -194,13 +193,6 @@ export async function submitCardDetails(page: Page) { | |
await page.locator("#confirm").click(); | ||
} | ||
|
||
export async function answerFindProperty(page: Page) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Moved this to a separate |
||
await setupOSMockResponse(page); | ||
await page.getByLabel("Postcode").fill("SW1 1AA"); | ||
await page.getByLabel("Select an address").click(); | ||
await page.getByRole("option").first().click(); | ||
} | ||
|
||
export async function answerContactInput( | ||
page: Page, | ||
{ | ||
|
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 |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { expect, Page } from "@playwright/test"; | ||
import { mockRoadData } from "./geospatialMocks"; | ||
import propertyConstraintsResponse from "./propertyConstraintResponse.json"; | ||
|
||
export async function setupGISMockResponse(page: Page) { | ||
const gisDigitalLandEndpoint = "**/gis/E2E?geom*"; | ||
await page.route(gisDigitalLandEndpoint, async (route, request) => { | ||
const urlContainsConstraints = checkGISMockRequestUrl(request.url()); | ||
expect(urlContainsConstraints).toEqual(true); | ||
await route.fulfill({ | ||
status: 200, | ||
body: JSON.stringify(propertyConstraintsResponse), | ||
}); | ||
}); | ||
} | ||
|
||
export function checkGISMockRequestUrl(url: string) { | ||
const splitUrl = url.split("/").pop()?.split("%2C"); | ||
return ( | ||
!splitUrl?.includes("designated.conservationArea") && | ||
splitUrl?.includes("listed") | ||
); | ||
} | ||
|
||
export async function setupRoadsMockResponse(page: Page) { | ||
const gisRoadsEndpoint = new RegExp(/\/roads\?.*/); | ||
await page.route(gisRoadsEndpoint, async (route) => { | ||
await route.fulfill({ | ||
status: 200, | ||
body: JSON.stringify(mockRoadData), | ||
}); | ||
}); | ||
} | ||
|
||
export const planningConstraintHeadersMock = [ | ||
"Planning constraints", | ||
"These are the planning constraints we think apply to this property", | ||
"Heritage and conservation", | ||
"General policy", | ||
"Heritage and conservation", | ||
"Flooding", | ||
"Ecology", | ||
"Trees", | ||
]; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
question: should this rather sit in a unit test?