diff --git a/tests/data/pipeline_before_feb_fields.geojson b/tests/data/pipeline_before_feb_fields.geojson new file mode 100644 index 000000000..c205f46b7 --- /dev/null +++ b/tests/data/pipeline_before_feb_fields.geojson @@ -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" +} diff --git a/tests/pipeline.spec.ts b/tests/pipeline.spec.ts index bf3a6e472..0813b6c98 100644 --- a/tests/pipeline.spec.ts +++ b/tests/pipeline.spec.ts @@ -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, + }), + }), + ); +});