From 5628be36327906e1d0f44004f8f8ad41b3b2ea5b Mon Sep 17 00:00:00 2001 From: pietervdvn Date: Wed, 6 Oct 2021 02:36:58 +0200 Subject: [PATCH] Fix tests --- Logic/Osm/Actions/ChangeTagAction.ts | 2 +- UI/Image/DeleteImage.ts | 10 ++++++++-- UI/Image/ImageUploadFlow.ts | 6 +++++- test/SplitAction.spec.ts | 12 +++++++++--- 4 files changed, 23 insertions(+), 7 deletions(-) diff --git a/Logic/Osm/Actions/ChangeTagAction.ts b/Logic/Osm/Actions/ChangeTagAction.ts index fd55953d1..00e9b001e 100644 --- a/Logic/Osm/Actions/ChangeTagAction.ts +++ b/Logic/Osm/Actions/ChangeTagAction.ts @@ -11,7 +11,7 @@ export default class ChangeTagAction extends OsmChangeAction { constructor(elementId: string, tagsFilter: TagsFilter, currentTags: any, meta: { theme: string, - changeType: "answer" | "soft-delete" + changeType: "answer" | "soft-delete" | "add-image" }) { super(); this._elementId = elementId; diff --git a/UI/Image/DeleteImage.ts b/UI/Image/DeleteImage.ts index 800eec53c..68afbb3fc 100644 --- a/UI/Image/DeleteImage.ts +++ b/UI/Image/DeleteImage.ts @@ -16,7 +16,10 @@ export default class DeleteImage extends Toggle { .SetClass("rounded-full p-1") .SetStyle("color:white;background:#ff8c8c") .onClick(async() => { - await State.state?.changes?.applyAction(new ChangeTagAction(tags.data.id, new Tag(key, oldValue), tags.data)) + await State.state?.changes?.applyAction(new ChangeTagAction(tags.data.id, new Tag(key, oldValue), tags.data, { + changeType: "answer", + theme: "test" + })) }); const deleteButton = Translations.t.image.doDelete.Clone() @@ -24,7 +27,10 @@ export default class DeleteImage extends Toggle { .SetStyle("color:white;background:#ff8c8c; border-top-left-radius:30rem; border-top-right-radius: 30rem;") .onClick( async() => { await State.state?.changes?.applyAction( - new ChangeTagAction(tags.data.id, new Tag(key, ""), tags.data) + new ChangeTagAction(tags.data.id, new Tag(key, ""), tags.data,{ + changeType: "answer", + theme: "test" + }) ) }); diff --git a/UI/Image/ImageUploadFlow.ts b/UI/Image/ImageUploadFlow.ts index 4eec0b85c..2a79417bc 100644 --- a/UI/Image/ImageUploadFlow.ts +++ b/UI/Image/ImageUploadFlow.ts @@ -31,7 +31,11 @@ export class ImageUploadFlow extends Toggle { console.log("Adding image:" + key, url); Promise.resolve(State.state.changes .applyAction(new ChangeTagAction( - tags.id, new Tag(key, url), tagsSource.data + tags.id, new Tag(key, url), tagsSource.data, + { + changeType: "add-image", + theme: State.state.layoutToUse.id + } ))) }) diff --git a/test/SplitAction.spec.ts b/test/SplitAction.spec.ts index 6e4ed77a9..cf9eb5f03 100644 --- a/test/SplitAction.spec.ts +++ b/test/SplitAction.spec.ts @@ -191,7 +191,9 @@ export default class SplitActionSpec extends T { // Lets split road https://www.openstreetmap.org/way/295132739 const id = "way/295132739" const splitPoint: [number, number] = [3.246733546257019, 51.181710380278176] - const splitter = new SplitAction(id, [splitPoint]) + const splitter = new SplitAction(id, [splitPoint], { + theme: "test" + }) const changeDescription = await splitter.CreateChangeDescriptions(new Changes()) equal(changeDescription[0].type, "node") @@ -235,7 +237,9 @@ export default class SplitActionSpec extends T { const id = "way/61435323" const splitPoint: [number, number] = [ 3.2021324336528774, 51.2170001600597] - const splitter = new SplitAction(id, [splitPoint]) + const splitter = new SplitAction(id, [splitPoint], { + theme: "test" + }) const changeDescription = await splitter.CreateChangeDescriptions(new Changes()) // Should be a new node @@ -247,7 +251,9 @@ export default class SplitActionSpec extends T { // Lets split road near an already existing point https://www.openstreetmap.org/way/295132739 const id = "way/295132739" const splitPoint: [number, number] = [3.2451081275939937, 51.18116898253599] - const splitter = new SplitAction(id, [splitPoint]) + const splitter = new SplitAction(id, [splitPoint], { + theme: "test" + }) const changeDescription = await splitter.CreateChangeDescriptions(new Changes()) equal(2, changeDescription.length)