Skip to content

Commit

Permalink
Verify new form with a test
Browse files Browse the repository at this point in the history
  • Loading branch information
dabreegster committed Feb 15, 2024
1 parent 9dc5bae commit cc569ea
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 0 deletions.
50 changes: 50 additions & 0 deletions tests/data/pipeline_before_feb_fields.geojson
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"properties": {
"scheme_reference": "bb649a68-5fc0-423a-b679-25dc43a8d020",
"intervention_type": "other",
"pipeline": {
"atf4_type": "",
"accuracy": "",
"is_alternative": false
},
"is_coverage_polygon": false,
"name": "POI"
},
"geometry": {
"type": "Point",
"coordinates": [-0.3140953, 50.8386259]
},
"id": 1
}
],
"schemes": {
"bb649a68-5fc0-423a-b679-25dc43a8d020": {
"scheme_reference": "bb649a68-5fc0-423a-b679-25dc43a8d020",
"color": "#377eb8",
"pipeline": {
"scheme_type": "",
"atf4_lead_type": "",
"scheme_description": "",
"status": "",
"timescale": "",
"development_funded": false,
"construction_funded": false,
"funding_sources": {
"atf2": false,
"atf3": false,
"atf4": false,
"atf4e": false,
"crsts": false,
"luf": false,
"other": ""
}
}
}
},
"authority": "LAD_Adur",
"origin": "atip-v2"
}
29 changes: 29 additions & 0 deletions tests/pipeline.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,3 +96,32 @@ test("file started with v1 can be edited by loading", async () => {
await page.getByRole("button", { name: "Scheme details" }).click();
await page.getByText("Shared-use route").click();
});

// Check compatibility of old files with new per-feature fields introduced 14 February 2024
test("file without new budget/timing forms can be edited by loading", async () => {
await page.getByText("Manage files").click();
await page
.getByLabel("Load GeoJSON file")
.setInputFiles("tests/data/pipeline_before_feb_fields.geojson");

await page.getByRole("link", { name: "POI" }).click();
await page.getByLabel("Cost (GBP)").fill("1.2");
await page.getByRole("button", { name: "multiply by 1 million" }).click();
await page.getByText("Is the construction fully funded?").check();
await page.getByText("CRSTS").check();
await page.getByRole("button", { name: "Save" }).click();

// Check the data in local storage
let json = await getLocalStorage(page, "LAD_Adur_pipeline");
let feature = json.features[0] as any;
expect(feature.properties.name).toEqual("POI");
expect(feature.properties.pipeline).toEqual(
expect.objectContaining({
budget: 1_200_000,
construction_funded: true,
funding_sources: expect.objectContaining({
crsts: true,
}),
}),
);
});

0 comments on commit cc569ea

Please sign in to comment.