Rewrite the validator in ES6/Promises, several improvements here:

- implements a validation work queue, jobs are run during browser idle callbacks
- when merging base entities, don't run validations 2x on both base and head graphs (this was wasteful)
- keep track of resolved issues in a separate set (it's not a simple compare of base/head anymore)
  this happens after validation queue is empty and avoids race conditions and inaccurate resolved counts
This commit is contained in:
Bryan Housel
2021-01-25 11:42:06 -05:00
parent 4f369a85a5
commit 11201eb822
2 changed files with 553 additions and 449 deletions
+538 -441
View File
File diff suppressed because it is too large Load Diff
+15 -8
View File
@@ -24,20 +24,27 @@ describe('iD.coreValidator', function () {
expect(issues).to.have.lengthOf(0);
});
it('populates issues on validate', function() {
it('validate returns a promise, fulfilled when the validation has completed', function(done) {
createInvalidWay();
var validator = new iD.coreValidator(context);
validator.init();
var issues = validator.getIssues();
expect(issues).to.have.lengthOf(0);
validator.validate();
issues = validator.getIssues();
expect(issues).to.have.lengthOf(1);
var issue = issues[0];
expect(issue.type).to.eql('missing_tag');
expect(issue.entityIds).to.have.lengthOf(1);
expect(issue.entityIds[0]).to.eql('w-1');
var prom = validator.validate();
prom
.then(function() {
issues = validator.getIssues();
expect(issues).to.have.lengthOf(1);
var issue = issues[0];
expect(issue.type).to.eql('missing_tag');
expect(issue.entityIds).to.have.lengthOf(1);
expect(issue.entityIds[0]).to.eql('w-1');
})
.finally(done);
window.setTimeout(function() {}, 20); // async - to let the promise settle in phantomjs
});
});