From c786336dcc3264dd8e8f223eadcc875f593919c8 Mon Sep 17 00:00:00 2001 From: bruehlca Date: Tue, 16 Jun 2026 16:55:06 +0200 Subject: [PATCH 1/6] update documentation --- GeoFilter/doc/config.json.md | 13 ++++++------- WfstUploader/doc/config.json.md | 16 +++++++++++++--- exporter/doc/config.json.md | 16 +++++++++++++++- importer/doc/config.json.md | 8 +++++--- 4 files changed, 39 insertions(+), 14 deletions(-) diff --git a/GeoFilter/doc/config.json.md b/GeoFilter/doc/config.json.md index 0c587e1..cfb4cef 100644 --- a/GeoFilter/doc/config.json.md +++ b/GeoFilter/doc/config.json.md @@ -1,19 +1,18 @@ #### Portalconfig.menu.tool.geoFilter The geofilter allows to filter a WFS Layer (target layer) with another layer, WFS or imported, that contains polygon features (filter layer). As a result all features that lie within or intersect the polygons on the filter layer will be returned on a new layer. The name of the new layer can be configured under `highlightedFeatures.layerName` (**[highlightedFeatures](#portalconfigtreehighlightedfeatures)**). -To use Imported layers the importerAddon for the v3 has to be configured as well (to be found here: https://github.com/terrestris/masterportal-addons/tree/main). - - +This addon uses the importer and exporter addon which must be configured as well to use the geoFilter addon. They can be found here https://github.com/terrestris/masterportal-addons/tree/main. The importer addon configuration should include geojson, shapezip and/or geopackage as supported import formats. WMS and WFS will be not useful in this context. |Name|Required|Type|Default|Description|Expert| |----|--------|----|-------|-----------|------| -|name|no|string|additional:modules.tools.geoFilter.title|Will be displayed as name for the addon|false| |description|no|string|additional:modules.tools.geoFilter.description|Will be displayed as description for the addon|false| -|targetLayerIds|no|Array|[]|List of layer ids of layers that can be used as target layers.|false| |filterLayerTypes|no|Array|["GeoJSON", "WFS"]|List of layer types that can be used as filter layers.|false| +|icon|no|string|bi-filter|CSS class of the Bootstrap Icon. Will be displayed in front of the tool name.|false| +|name|no|string|additional:modules.tools.geoFilter.title|Will be displayed as name for the addon|false| +|targetLayerIds|no|Array|[]|List of layer ids of layers that can be used as target layers.|false| +|type|yes|string||ID of the addon|false| - - +**Example:** ```json { diff --git a/WfstUploader/doc/config.json.md b/WfstUploader/doc/config.json.md index a2ab6d7..f61aa78 100644 --- a/WfstUploader/doc/config.json.md +++ b/WfstUploader/doc/config.json.md @@ -1,15 +1,25 @@ #### Portalconfig.menu.tool.wfstUploader +Addon that enables user to upload features on configured wfst layer by selecting features from vector layers. Intended use case is to upload features from imported geopackages or shapefile, so the importer addon is integrated in this addon and must be configured as well. +The importer addon can be found here https://github.com/terrestris/masterportal-addons/tree/main. The importer addon configuration should include geojson, shapezip and/or geopackage as supported import formats. WMS and WFS will be not useful in this context. |Name|Required|Type|Default|Description|Expert| |----|--------|----|-------|-----------|------| -||||||| - +|description|no|string|additional:modules.tools.wfstUploader.description|Will be displayed as description for the addon|false| +|icon|no|string|bi-upload|CSS class of the Bootstrap Icon. Will be displayed in front of the tool name.|false| +|name|no|string|additional:modules.tools.wfstUploader.title|Will be displayed as name for the addon|false| +|type|yes|string||ID of the addon|false| +|wfstLayers|yes||List of wfst layers that can be chosen for a feature upload|false| +**Example:** ```json { - + "type": "wfstUploader", + "name": "Neues Objekt hochladen", + "description": "Speichern von hochgeladenen Geometrien als Objekte", + "wfstLayers": ["ensemble_elemente", "fundplatz_elemente", "polygon_wfst"], + "wfstAttributesForInput": ["kategorie", "uuid"] } ``` \ No newline at end of file diff --git a/exporter/doc/config.json.md b/exporter/doc/config.json.md index 6c1f2e3..d011a8f 100644 --- a/exporter/doc/config.json.md +++ b/exporter/doc/config.json.md @@ -6,5 +6,19 @@ The basic tool configurations apply. Following additional properties can be set |Name|Required|Type|Default|Description|Expert| |----|--------|----|-------|-----------|------| -|supportedExportFormats|no|String[]|["geojson", "gml", "shp", "gpkg"]|List of supported export formats. Only formats that appear in this list will be provided as option. Currently supported formats: "geojson", "gml", "shp", "gpkg".|false| |downloadProjection|no|String|"EPSG:4326"|Optional projection mode used only for "shp" and "gpkg" download output. Supported values: "mapProjection" and "EPSG:4326". If omitted or invalid, EPSG:4326 is used.|false| +|icon|no|string|bi-download|CSS class of the Bootstrap Icon. Will be displayed in front of the tool name.|false| +|name|no|string|additional:modules.tools.exporter.title|Will be displayed as name for the addon|false| +|supportedExportFormats|no|String[]|["geojson", "gml", "shp", "gpkg"]|List of supported export formats. Only formats that appear in this list will be provided as option. Currently supported formats: "geojson", "gml", "shp", "gpkg".|false| +|type|yes|string||ID of the addon|false| + +**Example:** + +```json +{ + "type": "exporter", + "downloadProjection": "mapProjection", + "name":"additional:modules.tools.exporter.title", + "icon":"bi-download" +} +``` diff --git a/importer/doc/config.json.md b/importer/doc/config.json.md index 8d385d6..bd44a97 100644 --- a/importer/doc/config.json.md +++ b/importer/doc/config.json.md @@ -6,14 +6,16 @@ The basic tool configurations apply. Following additional properties can be set |Name|Required|Type|Default|Description|Expert| |----|--------|----|-------|-----------|------| +|fileUploadIcon|no|String|bi bi-cloud-arrow-up-fill|Icon library string for the file upload icon|false| +|icon|no|string|bi-upload|CSS class of the Bootstrap Icon. Will be displayed in front of the tool name.|false| +|name|no|string|additional:modules.tools.importer.title|Will be displayed as name for the addon|false| +|removeFileIcon|no|String|bi bi-x-circle-fill|Icon library string for the remove file icon|false| |styleFillColor|no|Array|[104, 170, 204, 1]|The RGBA color to use as default fill color|false| |styleStrokeColor|no|Array|[153, 153, 153, 1]|The RGBA color to use as default stroke color|false| |styleStrokeWidth|no|Array|5|The width in pixels to use as default stroke width|false| |styleCircleRadius|no|Array|10|The radius in pixels to use as default circle radius|false| |supportedImportWorkflows|no|Array|["wfs", "wms", "geojson", "shapezip", "geopackage"]|The supported workflows/formats that will be provided as import options.|false| -|fileUploadIcon|no|String|bi bi-cloud-arrow-up-fill|Icon library string for the file upload icon|false| -|removeFileIcon|no|String|bi bi-x-circle-fill|Icon library string for the remove file icon|false| - +|type|yes|string||ID of the addon|false| **Example:** From 51c6632c4a73e4b6dc785e4dc21d8b8cc859b107 Mon Sep 17 00:00:00 2001 From: bruehlca Date: Tue, 16 Jun 2026 17:15:21 +0200 Subject: [PATCH 2/6] add license files --- GeoFilter/LICENSE | 21 +++++++++++++++++++++ WfstUploader/LICENSE | 21 +++++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 GeoFilter/LICENSE create mode 100644 WfstUploader/LICENSE diff --git a/GeoFilter/LICENSE b/GeoFilter/LICENSE new file mode 100644 index 0000000..032753a --- /dev/null +++ b/GeoFilter/LICENSE @@ -0,0 +1,21 @@ +The MIT License + +Copyright (c) 2026 Dataport AöR + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. \ No newline at end of file diff --git a/WfstUploader/LICENSE b/WfstUploader/LICENSE new file mode 100644 index 0000000..032753a --- /dev/null +++ b/WfstUploader/LICENSE @@ -0,0 +1,21 @@ +The MIT License + +Copyright (c) 2026 Dataport AöR + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. \ No newline at end of file From ad54a134236f67a328ecb8758f0555778d9ce89d Mon Sep 17 00:00:00 2001 From: bruehlca Date: Wed, 17 Jun 2026 12:40:28 +0200 Subject: [PATCH 3/6] add url parameters to documentation --- WfstUploader/doc/config.json.md | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/WfstUploader/doc/config.json.md b/WfstUploader/doc/config.json.md index f61aa78..7133af3 100644 --- a/WfstUploader/doc/config.json.md +++ b/WfstUploader/doc/config.json.md @@ -22,4 +22,14 @@ The importer addon can be found here https://github.com/terrestris/masterportal- "wfstAttributesForInput": ["kategorie", "uuid"] } -``` \ No newline at end of file +``` + +**URL Parameters** + +Some parameters can be preset for this addon via the URL. + +|Name|Description|Example| +|-|-|-| +|UPLOADLAYERID|The id of the layer that should be preset as upload layer in the input formular. The upload layer must be visible in the portal. |`&UPLOADLAYERID=layer_id`| +|UUIDPROPERTY|The identifier attribute name for the feature that will be uploaded. If not set, "uuid" will be assumed as property name.|`&UUIDPROPERTY=UUID`| +|UUID|The value that will be set as preset for the uuid property in the input field.|`&UUIDVALUE=123-abc-456`| \ No newline at end of file From eb333a0eecbdf678566e4bdadbb43aa2fdad2835 Mon Sep 17 00:00:00 2001 From: bruehlca Date: Wed, 17 Jun 2026 12:41:12 +0200 Subject: [PATCH 4/6] enable other uuid property names as url parameter --- WfstUploader/components/WfstUploader.vue | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/WfstUploader/components/WfstUploader.vue b/WfstUploader/components/WfstUploader.vue index f4984b7..4dee31b 100644 --- a/WfstUploader/components/WfstUploader.vue +++ b/WfstUploader/components/WfstUploader.vue @@ -132,8 +132,10 @@ export default { properties = await wfs.receivePossibleProperties(url, version, featureType, isSecured ?? false); if (Array.isArray(properties)) { + const uuidProp = this.getUrlParamValue("UUIDPROPERTY") || "uuid"; + properties.forEach((propertie) => { - if (propertie.key === "uuid") { + if (propertie.key === uuidProp) { propertie.value = this.uuid || propertie.value; } }); @@ -197,7 +199,7 @@ export default { const params = new URL(location).searchParams, keyName = Array.from(params.keys()).find((key) => key.toLowerCase() === paramName.toLowerCase()); - return params.get(keyName); + return keyName ? params.get(keyName) : null; }, getUuid () { return this.getUrlParamValue("UUID"); From de224c8c601e0262c3e340c28298d7dd91134d85 Mon Sep 17 00:00:00 2001 From: bruehlca Date: Wed, 17 Jun 2026 12:41:45 +0200 Subject: [PATCH 5/6] fix spelling --- WfstUploader/components/WfstUploader.vue | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/WfstUploader/components/WfstUploader.vue b/WfstUploader/components/WfstUploader.vue index 4dee31b..ac68cd0 100644 --- a/WfstUploader/components/WfstUploader.vue +++ b/WfstUploader/components/WfstUploader.vue @@ -134,9 +134,9 @@ export default { if (Array.isArray(properties)) { const uuidProp = this.getUrlParamValue("UUIDPROPERTY") || "uuid"; - properties.forEach((propertie) => { - if (propertie.key === uuidProp) { - propertie.value = this.uuid || propertie.value; + properties.forEach((property) => { + if (property.key === uuidProp) { + property.value = this.uuid || property.value; } }); } From e7d5e324876b5f32da919581fb92d76099544e39 Mon Sep 17 00:00:00 2001 From: bruehlca Date: Wed, 24 Jun 2026 08:30:07 +0200 Subject: [PATCH 6/6] add tests to importer and exporter --- .../unit/components/ExporterAddon.spec.js | 221 ++++++++++++++++++ .../unit/store/actionsExporterAddon.spec.js | 8 + .../unit/store/gettersExporterAddon.spec.js | 8 + .../unit/store/mutationsExporterAddon.spec.js | 8 + .../unit/components/ImporterAddon.spec.js | 183 +++++++++++++++ .../unit/store/actionsImporterAddon.spec.js | 8 + .../unit/store/gettersImporterAddon.spec.js | 8 + .../unit/store/mutationsImporterAddon.spec.js | 8 + 8 files changed, 452 insertions(+) diff --git a/exporter/tests/unit/components/ExporterAddon.spec.js b/exporter/tests/unit/components/ExporterAddon.spec.js index e69de29..15c44f0 100644 --- a/exporter/tests/unit/components/ExporterAddon.spec.js +++ b/exporter/tests/unit/components/ExporterAddon.spec.js @@ -0,0 +1,221 @@ +import {createStore} from "vuex"; +import {expect} from "chai"; +import sinon from "sinon"; +import {shallowMount} from "@vue/test-utils"; +import ExporterAddon from "../../../components/ExporterAddon.vue"; +import ExporterStore from "../../../store/ExporterAddon.js"; +import {DEFAULT_VALUES} from "../../../store/stateExporterAddon.js"; +import STEPS from "../../../constants/steps.js"; +import * as downloadModule from "../../../utils/download.js"; + +describe("addons/exporter/components/ExporterAddon.vue", () => { + let store, wrapper; + + /** + * Helper function to create a wrapper with optional store overrides. + * + * @param {Object} storeOverrides Additional state values to override defaults. + * @returns {VueWrapper} Mounted component wrapper. + */ + function createWrapper (storeOverrides = {}) { + store = createStore({ + modules: { + Modules: { + namespaced: true, + modules: { + Exporter: { + ...ExporterStore, + state: { + ...ExporterStore.state, + ...DEFAULT_VALUES, + active: true, + ...storeOverrides + } + } + } + }, + Alerting: { + namespaced: true, + actions: { + addSingleAlert: sinon.stub() + } + } + } + }); + + return shallowMount(ExporterAddon, { + global: { + plugins: [store], + mocks: { + $t: key => key + } + } + }); + } + + afterEach(() => { + if (wrapper) { + wrapper.unmount(); + } + sinon.restore(); + }); + + describe("rendering", () => { + it("renders the exporter root element", () => { + wrapper = createWrapper(); + expect(wrapper.find("#exporter").exists()).to.be.true; + }); + + it("shows loading text and hides content when isLoading is true", async () => { + wrapper = createWrapper(); + await wrapper.setData({isLoading: true}); + expect(wrapper.text()).to.include("additional:modules.tools.exporter.loadingText"); + expect(wrapper.find(".exporter-addon-wizard-content").exists()).to.be.false; + }); + + it("shows LayerSelection on selectLayer step", () => { + wrapper = createWrapper({currentStep: STEPS.selectLayer}); + expect(wrapper.findComponent({name: "LayerSelection"}).exists()).to.be.true; + }); + + it("shows LayerDownloadOptions on downloadLayer step", () => { + wrapper = createWrapper({currentStep: STEPS.downloadLayer}); + expect(wrapper.findComponent({name: "LayerDownloadOptions"}).exists()).to.be.true; + }); + + it("shows next button when not on last step", () => { + wrapper = createWrapper({currentStep: STEPS.selectLayer}); + const buttons = wrapper.findAllComponents({name: "FlatButton"}); + const texts = buttons.map(b => b.props("text")); + + expect(texts).to.include("additional:modules.tools.exporter.next"); + }); + + it("shows finish button on last step", () => { + wrapper = createWrapper({currentStep: STEPS.downloadLayer}); + const buttons = wrapper.findAllComponents({name: "FlatButton"}); + const texts = buttons.map(b => b.props("text")); + + expect(texts).to.include("additional:modules.tools.exporter.finish"); + }); + + it("hides prev button on first step", () => { + wrapper = createWrapper({currentStep: STEPS.selectLayer}); + const buttons = wrapper.findAllComponents({name: "FlatButton"}); + const texts = buttons.map(b => b.props("text")); + + expect(texts).to.not.include("additional:modules.tools.exporter.prev"); + }); + + it("shows prev button on second step", () => { + wrapper = createWrapper({currentStep: STEPS.downloadLayer}); + const buttons = wrapper.findAllComponents({name: "FlatButton"}); + const texts = buttons.map(b => b.props("text")); + + expect(texts).to.include("additional:modules.tools.exporter.prev"); + }); + }); + + describe("onNextClick", () => { + it("advances to downloadLayer step", async () => { + wrapper = createWrapper({currentStep: STEPS.selectLayer, currentFormValid: true}); + await wrapper.vm.onNextClick(); + expect(wrapper.vm.currentStep).to.equal(STEPS.downloadLayer); + }); + }); + + describe("onPrevClick", () => { + it("goes back to selectLayer step", async () => { + wrapper = createWrapper({currentStep: STEPS.downloadLayer}); + await wrapper.vm.onPrevClick(); + expect(wrapper.vm.currentStep).to.equal(STEPS.selectLayer); + }); + }); + + describe("onFinishClick", () => { + it("executes download, manages loading state, and calls callback", async () => { + let resolveDownload; + + sinon.stub(downloadModule, "downloadLayer").returns( + new Promise(resolve => { + resolveDownload = resolve; + }) + ); + const onExportFinished = sinon.stub(); + + wrapper = createWrapper({ + currentStep: STEPS.downloadLayer, + selectedLayer: {id: "layer1"}, + selectedExportFormat: "geoJson", + downloadProjection: "EPSG:4326", + onExportFinished + }); + + const finishPromise = wrapper.vm.onFinishClick(); + + // Verify loading state starts + expect(wrapper.vm.isLoading).to.be.true; + + resolveDownload(); + await finishPromise; + + // Verify loading state ends and callbacks executed + expect(wrapper.vm.isLoading).to.be.false; + expect(onExportFinished.calledOnce).to.be.true; + expect(wrapper.vm.active).to.be.false; + }); + + it("dispatches alert on download error", async () => { + const error = new Error("download failed"); + + sinon.stub(downloadModule, "downloadLayer").rejects(error); + global.i18next = {t: key => key}; + + const addSingleAlertStub = sinon.stub(); + + store = createStore({ + modules: { + Modules: { + namespaced: true, + modules: { + Exporter: { + ...ExporterStore, + state: { + ...ExporterStore.state, + ...DEFAULT_VALUES, + active: true, + currentStep: STEPS.downloadLayer + } + } + } + }, + Alerting: { + namespaced: true, + actions: { + addSingleAlert: addSingleAlertStub + } + } + } + }); + + wrapper = shallowMount(ExporterAddon, { + global: { + plugins: [store], + mocks: {$t: key => key} + } + }); + + await wrapper.vm.onFinishClick(); + + expect(addSingleAlertStub.calledOnce).to.be.true; + }); + }); + + describe("close", () => { + it("sets active to false when close is called", () => { + wrapper = createWrapper(); + wrapper.vm.close(); + expect(wrapper.vm.active).to.be.false; + }); + }); +}); diff --git a/exporter/tests/unit/store/actionsExporterAddon.spec.js b/exporter/tests/unit/store/actionsExporterAddon.spec.js index e69de29..62b8cef 100644 --- a/exporter/tests/unit/store/actionsExporterAddon.spec.js +++ b/exporter/tests/unit/store/actionsExporterAddon.spec.js @@ -0,0 +1,8 @@ +import {expect} from "chai"; +import actions from "../../../store/actionsExporterAddon.js"; + +describe("addons/exporter/store/actionsExporterAddon.js", () => { + it("exports actions object", () => { + expect(actions).to.be.an("object"); + }); +}); diff --git a/exporter/tests/unit/store/gettersExporterAddon.spec.js b/exporter/tests/unit/store/gettersExporterAddon.spec.js index e69de29..b55581a 100644 --- a/exporter/tests/unit/store/gettersExporterAddon.spec.js +++ b/exporter/tests/unit/store/gettersExporterAddon.spec.js @@ -0,0 +1,8 @@ +import {expect} from "chai"; +import getters from "../../../store/gettersExporterAddon.js"; + +describe("addons/exporter/store/gettersExporterAddon.js", () => { + it("exports getters object", () => { + expect(getters).to.be.an("object"); + }); +}); diff --git a/exporter/tests/unit/store/mutationsExporterAddon.spec.js b/exporter/tests/unit/store/mutationsExporterAddon.spec.js index e69de29..0454f5f 100644 --- a/exporter/tests/unit/store/mutationsExporterAddon.spec.js +++ b/exporter/tests/unit/store/mutationsExporterAddon.spec.js @@ -0,0 +1,8 @@ +import {expect} from "chai"; +import mutations from "../../../store/mutationsExporterAddon.js"; + +describe("addons/exporter/store/mutationsExporterAddon.js", () => { + it("exports mutations object", () => { + expect(mutations).to.be.an("object"); + }); +}); diff --git a/importer/tests/unit/components/ImporterAddon.spec.js b/importer/tests/unit/components/ImporterAddon.spec.js index e69de29..2757ef7 100644 --- a/importer/tests/unit/components/ImporterAddon.spec.js +++ b/importer/tests/unit/components/ImporterAddon.spec.js @@ -0,0 +1,183 @@ +import {createStore} from "vuex"; +import {expect} from "chai"; +import sinon from "sinon"; +import {shallowMount} from "@vue/test-utils"; +import ImporterAddon from "../../../components/ImporterAddon.vue"; +import ImporterStore from "../../../store/ImporterAddon.js"; +import {DEFAULT_VALUES} from "../../../store/stateImporterAddon.js"; +import STEPS from "../../../constants/steps.js"; + +describe("addons/importer/components/ImporterAddon.vue", () => { + let store, wrapper; + + /** + * Helper function to create a wrapper with optional store overrides. + * + * @param {Object} storeOverrides Additional state values to override defaults. + * @returns {VueWrapper} Mounted component wrapper. + */ + function createWrapper (storeOverrides = {}) { + store = createStore({ + modules: { + Modules: { + namespaced: true, + modules: { + Importer: { + ...ImporterStore, + state: { + ...ImporterStore.state, + ...DEFAULT_VALUES, + active: true, + ...storeOverrides + } + } + } + }, + Alerting: { + namespaced: true, + actions: { + addSingleAlert: sinon.stub() + } + }, + Menu: { + namespaced: true, + getters: { + mainMenu: () => ({sections: []}), + secondaryMenu: () => ({sections: []}) + }, + actions: { + resetMenu: sinon.stub() + } + } + }, + actions: { + addLayerToLayerConfig: sinon.stub() + } + }); + + return shallowMount(ImporterAddon, { + global: { + plugins: [store], + mocks: { + $t: key => key + } + } + }); + } + + afterEach(() => { + if (wrapper) { + wrapper.unmount(); + } + sinon.restore(); + }); + + describe("rendering", () => { + it("renders the importer root element", () => { + wrapper = createWrapper(); + expect(wrapper.find("#importer").exists()).to.be.true; + }); + + it("shows WorkflowSelection when workflow is undefined", () => { + wrapper = createWrapper({currentWorkflow: undefined}); + expect(wrapper.findComponent({name: "WorkflowSelection"}).exists()).to.be.true; + }); + + it("shows ProvideOgcService on provideOgcService step", () => { + wrapper = createWrapper({ + currentWorkflow: "wms", + currentStep: STEPS.provideOgcService + }); + expect(wrapper.findComponent({name: "ProvideOgcService"}).exists()).to.be.true; + }); + + it("shows LayerSelection on selectLayers step", () => { + wrapper = createWrapper({ + currentWorkflow: "wms", + currentStep: STEPS.selectLayers + }); + expect(wrapper.findComponent({name: "LayerSelection"}).exists()).to.be.true; + }); + + it("shows FileUpload on uploadFile step", () => { + wrapper = createWrapper({ + currentWorkflow: "geojson", + currentStep: STEPS.uploadFile + }); + expect(wrapper.findComponent({name: "FileUpload"}).exists()).to.be.true; + }); + + it("shows StyleLayers on styleLayers step", () => { + wrapper = createWrapper({ + currentWorkflow: "wfs", + currentStep: STEPS.styleLayers, + selectedLayers: [{name: "test"}] + }); + expect(wrapper.findComponent({name: "StyleLayers"}).exists()).to.be.true; + }); + }); + + describe("navigation buttons", () => { + it("shows prev button when workflow is not undefined", () => { + wrapper = createWrapper({currentWorkflow: "wms"}); + const buttons = wrapper.findAllComponents({name: "FlatButton"}); + const texts = buttons.map(b => b.props("text")); + + expect(texts).to.include("additional:modules.tools.importer.prev"); + }); + + it("shows next button when not on last step", () => { + wrapper = createWrapper({ + currentWorkflow: "wms", + currentStep: STEPS.provideOgcService + }); + const buttons = wrapper.findAllComponents({name: "FlatButton"}); + const texts = buttons.map(b => b.props("text")); + + expect(texts).to.include("additional:modules.tools.importer.next"); + }); + + it("shows finish button on last step", () => { + wrapper = createWrapper({ + currentWorkflow: "wfs", + currentStep: STEPS.styleLayers + }); + const buttons = wrapper.findAllComponents({name: "FlatButton"}); + const texts = buttons.map(b => b.props("text")); + + expect(texts).to.include("additional:modules.tools.importer.finish"); + }); + + it("disables next button when form is invalid", () => { + wrapper = createWrapper({ + currentWorkflow: "wms", + currentStep: STEPS.provideOgcService, + currentFormValid: false + }); + const nextBtn = wrapper.findAllComponents({name: "FlatButton"}) + .find(b => b.props("text") === "additional:modules.tools.importer.next"); + + expect(nextBtn.props("disabled")).to.be.true; + }); + }); + + describe("layer tree folder title", () => { + it("returns custom title for wms with selected layers", () => { + wrapper = createWrapper({ + currentWorkflow: "wms", + selectedLayers: [{layers: "Custom Layer Name"}] + }); + + expect(wrapper.vm.layerTreeFolderTitle).to.equal("Custom Layer Name"); + }); + + it("returns generated title for geojson import", () => { + wrapper = createWrapper({ + currentWorkflow: "geojson", + geoJsonFolderCounter: 1 + }); + + expect(wrapper.vm.layerTreeFolderTitle).to.include("GeoJSON Import"); + }); + }); +}); diff --git a/importer/tests/unit/store/actionsImporterAddon.spec.js b/importer/tests/unit/store/actionsImporterAddon.spec.js index e69de29..5436a72 100644 --- a/importer/tests/unit/store/actionsImporterAddon.spec.js +++ b/importer/tests/unit/store/actionsImporterAddon.spec.js @@ -0,0 +1,8 @@ +import {expect} from "chai"; +import actions from "../../../store/actionsImporterAddon.js"; + +describe("addons/importer/store/actionsImporterAddon.js", () => { + it("exports actions object", () => { + expect(actions).to.be.an("object"); + }); +}); diff --git a/importer/tests/unit/store/gettersImporterAddon.spec.js b/importer/tests/unit/store/gettersImporterAddon.spec.js index e69de29..9b8b105 100644 --- a/importer/tests/unit/store/gettersImporterAddon.spec.js +++ b/importer/tests/unit/store/gettersImporterAddon.spec.js @@ -0,0 +1,8 @@ +import {expect} from "chai"; +import getters from "../../../store/gettersImporterAddon.js"; + +describe("addons/importer/store/gettersImporterAddon.js", () => { + it("exports getters object", () => { + expect(getters).to.be.an("object"); + }); +}); diff --git a/importer/tests/unit/store/mutationsImporterAddon.spec.js b/importer/tests/unit/store/mutationsImporterAddon.spec.js index e69de29..8092709 100644 --- a/importer/tests/unit/store/mutationsImporterAddon.spec.js +++ b/importer/tests/unit/store/mutationsImporterAddon.spec.js @@ -0,0 +1,8 @@ +import {expect} from "chai"; +import mutations from "../../../store/mutationsImporterAddon.js"; + +describe("addons/importer/store/mutationsImporterAddon.js", () => { + it("exports mutations object", () => { + expect(mutations).to.be.an("object"); + }); +});