From b2741e1b6d123158572c67d56c247d6330569dc8 Mon Sep 17 00:00:00 2001 From: pietervdvn Date: Fri, 11 Feb 2022 19:56:31 +0100 Subject: [PATCH] Fix tests --- Models/ThemeConfig/Conversion/FixImages.ts | 15 +++++++++++---- Models/ThemeConfig/LayoutConfig.ts | 2 +- assets/layers/birdhide/birdhide.json | 4 +--- assets/tagRenderings/questions.json | 9 ++++++--- langs/layers/nl.json | 7 ------- langs/shared-questions/es.json | 2 +- 6 files changed, 20 insertions(+), 19 deletions(-) diff --git a/Models/ThemeConfig/Conversion/FixImages.ts b/Models/ThemeConfig/Conversion/FixImages.ts index b781f11fe..31d1cfbcd 100644 --- a/Models/ThemeConfig/Conversion/FixImages.ts +++ b/Models/ThemeConfig/Conversion/FixImages.ts @@ -9,10 +9,11 @@ export class ExtractImages extends Conversion { super("Extract all images from a layoutConfig using the meta paths"); } - convert(json: LayoutConfigJson, context: string): { result: string[] } { + convert(json: LayoutConfigJson, context: string): { result: string[], errors: string[] } { const paths = metapaths["default"] ?? metapaths const trpaths = tagrenderingmetapaths["default"] ?? tagrenderingmetapaths const allFoundImages = [] + const errors = [] for (const metapath of paths) { if (metapath.typeHint === undefined) { continue @@ -34,7 +35,13 @@ export class ExtractImages extends Conversion { if (trpath.typeHint !== "rendered") { continue } - Utils.CollectPath(trpath.path, foundImage, allFoundImages) + const fromPath = Utils.CollectPath(trpath.path, foundImage) + for (const img of fromPath) { + if (typeof img !== "string") { + errors.push("Found an image path that is not a path at " + context + "." + metapath.path.join(".") + ": " + JSON.stringify(img)) + } + } + allFoundImages.push(...fromPath.filter(i => typeof i === "string")) } } @@ -44,9 +51,9 @@ export class ExtractImages extends Conversion { } } - const splitParts = [].concat(...allFoundImages.map(img => img.split(";"))) + const splitParts = [].concat(...Utils.NoNull(allFoundImages).map(img => img.split(";"))) .map(img => img.split(":")[0]) - return {result: Utils.Dedup(splitParts)}; + return {result: Utils.Dedup(splitParts), errors}; } } diff --git a/Models/ThemeConfig/LayoutConfig.ts b/Models/ThemeConfig/LayoutConfig.ts index b1f505268..dbc9f4b79 100644 --- a/Models/ThemeConfig/LayoutConfig.ts +++ b/Models/ThemeConfig/LayoutConfig.ts @@ -70,7 +70,7 @@ export default class LayoutConfig { this.credits = json.credits; this.version = json.version; this.language = json.mustHaveLanguage ?? Array.from(Object.keys(json.title)); - this.usedImages =Array.from( new ExtractImages().convertStrict(json, "while extracting the images")).sort() + this.usedImages =Array.from( new ExtractImages().convertStrict(json, "while extracting the images of "+json.id+" "+context??"")).sort() { if (typeof json.title === "string") { throw `The title of a theme should always be a translation, as it sets the corresponding languages (${context}.title). The themenID is ${this.id}; the offending object is ${JSON.stringify(json.title)} which is a ${typeof json.title})` diff --git a/assets/layers/birdhide/birdhide.json b/assets/layers/birdhide/birdhide.json index e058124a6..2f676c636 100644 --- a/assets/layers/birdhide/birdhide.json +++ b/assets/layers/birdhide/birdhide.json @@ -291,9 +291,7 @@ "mapRendering": [ { "icon": { - "render": { - "nl": "./assets/layers/birdhide/birdhide.svg" - }, + "render": "./assets/layers/birdhide/birdhide.svg", "mappings": [ { "if": { diff --git a/assets/tagRenderings/questions.json b/assets/tagRenderings/questions.json index 4b11be1a3..35b737b27 100644 --- a/assets/tagRenderings/questions.json +++ b/assets/tagRenderings/questions.json @@ -370,7 +370,8 @@ "zh_Hant": "允許犬隻", "id": "Anjing diperbolehkan", "pl": "Psy dozwolone", - "ja": "ペット同伴可能" + "ja": "ペット同伴可能", + "es": "Se permiten perros" } }, { @@ -391,7 +392,8 @@ "pl": "Psy nie dozwolone", "ru": "С собаками не впускают", "id": "Anjing tidak diperbolehkan", - "ja": "ペット同伴不可" + "ja": "ペット同伴不可", + "es": "No se permiten perros" } }, { @@ -452,7 +454,8 @@ "ca": "Hi ha quelcom rellevant que no t'hem preguntat? Afegeix-ho aquí.
No repeteixis informació que ja hi és", "sv": "Finns det fortfarande någonting relevant som du inte kunde ge i de föregående frågorna? Lägg till det här.
Repetera inte redan angivna fakta", "id": "Apakah masih ada sesuatu yang relevan yang tidak dapat Anda berikan dalam pertanyaan sebelumnya? Tambahkan di sini.
Jangan ulangi fakta yang sudah dinyatakan ", - "ja": "前の質問で伝えきれなかった関連事項がまだありますか?ここに追加してください。
今後表示しない" + "ja": "前の質問で伝えきれなかった関連事項がまだありますか?ここに追加してください。
今後表示しない", + "es": "¿Aún hay algo relevante que no ha encajado en las preguntas anteriores? Compártalo aquí.
No repita datos ya expresados" }, "render": "{description}", "freeform": { diff --git a/langs/layers/nl.json b/langs/layers/nl.json index 2064cb182..8961003e2 100644 --- a/langs/layers/nl.json +++ b/langs/layers/nl.json @@ -1040,13 +1040,6 @@ } } }, - "mapRendering": { - "0": { - "icon": { - "render": "./assets/layers/birdhide/birdhide.svg" - } - } - }, "name": "Vogelkijkhutten", "presets": { "0": { diff --git a/langs/shared-questions/es.json b/langs/shared-questions/es.json index 1dca5b160..e513f074e 100644 --- a/langs/shared-questions/es.json +++ b/langs/shared-questions/es.json @@ -14,4 +14,4 @@ } } } -} +} \ No newline at end of file