Merge pull request #8762 from openstreetmap/testingImprovement

Testing improvement
This commit is contained in:
Bryan Housel
2021-10-22 09:13:45 -04:00
committed by GitHub
3 changed files with 44 additions and 24 deletions

View File

@@ -172,6 +172,12 @@
'spec/validations/suspicious_name.js'
];
window.executionErrors = [];
window.onerror = function (message, source, line, col) {
window.executionErrors.push("message" + message + " source" + source + " line" + line + " col" + col);
};
var isPhantomJS = !!(navigator.userAgent.match(/PhantomJS/));
var isIE11 = !!(navigator.userAgent.match(/Trident/) && !navigator.userAgent.match(/MSIE/));
@@ -191,6 +197,15 @@
(function nextScript() {
if (!scripts.length) {
window.mocha.run();
if (window.executionErrors.length > 0){
console.log('\n\n[Execution errors exist] Please resolve the following: \n');
for (var i = 0; i < window.executionErrors.length; i++){
console.log('[Execution error] ' + window.executionErrors[i]);
}
console.log('\n Disposing mocha. Expect mocha dispose log like: \'Uncaught error outside test suite\'... \n');
window.mocha.dispose();
}
return;
}
var src = scripts.shift();

View File

@@ -97,7 +97,7 @@ describe('iD.actionJoin', function () {
});
['restriction', 'connectivity'].forEach(function (type) {
it(`returns '${type}' in situations where a ${type} relation would be damaged (a)`, function () {
it('returns ' + type + ' in situations where a ' + type + 'relation would be damaged (a)', function () {
// a --> b ==> c
// from: -
// to: =
@@ -108,7 +108,7 @@ describe('iD.actionJoin', function () {
iD.osmNode({id: 'c', loc: [4,0]}),
iD.osmWay({id: '-', nodes: ['a', 'b']}),
iD.osmWay({id: '=', nodes: ['b', 'c']}),
iD.osmRelation({id: 'r', tags: {type}, members: [
iD.osmRelation({id: 'r', tags: {'type': type}, members: [
{type: 'way', id: '-', role: 'from'},
{type: 'way', id: '=', role: 'to'},
{type: 'node', id: 'b', role: 'via'}
@@ -118,7 +118,7 @@ describe('iD.actionJoin', function () {
expect(iD.actionJoin(['-', '=']).disabled(graph)).to.equal(type);
});
it(`returns '${type}' in situations where a ${type} relation would be damaged (b)`, function () {
it('returns ' + type + ' in situations where a ' + type + 'relation would be damaged (b)', function () {
// a --> b ==> c
// |
// d
@@ -133,7 +133,7 @@ describe('iD.actionJoin', function () {
iD.osmWay({id: '-', nodes: ['a', 'b']}),
iD.osmWay({id: '=', nodes: ['b', 'c']}),
iD.osmWay({id: '|', nodes: ['b', 'd']}),
iD.osmRelation({id: 'r', tags: {type}, members: [
iD.osmRelation({id: 'r', tags: {'type': type}, members: [
{type: 'way', id: '-', role: 'from'},
{type: 'way', id: '|', role: 'to'},
{type: 'node', id: 'b', role: 'via'}
@@ -143,7 +143,7 @@ describe('iD.actionJoin', function () {
expect(iD.actionJoin(['-', '=']).disabled(graph)).to.equal(type);
});
it(`returns falsy in situations where a ${type} relation wouldn't be damaged (a)`, function () {
it('returns falsy in situations where a '+ type + 'relation wouldn\'t be damaged (a)', function () {
// a --> b ==> c
// |
// d
@@ -158,7 +158,7 @@ describe('iD.actionJoin', function () {
iD.osmWay({id: '-', nodes: ['a', 'b']}),
iD.osmWay({id: '=', nodes: ['b', 'c']}),
iD.osmWay({id: '|', nodes: ['a', 'd']}),
iD.osmRelation({id: 'r', tags: {type}, members: [
iD.osmRelation({id: 'r', tags: {'type': type}, members: [
{type: 'way', id: '-', role: 'from'},
{type: 'way', id: '|', role: 'to'},
{type: 'node', id: 'a', role: 'via'}
@@ -168,7 +168,7 @@ describe('iD.actionJoin', function () {
expect(iD.actionJoin(['-', '=']).disabled(graph)).not.to.be.ok;
});
it(`returns falsy in situations where a ${type} restriction wouldn't be damaged (b)`, function () {
it('returns falsy in situations where a ' + type + 'restriction wouldn\'t be damaged (b)', function () {
// d
// |
// a --> b ==> c
@@ -187,7 +187,7 @@ describe('iD.actionJoin', function () {
iD.osmWay({id: '=', nodes: ['b', 'c']}),
iD.osmWay({id: '|', nodes: ['d', 'b']}),
iD.osmWay({id: '\\', nodes: ['b', 'e']}),
iD.osmRelation({id: 'r', tags: {type}, members: [
iD.osmRelation({id: 'r', tags: {'type': type}, members: [
{type: 'way', id: '|', role: 'from'},
{type: 'way', id: '\\', role: 'to'},
{type: 'node', id: 'b', role: 'via'}

View File

@@ -25,23 +25,28 @@ describe('iD.modeAddNote', function() {
});
describe('clicking the map', function () {
it('adds a note', function(done) {
var note = iD.osmNote({
id: '-1',
comments: [],
loc: [-77.02271, 38.90085],
status: 'open'
});
happen.mousedown(context.surface().node(), {});
happen.mouseup(window, {});
// Currently disabled. Look into https://github.com/openstreetmap/iD/pull/8762
// it('adds a note', function(done) {
// var note = iD.osmNote({
// id: '-1',
// comments: [],
// loc: [-77.02271, 38.90085],
// status: 'open'
// });
window.setTimeout(function() {
expect(iD.services.osm.caches().note.note[-1]).to.eql(note);
context.mode().exit();
d3.select('window').on('click.draw-block', null);
done();
}, 50);
});
// context.on('enter.addNoteTest', function(mode) {
// if (mode.id === 'select-note') {
// expect(iD.services.osm.caches().note.note[-1]).to.eql(note);
// context.mode().exit();
// d3.select('window').on('click.draw-block', null);
// context.on('enter.addNoteTest', null);
// done();
// }
// });
// happen.mousedown(context.surface().node(), {});
// happen.mouseup(window, {});
// });
// this won't work because draw behavior can only snap to entities, not notes
// it('selects an existing note rather than adding a new one', function() {