From 0bbf8be4bc22171bac45d96058e5beaa24823ac5 Mon Sep 17 00:00:00 2001 From: huanglii Date: Thu, 26 Sep 2024 16:07:11 +0800 Subject: [PATCH] Add a test that adds a source --- cypress/e2e/modals.cy.ts | 20 +++++++++++++++++++- src/components/ModalSources.tsx | 3 +++ src/components/ModalSourcesTypeEditor.tsx | 1 + 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/cypress/e2e/modals.cy.ts b/cypress/e2e/modals.cy.ts index ec3e4d77..3c260856 100644 --- a/cypress/e2e/modals.cy.ts +++ b/cypress/e2e/modals.cy.ts @@ -61,9 +61,27 @@ describe("modals", () => { }); describe("sources", () => { + beforeEach(() => { + when.setStyle("layer"); + when.click("nav:sources"); + }); + it("active sources"); it("public source"); - it("add new source"); + + it("add new source", () => { + let sourceId = "n1z2v3r"; + when.setValue("modal:sources.add.source_id", sourceId); + when.select("modal:sources.add.source_type", "tile_vector"); + when.select("modal:sources.add.scheme_type", "tms"); + when.click("modal:sources.add.add_source"); + when.wait(200); + then( + get.styleFromLocalStorage().then((style) => style.sources[sourceId]) + ).shouldInclude({ + scheme: "tms", + }); + }); }); describe("inspect", () => { diff --git a/src/components/ModalSources.tsx b/src/components/ModalSources.tsx index efc5d816..6884e57e 100644 --- a/src/components/ModalSources.tsx +++ b/src/components/ModalSources.tsx @@ -224,6 +224,7 @@ class AddSource extends React.Component { fieldSpec={{doc: t("Unique ID that identifies the source and is used in the layer to reference the source.")}} value={this.state.sourceId} onChange={(v: string) => this.setState({ sourceId: v})} + data-wd-key="modal:sources.add.source_id" /> { ]} onChange={mode => this.setState({mode: mode as EditorMode, source: this.defaultSource(mode as EditorMode)})} value={this.state.mode as string} + data-wd-key="modal:sources.add.source_type" /> { {t("Add Source")} diff --git a/src/components/ModalSourcesTypeEditor.tsx b/src/components/ModalSourcesTypeEditor.tsx index c43234ea..bc1944bb 100644 --- a/src/components/ModalSourcesTypeEditor.tsx +++ b/src/components/ModalSourcesTypeEditor.tsx @@ -86,6 +86,7 @@ class TileURLSourceEditor extends React.Component { scheme })} value={this.props.source.scheme} + data-wd-key="modal:sources.add.scheme_type" />