revalidate entities with changed relation memberships

This commit is contained in:
Martin Raifer
2025-02-18 13:18:09 +01:00
parent 0a6cbf3ebc
commit 918126e5f8
3 changed files with 83 additions and 3 deletions

View File

@@ -102,4 +102,67 @@ describe('iD.coreValidator', function() {
issues = validator.getIssues();
expect(issues).to.have.lengthOf(1);
});
it('removes validation issue when untagged way is becomes part of a boundary relation', async () => {
var n1 = iD.osmNode({ id: 'n-1', loc: [4, 4] });
var n2 = iD.osmNode({ id: 'n-2', loc: [4, 5] });
var n3 = iD.osmNode({ id: 'n-3', loc: [4, 6] });
var w1 = iD.osmWay({ id: 'w-1', nodes: ['n-1', 'n-2'], tags: { 'note': 'foo' } });
var w2 = iD.osmWay({ id: 'w-2', nodes: ['n-2', 'n-3'], tags: {} });
var r = iD.osmRelation({ id: 'r-1', members: [{ id: 'w-2' }], tags: { 'type': 'boundary' } });
context.perform(
iD.actionAddEntity(n1),
iD.actionAddEntity(n2),
iD.actionAddEntity(n3),
iD.actionAddEntity(w1),
iD.actionAddEntity(w2),
iD.actionAddEntity(r)
);
var validator = new iD.coreValidator(context);
validator.init();
await validator.validate();
// There should be a validation error about the untagged way
let issues = validator.getIssues();
expect(issues).to.have.lengthOf(1);
// add way to relation
context.perform(
iD.actionAddMember(r.id, { id: w1.id })
);
await validator.validate();
// Validation error should be fixed
issues = validator.getIssues();
expect(issues).to.have.lengthOf(0);
});
it('add validation issue when untagged way is removed from boundary relation', async () => {
// A way is "untagged", but part of a larger (boundary) relation
var n1 = iD.osmNode({ id: 'n-1', loc: [4, 4] });
var n2 = iD.osmNode({ id: 'n-2', loc: [4, 5] });
var w1 = iD.osmWay({ id: 'w-1', nodes: ['n-1', 'n-2'], tags: { 'note': 'foo' } });
var r = iD.osmRelation({ id: 'r-1', members: [{ id: 'w-1' }], tags: { 'type': 'boundary' } });
context.perform(
iD.actionAddEntity(n1),
iD.actionAddEntity(n2),
iD.actionAddEntity(w1),
iD.actionAddEntity(r)
);
var validator = new iD.coreValidator(context);
validator.init();
await validator.validate();
// Should be no errors
let issues = validator.getIssues();
expect(issues).to.have.lengthOf(0);
// delete relation
context.perform(
iD.actionDeleteRelation(r.id)
);
await validator.validate();
// Should produce untagged feature error
issues = validator.getIssues();
expect(issues).to.have.lengthOf(1);
});
});