refactoring: slight cleanup of tests

This commit is contained in:
Pieter Vander Vennet 2023-04-07 03:54:11 +02:00
parent 2e9b1016de
commit f8d34648a0
28 changed files with 252 additions and 353 deletions

View file

@ -23,18 +23,18 @@ export default class SelectedElementTagsUpdater {
private readonly state: {
selectedElement: UIEventSource<Feature>
allElements: FeaturePropertiesStore
featureProperties: FeaturePropertiesStore
changes: Changes
osmConnection: OsmConnection
layoutToUse: LayoutConfig
layout: LayoutConfig
}
constructor(state: {
selectedElement: UIEventSource<Feature>
allElements: FeaturePropertiesStore
featureProperties: FeaturePropertiesStore
changes: Changes
osmConnection: OsmConnection
layoutToUse: LayoutConfig
layout: LayoutConfig
}) {
this.state = state
state.osmConnection.isLoggedIn.addCallbackAndRun((isLoggedIn) => {
@ -73,7 +73,7 @@ export default class SelectedElementTagsUpdater {
const latestTags = await OsmObject.DownloadPropertiesOf(id)
if (latestTags === "deleted") {
console.warn("The current selected element has been deleted upstream!")
const currentTagsSource = state.allElements.getStore(id)
const currentTagsSource = state.featureProperties.getStore(id)
if (currentTagsSource.data["_deleted"] === "yes") {
return
}
@ -91,7 +91,7 @@ export default class SelectedElementTagsUpdater {
private applyUpdate(latestTags: OsmTags, id: string) {
const state = this.state
try {
const leftRightSensitive = state.layoutToUse.isLeftRightSensitive()
const leftRightSensitive = state.layout.isLeftRightSensitive()
if (leftRightSensitive) {
SimpleMetaTagger.removeBothTagging(latestTags)
@ -116,7 +116,7 @@ export default class SelectedElementTagsUpdater {
// With the changes applied, we merge them onto the upstream object
let somethingChanged = false
const currentTagsSource = state.allElements.getStore(id)
const currentTagsSource = state.featureProperties.getStore(id)
const currentTags = currentTagsSource.data
for (const key in latestTags) {
let osmValue = latestTags[key]

View file

@ -82,7 +82,7 @@ export default class DeleteAction extends OsmChangeAction {
return await new ChangeTagAction(this._id, this._softDeletionTags, osmObject.tags, {
...this.meta,
changeType: "soft-delete",
}).CreateChangeDescriptions(changes)
}).CreateChangeDescriptions()
}
}
}

View file

@ -29,7 +29,7 @@ export class ChangesetHandler {
constructor(
dryRun: UIEventSource<boolean>,
osmConnection: OsmConnection,
allElements: { addAlias: (id0: String, id1: string) => void },
allElements: { addAlias: (id0: string, id1: string) => void },
changes: Changes
) {
this.osmConnection = osmConnection
@ -68,9 +68,9 @@ export class ChangesetHandler {
* The key is changed _in place_; true will be returned if a change has been applied
* @param extraMetaTags
* @param rewriteIds
* @private
* @public for testing purposes
*/
private static rewriteMetaTags(extraMetaTags: ChangesetTag[], rewriteIds: Map<string, string>) {
public static rewriteMetaTags(extraMetaTags: ChangesetTag[], rewriteIds: Map<string, string>) {
let hasChange = false
for (const tag of extraMetaTags) {
const match = tag.key.match(/^([a-zA-Z0-9_]+):(node\/-[0-9])$/)
@ -185,8 +185,10 @@ export class ChangesetHandler {
* @param extraMetaTags: new changeset tags to add/fuse with this changeset
* @param rewriteIds: the mapping of ids
* @param oldChangesetMeta: the metadata-object of the already existing changeset
*
* @public for testing purposes
*/
private RewriteTagsOf(
public RewriteTagsOf(
extraMetaTags: ChangesetTag[],
rewriteIds: Map<string, string>,
oldChangesetMeta: {
@ -305,6 +307,7 @@ export class ChangesetHandler {
return new Map<string, string>(mappings)
}
// noinspection JSUnusedLocalSymbols
private async CloseChangeset(changesetId: number = undefined): Promise<void> {
if (changesetId === undefined) {
return

View file

@ -59,7 +59,7 @@ export class OsmConnection {
oauth_secret: string
url: string
}
private readonly _dryRun: UIEventSource<boolean>
private readonly _dryRun: Store<boolean>
private fakeUser: boolean
private _onLoggedIn: ((userDetails: UserDetails) => void)[] = []
private readonly _iframeMode: Boolean | boolean
@ -67,7 +67,7 @@ export class OsmConnection {
private isChecking = false
constructor(options?: {
dryRun?: UIEventSource<boolean>
dryRun?: Store<boolean>
fakeUser?: false | boolean
oauth_token?: UIEventSource<string>
// Used to keep multiple changesets open and to write to the correct changeset

View file

@ -51,6 +51,8 @@ export default class UserRelatedState {
<LayerConfigJson>usersettings,
"userinformationpanel"
)
public static readonly availableUserSettingsIds: string[] =
UserRelatedState.usersettingsConfig.tagRenderings.map((tr) => tr.id)
constructor(
osmConnection: OsmConnection,