Tests: tweak validation to be runnable in the tests
This commit is contained in:
parent
6e8c0babd8
commit
e2b3032198
3 changed files with 26 additions and 10 deletions
|
@ -297,6 +297,9 @@ export class Fuse<T> extends DesugaringStep<T> {
|
|||
const step = this.steps[i]
|
||||
try {
|
||||
let r = step.convert(json, "While running step " + step.name + ": " + context)
|
||||
if(r.result["tagRenderings"]?.some(tr => tr === undefined)){
|
||||
throw step.name+" introduced an undefined tagRendering"
|
||||
}
|
||||
errors.push(...(r.errors ?? []))
|
||||
warnings.push(...(r.warnings ?? []))
|
||||
information.push(...(r.information ?? []))
|
||||
|
|
|
@ -593,6 +593,7 @@ export class AddEditingElements extends DesugaringStep<LayerConfigJson> {
|
|||
|
||||
if (
|
||||
json.tagRenderings &&
|
||||
this._desugaring.tagRenderings.has("just_created") &&
|
||||
!json.tagRenderings.some((tr) => tr === "just_created" || tr["id"] === "just_created")
|
||||
) {
|
||||
json.tagRenderings.unshift(this._desugaring.tagRenderings.get("just_created"))
|
||||
|
@ -623,6 +624,7 @@ export class AddEditingElements extends DesugaringStep<LayerConfigJson> {
|
|||
json.source !== "special" &&
|
||||
json.source !== "special:library" &&
|
||||
json.tagRenderings &&
|
||||
this._desugaring.tagRenderings.has("last_edit") &&
|
||||
!json.tagRenderings.some((tr) => tr["id"] === "last_edit")
|
||||
) {
|
||||
json.tagRenderings.push(this._desugaring.tagRenderings.get("last_edit"))
|
||||
|
@ -1161,7 +1163,14 @@ export class AddMiniMap extends DesugaringStep<LayerConfigJson> {
|
|||
if (!hasMinimap) {
|
||||
layerConfig = { ...layerConfig }
|
||||
layerConfig.tagRenderings = [...layerConfig.tagRenderings]
|
||||
layerConfig.tagRenderings.push(state.tagRenderings.get("minimap"))
|
||||
const minimap = state.tagRenderings.get("minimap")
|
||||
if(minimap === undefined){
|
||||
if(state.tagRenderings.size > 0){
|
||||
throw "The 'minimap'-builtin tagrendering is not defined. As such, it cannot be added automatically"
|
||||
}
|
||||
}else{
|
||||
layerConfig.tagRenderings.push()
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
|
|
|
@ -10,10 +10,14 @@ export default class ValidationUtils {
|
|||
specialVisualisation: string
|
||||
): boolean {
|
||||
return (
|
||||
layer.tagRenderings?.some((tagRendering) =>
|
||||
ValidationUtils.getSpecialVisualisations(<TagRenderingConfigJson>tagRendering).some(
|
||||
(vis) => vis.funcName === specialVisualisation
|
||||
)
|
||||
layer.tagRenderings?.some((tagRendering) => {
|
||||
if(tagRendering === undefined){
|
||||
return false
|
||||
}
|
||||
|
||||
const spec = ValidationUtils.getSpecialVisualisations(<TagRenderingConfigJson>tagRendering)
|
||||
return spec.some((vis) => vis.funcName === specialVisualisation);
|
||||
}
|
||||
) ?? false
|
||||
)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue