From 59acd1b3e70199b573d18ab791207cb5daa89b9d Mon Sep 17 00:00:00 2001 From: Pirmin Kalberer Date: Sun, 29 Dec 2024 00:03:55 +0100 Subject: [PATCH] Add pmtiles source test --- cypress/e2e/modals.cy.ts | 14 ++++++++++++++ src/components/ModalSourcesTypeEditor.tsx | 1 + 2 files changed, 15 insertions(+) diff --git a/cypress/e2e/modals.cy.ts b/cypress/e2e/modals.cy.ts index aade75fe..5eeb0c69 100644 --- a/cypress/e2e/modals.cy.ts +++ b/cypress/e2e/modals.cy.ts @@ -83,6 +83,20 @@ describe("modals", () => { }); }); + it("add new pmtiles source", () => { + let sourceId = "pmtilestest"; + when.setValue("modal:sources.add.source_id", sourceId); + when.select("modal:sources.add.source_type", "pmtiles_vector"); + when.setValue("modal:sources.add.source_url", "https://pmtiles.io/stamen_toner(raster)CC-BY+ODbL_z3.pmtiles"); + when.click("modal:sources.add.add_source"); + when.wait(200); + then( + get.styleFromLocalStorage().then((style) => style.sources[sourceId]) + ).shouldInclude({ + url: "pmtiles://https://pmtiles.io/stamen_toner(raster)CC-BY+ODbL_z3.pmtiles", + }); + }); + it("add new raster source", () => { let sourceId = "rastertest"; when.setValue("modal:sources.add.source_id", sourceId); diff --git a/src/components/ModalSourcesTypeEditor.tsx b/src/components/ModalSourcesTypeEditor.tsx index 2c9a1492..20fd9fa6 100644 --- a/src/components/ModalSourcesTypeEditor.tsx +++ b/src/components/ModalSourcesTypeEditor.tsx @@ -302,6 +302,7 @@ class PMTilesSourceEditor extends React.Component { label={t("PMTiles URL")} fieldSpec={latest.source_vector.url} value={this.props.source.url} + data-wd-key="modal:sources.add.source_url" onChange={(url: string) => this.props.onChange({ ...this.props.source, url: url.startsWith("pmtiles://") ? url : `pmtiles://${url}`