Fix tests

This commit is contained in:
Pieter Vander Vennet 2023-07-15 18:55:03 +02:00
parent 0e760b908c
commit 16816a916c
28 changed files with 124 additions and 117 deletions

View file

@ -40,7 +40,7 @@
"generate:charging-stations": "cd ./assets/layers/charging_station && vite-node csvToJson.ts && cd -",
"prepare-deploy": "npm run generate:service-worker && ./scripts/build.sh",
"format": "prettier --write '**/*.ts' '**/*.svelte'",
"clean:tests": "(find . -type f -name \"*.doctest.ts\" | xargs -r rm)",
"clean:tests": "find . -type f -name \"*.doctest.ts\" | xargs -r rm",
"clean": "rm -rf .cache/ && (find *.html | grep -v \"^\\(404\\|index\\|land\\|test\\|studio\\|theme\\|style_test\\|statistics\\).html\" | xargs -r rm) && (ls | grep \"^index_[a-zA-Z_-]\\+\\.ts$\" | xargs -r rm) && (ls | grep \".*.webmanifest$\" | grep -v \"manifest.webmanifest\" | xargs -r rm)",
"generate:dependency-graph": "node_modules/.bin/depcruise --exclude \"^node_modules\" --output-type dot Logic/State/MapState.ts > dependencies.dot && dot dependencies.dot -T svg -o dependencies.svg && rm dependencies.dot",
"weblate-add-upstream": "git remote add weblate-github git@github.com:weblate/MapComplete.git && git remote add weblate-hosted-core https://hosted.weblate.org/git/mapcomplete/core/ && git remote add weblate-hosted-layers https://hosted.weblate.org/git/mapcomplete/layers/",

View file

@ -1,30 +1,30 @@
/**
* Generates a collection of geojson files based on an overpass query for a given theme
*/
import { Utils } from "../Utils"
import { Overpass } from "../Logic/Osm/Overpass"
import { Utils } from "../src/Utils"
import { Overpass } from "../src/Logic/Osm/Overpass"
import { existsSync, readFileSync, writeFileSync } from "fs"
import { TagsFilter } from "../Logic/Tags/TagsFilter"
import { Or } from "../Logic/Tags/Or"
import { AllKnownLayouts } from "../Customizations/AllKnownLayouts"
import { TagsFilter } from "../src/Logic/Tags/TagsFilter"
import { Or } from "../src/Logic/Tags/Or"
import { AllKnownLayouts } from "../src/Customizations/AllKnownLayouts"
import * as OsmToGeoJson from "osmtogeojson"
import MetaTagging from "../Logic/MetaTagging"
import { UIEventSource } from "../Logic/UIEventSource"
import { TileRange, Tiles } from "../Models/TileRange"
import LayoutConfig from "../Models/ThemeConfig/LayoutConfig"
import MetaTagging from "../src/Logic/MetaTagging"
import { UIEventSource } from "../src/Logic/UIEventSource"
import { TileRange, Tiles } from "../src/Models/TileRange"
import LayoutConfig from "../src/Models/ThemeConfig/LayoutConfig"
import ScriptUtils from "./ScriptUtils"
import PerLayerFeatureSourceSplitter from "../Logic/FeatureSource/PerLayerFeatureSourceSplitter"
import FilteredLayer from "../Models/FilteredLayer"
import StaticFeatureSource from "../Logic/FeatureSource/Sources/StaticFeatureSource"
import Constants from "../Models/Constants"
import { GeoOperations } from "../Logic/GeoOperations"
import SimpleMetaTaggers, { ReferencingWaysMetaTagger } from "../Logic/SimpleMetaTagger"
import FilteringFeatureSource from "../Logic/FeatureSource/Sources/FilteringFeatureSource"
import PerLayerFeatureSourceSplitter from "../src/Logic/FeatureSource/PerLayerFeatureSourceSplitter"
import FilteredLayer from "../src/Models/FilteredLayer"
import StaticFeatureSource from "../src/Logic/FeatureSource/Sources/StaticFeatureSource"
import Constants from "../src/Models/Constants"
import { GeoOperations } from "../src/Logic/GeoOperations"
import SimpleMetaTaggers, { ReferencingWaysMetaTagger } from "../src/Logic/SimpleMetaTagger"
import FilteringFeatureSource from "../src/Logic/FeatureSource/Sources/FilteringFeatureSource"
import { Feature } from "geojson"
import { BBox } from "../Logic/BBox"
import { FeatureSource } from "../Logic/FeatureSource/FeatureSource"
import OsmObjectDownloader from "../Logic/Osm/OsmObjectDownloader"
import FeaturePropertiesStore from "../Logic/FeatureSource/Actors/FeaturePropertiesStore"
import { BBox } from "../src/Logic/BBox"
import { FeatureSource } from "../src/Logic/FeatureSource/FeatureSource"
import OsmObjectDownloader from "../src/Logic/Osm/OsmObjectDownloader"
import FeaturePropertiesStore from "../src/Logic/FeatureSource/Actors/FeaturePropertiesStore"
ScriptUtils.fixUtils()

View file

@ -1,11 +1,11 @@
import { Utils } from "../../../Utils"
import LayoutConfig from "../../../Models/ThemeConfig/LayoutConfig"
import { Utils } from "../../../src/Utils"
import LayoutConfig from "../../../src/Models/ThemeConfig/LayoutConfig"
import * as bookcaseJson from "../../../assets/generated/themes/bookcases.json"
import { OsmTags } from "../../../Models/OsmFeature"
import * as bookcaseJson from "../../../src/assets/generated/themes/bookcases.json"
import { OsmTags } from "../../../src/Models/OsmFeature"
import { Feature, Geometry } from "geojson"
import { expect, it } from "vitest"
import ThemeViewState from "../../../Models/ThemeViewState"
import ThemeViewState from "../../../src/Models/ThemeViewState"
import ScriptUtils from "../../../scripts/ScriptUtils"
const latestTags = {

View file

@ -1,7 +1,9 @@
import CreateMultiPolygonWithPointReuseAction from "../../../Logic/Osm/Actions/CreateMultiPolygonWithPointReuseAction"
import { Tag } from "../../../Logic/Tags/Tag"
import { Changes } from "../../../Logic/Osm/Changes"
import CreateMultiPolygonWithPointReuseAction from "../../../src/Logic/Osm/Actions/CreateMultiPolygonWithPointReuseAction"
import { Tag } from "../../../src/Logic/Tags/Tag"
import { Changes } from "../../../src/Logic/Osm/Changes"
import { describe, expect, it } from "vitest"
import { OsmConnection } from "../../../src/Logic/Osm/OsmConnection"
import { ImmutableStore } from "../../../src/Logic/UIEventSource"
describe("CreateMultiPolygonWithPointReuseAction", () => {
it("should produce a correct changeset", () => {
@ -102,7 +104,12 @@ describe("CreateMultiPolygonWithPointReuseAction", () => {
[],
"import"
)
const descriptions = await action.Perform(new Changes())
const descriptions = await action.Perform(
new Changes({
dryRun: new ImmutableStore(true),
osmConnection: new OsmConnection(),
})
)
const ways = descriptions.filter((d) => d.type === "way")
// "unexpected id"

View file

@ -1,5 +1,5 @@
import { ExtraFuncParams, ExtraFunctions } from "../../Logic/ExtraFunctions"
import { OsmFeature } from "../../Models/OsmFeature"
import { ExtraFuncParams, ExtraFunctions } from "../../src/Logic/ExtraFunctions"
import { OsmFeature } from "../../src/Models/OsmFeature"
import { describe, expect, it } from "vitest"
import { Feature } from "geojson"

View file

@ -1,5 +1,5 @@
import * as turf from "@turf/turf"
import { GeoOperations } from "../../Logic/GeoOperations"
import { GeoOperations } from "../../src/Logic/GeoOperations"
import { Feature, LineString, Polygon } from "geojson"
import { describe, expect, it } from "vitest"

View file

@ -1,6 +1,6 @@
import AllImageProviders from "../../../Logic/ImageProviders/AllImageProviders"
import { UIEventSource } from "../../../Logic/UIEventSource"
import { Utils } from "../../../Utils"
import AllImageProviders from "../../../src/Logic/ImageProviders/AllImageProviders"
import { UIEventSource } from "../../../src/Logic/UIEventSource"
import { Utils } from "../../../src/Utils"
import { describe, expect, it } from "vitest"
describe("ImageProviders", () => {

View file

@ -1,14 +1,14 @@
import { Utils } from "../../../../Utils"
import { OsmRelation } from "../../../../Logic/Osm/OsmObject"
import { Utils } from "../../../../src/Utils"
import { OsmRelation } from "../../../../src/Logic/Osm/OsmObject"
import {
InPlaceReplacedmentRTSH,
TurnRestrictionRSH,
} from "../../../../Logic/Osm/Actions/RelationSplitHandler"
import { Changes } from "../../../../Logic/Osm/Changes"
} from "../../../../src/Logic/Osm/Actions/RelationSplitHandler"
import { Changes } from "../../../../src/Logic/Osm/Changes"
import { describe, expect, it } from "vitest"
import OsmObjectDownloader from "../../../../Logic/Osm/OsmObjectDownloader"
import { ImmutableStore } from "../../../../Logic/UIEventSource"
import { OsmConnection } from "../../../../Logic/Osm/OsmConnection"
import OsmObjectDownloader from "../../../../src/Logic/Osm/OsmObjectDownloader"
import { ImmutableStore } from "../../../../src/Logic/UIEventSource"
import { OsmConnection } from "../../../../src/Logic/Osm/OsmConnection"
describe("RelationSplitHandler", () => {
Utils.injectJsonDownloadForTests("https://www.openstreetmap.org/api/0.6/node/1124134958/ways", {

View file

@ -1,12 +1,12 @@
import { Utils } from "../../../../Utils"
import LayoutConfig from "../../../../Models/ThemeConfig/LayoutConfig"
import { BBox } from "../../../../Logic/BBox"
import ReplaceGeometryAction from "../../../../Logic/Osm/Actions/ReplaceGeometryAction"
import { Utils } from "../../../../src/Utils"
import LayoutConfig from "../../../../src/Models/ThemeConfig/LayoutConfig"
import { BBox } from "../../../../src/Logic/BBox"
import ReplaceGeometryAction from "../../../../src/Logic/Osm/Actions/ReplaceGeometryAction"
import { describe, expect, it } from "vitest"
import { OsmConnection } from "../../../../Logic/Osm/OsmConnection"
import { ImmutableStore } from "../../../../Logic/UIEventSource"
import { Changes } from "../../../../Logic/Osm/Changes"
import FullNodeDatabaseSource from "../../../../Logic/FeatureSource/TiledFeatureSource/FullNodeDatabaseSource"
import { OsmConnection } from "../../../../src/Logic/Osm/OsmConnection"
import { ImmutableStore } from "../../../../src/Logic/UIEventSource"
import { Changes } from "../../../../src/Logic/Osm/Changes"
import FullNodeDatabaseSource from "../../../../src/Logic/FeatureSource/TiledFeatureSource/FullNodeDatabaseSource"
describe("ReplaceGeometryAction", () => {
const grbStripped = {

View file

@ -1,9 +1,9 @@
import { Utils } from "../../../../Utils"
import SplitAction from "../../../../Logic/Osm/Actions/SplitAction"
import { Changes } from "../../../../Logic/Osm/Changes"
import { Utils } from "../../../../src/Utils"
import SplitAction from "../../../../src/Logic/Osm/Actions/SplitAction"
import { Changes } from "../../../../src/Logic/Osm/Changes"
import { describe, expect, it } from "vitest"
import { OsmConnection } from "../../../../Logic/Osm/OsmConnection"
import { ImmutableStore } from "../../../../Logic/UIEventSource"
import { OsmConnection } from "../../../../src/Logic/Osm/OsmConnection"
import { ImmutableStore } from "../../../../src/Logic/UIEventSource"
describe("SplitAction", () => {
{

View file

@ -1,8 +1,8 @@
import { ChangeDescription } from "../../../Logic/Osm/Actions/ChangeDescription"
import { Changes } from "../../../Logic/Osm/Changes"
import { ChangeDescription } from "../../../src/Logic/Osm/Actions/ChangeDescription"
import { Changes } from "../../../src/Logic/Osm/Changes"
import { expect, it } from "vitest"
import { ImmutableStore } from "../../../Logic/UIEventSource"
import { OsmConnection } from "../../../Logic/Osm/OsmConnection"
import { ImmutableStore } from "../../../src/Logic/UIEventSource"
import { OsmConnection } from "../../../src/Logic/Osm/OsmConnection"
it("Generate preXML from changeDescriptions", () => {
const changeDescrs: ChangeDescription[] = [

View file

@ -1,8 +1,8 @@
import { Utils } from "../../../Utils"
import { ChangesetHandler, ChangesetTag } from "../../../Logic/Osm/ChangesetHandler"
import { ImmutableStore, UIEventSource } from "../../../Logic/UIEventSource"
import { OsmConnection } from "../../../Logic/Osm/OsmConnection"
import { Changes } from "../../../Logic/Osm/Changes"
import { Utils } from "../../../src/Utils"
import { ChangesetHandler, ChangesetTag } from "../../../src/Logic/Osm/ChangesetHandler"
import { ImmutableStore, UIEventSource } from "../../../src/Logic/UIEventSource"
import { OsmConnection } from "../../../src/Logic/Osm/OsmConnection"
import { Changes } from "../../../src/Logic/Osm/Changes"
import { describe, expect, it } from "vitest"
function elstorage() {

View file

@ -1,9 +1,9 @@
import { OsmObject } from "../../../Logic/Osm/OsmObject"
import { Utils } from "../../../Utils"
import { OsmObject } from "../../../src/Logic/Osm/OsmObject"
import { Utils } from "../../../src/Utils"
import ScriptUtils from "../../../scripts/ScriptUtils"
import { readFileSync } from "fs"
import { describe, expect, it } from "vitest"
import OsmObjectDownloader from "../../../Logic/Osm/OsmObjectDownloader"
import OsmObjectDownloader from "../../../src/Logic/Osm/OsmObjectDownloader"
describe("OsmObject", () => {
describe("download referencing ways", () => {

View file

@ -1,5 +1,5 @@
import { TagUtils } from "../../../Logic/Tags/TagUtils"
import { Tag } from "../../../Logic/Tags/Tag"
import { TagUtils } from "../../../src/Logic/Tags/TagUtils"
import { Tag } from "../../../src/Logic/Tags/Tag"
import { describe, expect, it } from "vitest"
describe("Lazy object properties", () => {

View file

@ -1,9 +1,9 @@
import { TagsFilter } from "../../../Logic/Tags/TagsFilter"
import { And } from "../../../Logic/Tags/And"
import { Tag } from "../../../Logic/Tags/Tag"
import { TagUtils } from "../../../Logic/Tags/TagUtils"
import { Or } from "../../../Logic/Tags/Or"
import { RegexTag } from "../../../Logic/Tags/RegexTag"
import { TagsFilter } from "../../../src/Logic/Tags/TagsFilter"
import { And } from "../../../src/Logic/Tags/And"
import { Tag } from "../../../src/Logic/Tags/Tag"
import { TagUtils } from "../../../src/Logic/Tags/TagUtils"
import { Or } from "../../../src/Logic/Tags/Or"
import { RegexTag } from "../../../src/Logic/Tags/RegexTag"
import { describe, expect, it } from "vitest"
describe("Tag optimalization", () => {

View file

@ -1,4 +1,4 @@
import { TagUtils } from "../../../Logic/Tags/TagUtils"
import { TagUtils } from "../../../src/Logic/Tags/TagUtils"
import { equal } from "assert"
import { describe, expect, it } from "vitest"

View file

@ -1,5 +1,5 @@
import { Utils } from "../../../Utils"
import Wikidata from "../../../Logic/Web/Wikidata"
import { Utils } from "../../../src/Utils"
import Wikidata from "../../../src/Logic/Web/Wikidata"
import { describe, expect, it } from "vitest"
const Q140 = {

View file

@ -1,10 +1,10 @@
import { Utils } from "../../../../Utils"
import { DesugaringContext } from "../../../../Models/ThemeConfig/Conversion/Conversion"
import { LayerConfigJson } from "../../../../Models/ThemeConfig/Json/LayerConfigJson"
import { TagRenderingConfigJson } from "../../../../Models/ThemeConfig/Json/TagRenderingConfigJson"
import { PrepareLayer } from "../../../../Models/ThemeConfig/Conversion/PrepareLayer"
import { Utils } from "../../../../src/Utils"
import { DesugaringContext } from "../../../../src/Models/ThemeConfig/Conversion/Conversion"
import { LayerConfigJson } from "../../../../src/Models/ThemeConfig/Json/LayerConfigJson"
import { TagRenderingConfigJson } from "../../../../src/Models/ThemeConfig/Json/TagRenderingConfigJson"
import { PrepareLayer } from "../../../../src/Models/ThemeConfig/Conversion/PrepareLayer"
import * as bookcases from "../../../../assets/layers/public_bookcase/public_bookcase.json"
import CreateNoteImportLayer from "../../../../Models/ThemeConfig/Conversion/CreateNoteImportLayer"
import CreateNoteImportLayer from "../../../../src/Models/ThemeConfig/Conversion/CreateNoteImportLayer"
import { describe, expect, it } from "vitest"
describe("CreateNoteImportLayer", () => {

View file

@ -1,5 +1,5 @@
import LayoutConfig from "../../../../Models/ThemeConfig/LayoutConfig"
import { FixLegacyTheme } from "../../../../Models/ThemeConfig/Conversion/LegacyJsonConvert"
import LayoutConfig from "../../../../src/Models/ThemeConfig/LayoutConfig"
import { FixLegacyTheme } from "../../../../src/Models/ThemeConfig/Conversion/LegacyJsonConvert"
import { describe, expect, it } from "vitest"
describe("FixLegacyTheme", () => {

View file

@ -1,13 +1,13 @@
import { LayerConfigJson } from "../../../../Models/ThemeConfig/Json/LayerConfigJson"
import { TagRenderingConfigJson } from "../../../../Models/ThemeConfig/Json/TagRenderingConfigJson"
import LineRenderingConfigJson from "../../../../Models/ThemeConfig/Json/LineRenderingConfigJson"
import { LayerConfigJson } from "../../../../src/Models/ThemeConfig/Json/LayerConfigJson"
import { TagRenderingConfigJson } from "../../../../src/Models/ThemeConfig/Json/TagRenderingConfigJson"
import LineRenderingConfigJson from "../../../../src/Models/ThemeConfig/Json/LineRenderingConfigJson"
import {
ExpandRewrite,
PrepareLayer,
RewriteSpecial,
} from "../../../../Models/ThemeConfig/Conversion/PrepareLayer"
import { QuestionableTagRenderingConfigJson } from "../../../../Models/ThemeConfig/Json/QuestionableTagRenderingConfigJson"
import RewritableConfigJson from "../../../../Models/ThemeConfig/Json/RewritableConfigJson"
} from "../../../../src/Models/ThemeConfig/Conversion/PrepareLayer"
import { QuestionableTagRenderingConfigJson } from "../../../../src/Models/ThemeConfig/Json/QuestionableTagRenderingConfigJson"
import RewritableConfigJson from "../../../../src/Models/ThemeConfig/Json/RewritableConfigJson"
import { describe, expect, it } from "vitest"
describe("ExpandRewrite", () => {

View file

@ -1,15 +1,15 @@
import { LayoutConfigJson } from "../../../../Models/ThemeConfig/Json/LayoutConfigJson"
import { LayerConfigJson } from "../../../../Models/ThemeConfig/Json/LayerConfigJson"
import { PrepareTheme } from "../../../../Models/ThemeConfig/Conversion/PrepareTheme"
import { TagRenderingConfigJson } from "../../../../Models/ThemeConfig/Json/TagRenderingConfigJson"
import LayoutConfig from "../../../../Models/ThemeConfig/LayoutConfig"
import bookcaseLayer from "../../../../assets/generated/layers/public_bookcase.json"
import LayerConfig from "../../../../Models/ThemeConfig/LayerConfig"
import { ExtractImages } from "../../../../Models/ThemeConfig/Conversion/FixImages"
import cyclofix from "../../../../assets/generated/themes/cyclofix.json"
import { Tag } from "../../../../Logic/Tags/Tag"
import { DesugaringContext } from "../../../../Models/ThemeConfig/Conversion/Conversion"
import { And } from "../../../../Logic/Tags/And"
import { LayoutConfigJson } from "../../../../src/Models/ThemeConfig/Json/LayoutConfigJson"
import { LayerConfigJson } from "../../../../src/Models/ThemeConfig/Json/LayerConfigJson"
import { PrepareTheme } from "../../../../src/Models/ThemeConfig/Conversion/PrepareTheme"
import { TagRenderingConfigJson } from "../../../../src/Models/ThemeConfig/Json/TagRenderingConfigJson"
import LayoutConfig from "../../../../src/Models/ThemeConfig/LayoutConfig"
import bookcaseLayer from "../../../../src/assets/generated/layers/public_bookcase.json"
import LayerConfig from "../../../../src/Models/ThemeConfig/LayerConfig"
import { ExtractImages } from "../../../../src/Models/ThemeConfig/Conversion/FixImages"
import cyclofix from "../../../../src/assets/generated/themes/cyclofix.json"
import { Tag } from "../../../../src/Logic/Tags/Tag"
import { DesugaringContext } from "../../../../src/Models/ThemeConfig/Conversion/Conversion"
import { And } from "../../../../src/Logic/Tags/And"
import { describe, expect, it } from "vitest"
const themeConfigJson: LayoutConfigJson = {

View file

@ -1,5 +1,5 @@
import SourceConfig from "../../../Models/ThemeConfig/SourceConfig"
import { TagUtils } from "../../../Logic/Tags/TagUtils"
import SourceConfig from "../../../src/Models/ThemeConfig/SourceConfig"
import { TagUtils } from "../../../src/Logic/Tags/TagUtils"
import { describe, expect, it } from "vitest"
describe("SourceConfig", () => {

View file

@ -1,5 +1,5 @@
import TagRenderingConfig from "../../../Models/ThemeConfig/TagRenderingConfig"
import Locale from "../../../UI/i18n/Locale"
import TagRenderingConfig from "../../../src/Models/ThemeConfig/TagRenderingConfig"
import Locale from "../../../src/UI/i18n/Locale"
import { describe, expect, it } from "vitest"
describe("TagRenderingConfig", () => {

View file

@ -1,5 +1,5 @@
import { Unit } from "../../Models/Unit"
import { Denomination } from "../../Models/Denomination"
import { Unit } from "../../src/Models/Unit"
import { Denomination } from "../../src/Models/Denomination"
import { describe, expect, it } from "vitest"
describe("Unit", () => {

View file

@ -1,4 +1,4 @@
import SpecialVisualizations from "../../UI/SpecialVisualizations"
import SpecialVisualizations from "../../src/UI/SpecialVisualizations"
import { describe, expect, it } from "vitest"
describe("SpecialVisualisations", () => {

View file

@ -1,4 +1,4 @@
import { Utils } from "../Utils"
import { Utils } from "../src/Utils"
import LZString from "lz-string"
import { describe, expect, it } from "vitest"

View file

@ -1,4 +1,4 @@
import { Utils } from "../../Utils"
import { Utils } from "../../src/Utils"
import { existsSync, mkdirSync, readFileSync, unlinkSync } from "fs"
import ScriptUtils from "../../scripts/ScriptUtils"
import { main } from "../../scripts/generateCache"

View file

@ -1,8 +1,8 @@
import ScriptUtils from "../scripts/ScriptUtils"
import { Utils } from "../Utils"
import Locale from "../UI/i18n/Locale"
import { Utils } from "../src/Utils"
import Locale from "../src/UI/i18n/Locale"
import { beforeEach } from "vitest"
import { ReferencingWaysMetaTagger } from "../Logic/SimpleMetaTagger"
import { ReferencingWaysMetaTagger } from "../src/Logic/SimpleMetaTagger"
beforeEach(async () => {
ScriptUtils.fixUtils()