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]
|
const step = this.steps[i]
|
||||||
try {
|
try {
|
||||||
let r = step.convert(json, "While running step " + step.name + ": " + context)
|
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 ?? []))
|
errors.push(...(r.errors ?? []))
|
||||||
warnings.push(...(r.warnings ?? []))
|
warnings.push(...(r.warnings ?? []))
|
||||||
information.push(...(r.information ?? []))
|
information.push(...(r.information ?? []))
|
||||||
|
|
|
@ -593,6 +593,7 @@ export class AddEditingElements extends DesugaringStep<LayerConfigJson> {
|
||||||
|
|
||||||
if (
|
if (
|
||||||
json.tagRenderings &&
|
json.tagRenderings &&
|
||||||
|
this._desugaring.tagRenderings.has("just_created") &&
|
||||||
!json.tagRenderings.some((tr) => tr === "just_created" || tr["id"] === "just_created")
|
!json.tagRenderings.some((tr) => tr === "just_created" || tr["id"] === "just_created")
|
||||||
) {
|
) {
|
||||||
json.tagRenderings.unshift(this._desugaring.tagRenderings.get("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" &&
|
||||||
json.source !== "special:library" &&
|
json.source !== "special:library" &&
|
||||||
json.tagRenderings &&
|
json.tagRenderings &&
|
||||||
|
this._desugaring.tagRenderings.has("last_edit") &&
|
||||||
!json.tagRenderings.some((tr) => tr["id"] === "last_edit")
|
!json.tagRenderings.some((tr) => tr["id"] === "last_edit")
|
||||||
) {
|
) {
|
||||||
json.tagRenderings.push(this._desugaring.tagRenderings.get("last_edit"))
|
json.tagRenderings.push(this._desugaring.tagRenderings.get("last_edit"))
|
||||||
|
@ -1161,7 +1163,14 @@ export class AddMiniMap extends DesugaringStep<LayerConfigJson> {
|
||||||
if (!hasMinimap) {
|
if (!hasMinimap) {
|
||||||
layerConfig = { ...layerConfig }
|
layerConfig = { ...layerConfig }
|
||||||
layerConfig.tagRenderings = [...layerConfig.tagRenderings]
|
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 {
|
return {
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import { TagRenderingConfigJson } from "../Json/TagRenderingConfigJson"
|
import {TagRenderingConfigJson} from "../Json/TagRenderingConfigJson"
|
||||||
import { Utils } from "../../../Utils"
|
import {Utils} from "../../../Utils"
|
||||||
import SpecialVisualizations from "../../../UI/SpecialVisualizations"
|
import SpecialVisualizations from "../../../UI/SpecialVisualizations"
|
||||||
import { RenderingSpecification, SpecialVisualization } from "../../../UI/SpecialVisualization"
|
import {RenderingSpecification, SpecialVisualization} from "../../../UI/SpecialVisualization"
|
||||||
import { LayerConfigJson } from "../Json/LayerConfigJson"
|
import {LayerConfigJson} from "../Json/LayerConfigJson"
|
||||||
|
|
||||||
export default class ValidationUtils {
|
export default class ValidationUtils {
|
||||||
public static hasSpecialVisualisation(
|
public static hasSpecialVisualisation(
|
||||||
|
@ -10,10 +10,14 @@ export default class ValidationUtils {
|
||||||
specialVisualisation: string
|
specialVisualisation: string
|
||||||
): boolean {
|
): boolean {
|
||||||
return (
|
return (
|
||||||
layer.tagRenderings?.some((tagRendering) =>
|
layer.tagRenderings?.some((tagRendering) => {
|
||||||
ValidationUtils.getSpecialVisualisations(<TagRenderingConfigJson>tagRendering).some(
|
if(tagRendering === undefined){
|
||||||
(vis) => vis.funcName === specialVisualisation
|
return false
|
||||||
)
|
}
|
||||||
|
|
||||||
|
const spec = ValidationUtils.getSpecialVisualisations(<TagRenderingConfigJson>tagRendering)
|
||||||
|
return spec.some((vis) => vis.funcName === specialVisualisation);
|
||||||
|
}
|
||||||
) ?? false
|
) ?? false
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -40,7 +44,7 @@ export default class ValidationUtils {
|
||||||
const all: RenderingSpecification[] = []
|
const all: RenderingSpecification[] = []
|
||||||
for (let translation of translations) {
|
for (let translation of translations) {
|
||||||
if (typeof translation == "string") {
|
if (typeof translation == "string") {
|
||||||
translation = { "*": translation }
|
translation = {"*": translation}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const key in translation) {
|
for (const key in translation) {
|
||||||
|
|
Loading…
Reference in a new issue