From e6dab1a83f01cfab17fcaf58e36fd4ec8423977d Mon Sep 17 00:00:00 2001 From: Pieter Vander Vennet Date: Tue, 10 Sep 2024 14:44:25 +0200 Subject: [PATCH] Fix tests --- src/Models/RasterLayers.ts | 2 +- src/Models/ThemeViewState.ts | 4 ++++ test/Logic/Actors/Actors.spec.ts | 4 +++- test/testhooks.ts | 1 + 4 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/Models/RasterLayers.ts b/src/Models/RasterLayers.ts index aac8daa9c..cde3dddf3 100644 --- a/src/Models/RasterLayers.ts +++ b/src/Models/RasterLayers.ts @@ -23,7 +23,7 @@ export class AvailableRasterLayers { const eli = await Utils.downloadJson<{ features: EditorLayerIndex }>( "./assets/data/editor-layer-index.json" ) - this._editorLayerIndex = eli.features.filter((l) => l.properties.id !== "Bing") + this._editorLayerIndex = eli.features?.filter((l) => l.properties.id !== "Bing") ?? [] this._editorLayerIndexStore.set(this._editorLayerIndex) return this._editorLayerIndex } diff --git a/src/Models/ThemeViewState.ts b/src/Models/ThemeViewState.ts index a937ca907..46f2aecd3 100644 --- a/src/Models/ThemeViewState.ts +++ b/src/Models/ThemeViewState.ts @@ -962,6 +962,10 @@ export default class ThemeViewState implements SpecialVisualizationState { } public async reportError(message: string | Error | XMLHttpRequest, extramessage:string = "") { + if(Utils.runningFromConsole){ + console.error("Got (in themeViewSTate.reportError):", message, extramessage) + return + } const isTesting = this.featureSwitchIsTesting.data console.log( isTesting diff --git a/test/Logic/Actors/Actors.spec.ts b/test/Logic/Actors/Actors.spec.ts index 19543b5bf..2dbcfc8a0 100644 --- a/test/Logic/Actors/Actors.spec.ts +++ b/test/Logic/Actors/Actors.spec.ts @@ -43,6 +43,8 @@ Utils.injectJsonDownloadForTests("https://www.openstreetmap.org/api/0.6/node/556 ], }) +Utils.injectJsonDownloadForTests("./assets/data/editor-layer-index.json", '{"features": [] }') + it("should download the latest version", async () => { const state = new ThemeViewState(new LayoutConfig(bookcaseJson, true), new Set()) const feature: Feature = { @@ -83,6 +85,6 @@ it("should download the latest version", async () => { // The name should be updated expect(feature.properties.name).toEqual("Stubbekwartier-buurtbibliotheek") - // The fixme should be removed + // The fix_me should be removed expect(feature.properties.fixme).toBeUndefined() }) diff --git a/test/testhooks.ts b/test/testhooks.ts index e0b7c7a4f..8eca70f46 100644 --- a/test/testhooks.ts +++ b/test/testhooks.ts @@ -11,6 +11,7 @@ beforeEach(async () => { // Block internet access Utils.externalDownloadFunction = async (url) => { + console.trace("Fetching external data during tests:", url) throw "Fetching " + url + " blocked in tests, use Utils.injectJsonDownloadForTests instead" } })