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 {
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
import { TagRenderingConfigJson } from "../Json/TagRenderingConfigJson"
|
||||
import { Utils } from "../../../Utils"
|
||||
import {TagRenderingConfigJson} from "../Json/TagRenderingConfigJson"
|
||||
import {Utils} from "../../../Utils"
|
||||
import SpecialVisualizations from "../../../UI/SpecialVisualizations"
|
||||
import { RenderingSpecification, SpecialVisualization } from "../../../UI/SpecialVisualization"
|
||||
import { LayerConfigJson } from "../Json/LayerConfigJson"
|
||||
import {RenderingSpecification, SpecialVisualization} from "../../../UI/SpecialVisualization"
|
||||
import {LayerConfigJson} from "../Json/LayerConfigJson"
|
||||
|
||||
export default class ValidationUtils {
|
||||
public static hasSpecialVisualisation(
|
||||
|
@ -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
|
||||
)
|
||||
}
|
||||
|
@ -40,7 +44,7 @@ export default class ValidationUtils {
|
|||
const all: RenderingSpecification[] = []
|
||||
for (let translation of translations) {
|
||||
if (typeof translation == "string") {
|
||||
translation = { "*": translation }
|
||||
translation = {"*": translation}
|
||||
}
|
||||
|
||||
for (const key in translation) {
|
||||
|
|
Loading…
Reference in a new issue