forked from MapComplete/MapComplete
		
	Fix tests
This commit is contained in:
		
							parent
							
								
									3785d51468
								
							
						
					
					
						commit
						b2741e1b6d
					
				
					 6 changed files with 20 additions and 19 deletions
				
			
		|  | @ -9,10 +9,11 @@ export class ExtractImages extends Conversion<LayoutConfigJson, string[]> { | |||
|         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<LayoutConfigJson, string[]> { | |||
|                             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<LayoutConfigJson, string[]> { | |||
|             } | ||||
|         } | ||||
| 
 | ||||
|         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}; | ||||
|     } | ||||
| 
 | ||||
| } | ||||
|  |  | |||
|  | @ -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})` | ||||
|  |  | |||
|  | @ -291,9 +291,7 @@ | |||
|   "mapRendering": [ | ||||
|     { | ||||
|       "icon": { | ||||
|         "render": { | ||||
|           "nl": "./assets/layers/birdhide/birdhide.svg" | ||||
|         }, | ||||
|         "render": "./assets/layers/birdhide/birdhide.svg", | ||||
|         "mappings": [ | ||||
|           { | ||||
|             "if": { | ||||
|  |  | |||
|  | @ -370,7 +370,8 @@ | |||
|           "zh_Hant": "允許犬隻", | ||||
|           "id": "Anjing diperbolehkan", | ||||
|           "pl": "Psy dozwolone", | ||||
|           "ja": "ペット同伴可能" | ||||
|           "ja": "ペット同伴可能", | ||||
|           "es": "Se permiten perros" | ||||
|         } | ||||
|       }, | ||||
|       { | ||||
|  | @ -391,7 +392,8 @@ | |||
|           "pl": "Psy <b>nie</b> dozwolone", | ||||
|           "ru": "С собаками <b>не</b> впускают", | ||||
|           "id": "Anjing <b> tidak </b> diperbolehkan", | ||||
|           "ja": "ペット同伴<b>不可</b>" | ||||
|           "ja": "ペット同伴<b>不可</b>", | ||||
|           "es": "<b>No</b> se permiten perros" | ||||
|         } | ||||
|       }, | ||||
|       { | ||||
|  | @ -452,7 +454,8 @@ | |||
|       "ca": "Hi ha quelcom rellevant que no t'hem preguntat? Afegeix-ho aquí. <br/><span style='font-size: small'>No repeteixis informació que ja hi és</span>", | ||||
|       "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.<br/><span style='font-size: small'>Repetera inte redan angivna fakta</span>", | ||||
|       "id": "Apakah masih ada sesuatu yang relevan yang tidak dapat Anda berikan dalam pertanyaan sebelumnya? Tambahkan di sini. <br/> <span style='font-size: small'> Jangan ulangi fakta yang sudah dinyatakan </span>", | ||||
|       "ja": "前の質問で伝えきれなかった関連事項がまだありますか?ここに追加してください。<br/><span style='font-size: small'>今後表示しない</span>" | ||||
|       "ja": "前の質問で伝えきれなかった関連事項がまだありますか?ここに追加してください。<br/><span style='font-size: small'>今後表示しない</span>", | ||||
|       "es": "¿Aún hay algo relevante que no ha encajado en las preguntas anteriores? Compártalo aquí.<br/><span style='font-size: small'>No repita datos ya expresados</span>" | ||||
|     }, | ||||
|     "render": "{description}", | ||||
|     "freeform": { | ||||
|  |  | |||
|  | @ -1040,13 +1040,6 @@ | |||
|                 } | ||||
|             } | ||||
|         }, | ||||
|         "mapRendering": { | ||||
|             "0": { | ||||
|                 "icon": { | ||||
|                     "render": "./assets/layers/birdhide/birdhide.svg" | ||||
|                 } | ||||
|             } | ||||
|         }, | ||||
|         "name": "Vogelkijkhutten", | ||||
|         "presets": { | ||||
|             "0": { | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue