Extract and validate images using a new conversion, regenerate docs

This commit is contained in:
Pieter Vander Vennet 2022-02-09 22:37:21 +01:00
parent 5198f5d310
commit b3c58ae82e
52 changed files with 8611 additions and 3408 deletions

View file

@ -1,8 +1,8 @@
import {equal} from "assert";
import T from "./TestHelper";
import {Translation} from "../UI/i18n/Translation";
import * as bike_repair_station from "../assets/layers/bike_repair_station/bike_repair_station.json"
import LayerConfig from "../Models/ThemeConfig/LayerConfig";
import * as cyclofix from "../assets/generated/themes/cyclofix.json"
import {ExtractImages} from "../Models/ThemeConfig/Conversion/FixImages";
export default class ImageAttributionSpec extends T {
constructor() {
@ -10,9 +10,9 @@ export default class ImageAttributionSpec extends T {
[
"Should find all the images",
() => {
const pumps: LayerConfig = new LayerConfig(bike_repair_station)
const images = pumps.ExtractImages();
const expectedValues = ['./assets/layers/bike_repair_station/repair_station.svg',
const images = new Set(new ExtractImages().convertStrict(cyclofix, "test"))
const expectedValues = [
'./assets/layers/bike_repair_station/repair_station.svg',
'./assets/layers/bike_repair_station/repair_station_pump.svg',
'./assets/layers/bike_repair_station/broken_pump.svg',
'./assets/layers/bike_repair_station/pump.svg',
@ -20,7 +20,8 @@ export default class ImageAttributionSpec extends T {
'./assets/layers/bike_repair_station/pump_example_manual.jpg',
'./assets/layers/bike_repair_station/pump_example.png',
'./assets/layers/bike_repair_station/pump_example_round.jpg',
'./assets/layers/bike_repair_station/repair_station_example_2.jpg']
'./assets/layers/bike_repair_station/repair_station_example_2.jpg',
'close']
for (const expected of expectedValues) {
T.isTrue(images.has(expected), expected + " not found")
}

View file

@ -1,10 +1,11 @@
import T from "./TestHelper";
import {FixImages, FixLegacyTheme} from "../Models/ThemeConfig/Conversion/LegacyJsonConvert";
import {FixLegacyTheme} from "../Models/ThemeConfig/Conversion/LegacyJsonConvert";
import LayoutConfig from "../Models/ThemeConfig/LayoutConfig";
import {TagRenderingConfigJson} from "../Models/ThemeConfig/Json/TagRenderingConfigJson";
import {AddMiniMap} from "../Models/ThemeConfig/Conversion/PrepareTheme";
import {DetectShadowedMappings} from "../Models/ThemeConfig/Conversion/Validation";
import * as Assert from "assert";
import {FixImages} from "../Models/ThemeConfig/Conversion/FixImages";
export default class LegacyThemeLoaderSpec extends T {
@ -239,6 +240,17 @@ export default class LegacyThemeLoaderSpec extends T {
"mapRendering": [
{
"icon": "./TS_bolt.svg",
iconBadges: [{
if: "id=yes",
then:{
mappings: [
{
if: "id=yes",
then: "./Something.svg"
}
]
}
}],
"location": [
"point",
"centroid"
@ -433,6 +445,10 @@ export default class LegacyThemeLoaderSpec extends T {
const fixedValue = fixed.layers[0]["mapRendering"][0].icon
Assert.equal("https://raw.githubusercontent.com/seppesantens/MapComplete-Themes/main/VerkeerdeBordenDatabank/TS_bolt.svg",
fixedValue)
const fixedMapping = fixed.layers[0]["mapRendering"][0].iconBadges[0].then.mappings[0].then
Assert.equal("https://raw.githubusercontent.com/seppesantens/MapComplete-Themes/main/VerkeerdeBordenDatabank/Something.svg",
fixedMapping)
} ]
]
);