From 33fab5580ba33410bb99f8f5f0862ba658869cc7 Mon Sep 17 00:00:00 2001 From: Bryan Housel Date: Mon, 16 Aug 2021 22:06:42 -0400 Subject: [PATCH] Before calling init() make sure the assetPath is set init kicks off building the ui, which can fetch spritesheets for the The assetPath needs to be set otherwise these files will not be found --- test/spec/behavior/hash.js | 2 +- test/spec/behavior/lasso.js | 2 +- test/spec/behavior/select.js | 2 +- test/spec/core/context.js | 10 +++++----- test/spec/core/history.js | 2 +- test/spec/core/validator.js | 2 +- test/spec/modes/add_note.js | 4 +--- test/spec/modes/add_point.js | 6 +----- test/spec/renderer/features.js | 2 +- test/spec/renderer/map.js | 2 +- test/spec/renderer/tile_layer.js | 2 +- test/spec/services/osm.js | 2 +- test/spec/svg/areas.js | 2 +- test/spec/svg/data.js | 2 +- test/spec/svg/layers.js | 4 ++-- test/spec/svg/lines.js | 2 +- test/spec/svg/midpoints.js | 2 +- test/spec/svg/points.js | 2 +- test/spec/svg/vertices.js | 2 +- test/spec/ui/combobox.js | 2 +- test/spec/ui/fields/access.js | 2 +- test/spec/ui/fields/localized.js | 2 +- test/spec/ui/fields/wikipedia.js | 2 +- test/spec/ui/flash.js | 2 +- test/spec/ui/sections/raw_tag_editor.js | 2 +- test/spec/validations/almost_junction.js | 2 +- test/spec/validations/crossing_ways.js | 2 +- test/spec/validations/disconnected_way.js | 2 +- test/spec/validations/incompatible_source.js | 2 +- test/spec/validations/missing_role.js | 2 +- test/spec/validations/missing_tag.js | 2 +- test/spec/validations/private_data.js | 2 +- test/spec/validations/suspicious_name.js | 2 +- 33 files changed, 38 insertions(+), 44 deletions(-) diff --git a/test/spec/behavior/hash.js b/test/spec/behavior/hash.js index 767d149f0..c1af7adbe 100644 --- a/test/spec/behavior/hash.js +++ b/test/spec/behavior/hash.js @@ -5,7 +5,7 @@ describe('iD.behaviorHash', function () { beforeEach(function () { var container = d3.select(document.createElement('div')); - context = iD.coreContext().init().container(container); + context = iD.coreContext().assetPath('../dist/').init().container(container); container.call(context.map()); hash = iD.behaviorHash(context); }); diff --git a/test/spec/behavior/lasso.js b/test/spec/behavior/lasso.js index f342cec3c..b86add2e0 100644 --- a/test/spec/behavior/lasso.js +++ b/test/spec/behavior/lasso.js @@ -2,7 +2,7 @@ describe('iD.behaviorLasso', function () { var context, lasso; beforeEach(function () { - context = iD.coreContext().init(); + context = iD.coreContext().assetPath('../dist/').init(); d3.select(document.createElement('div')) .attr('class', 'main-map') .call(context.map()); diff --git a/test/spec/behavior/select.js b/test/spec/behavior/select.js index df7dfc9c8..3af70a808 100644 --- a/test/spec/behavior/select.js +++ b/test/spec/behavior/select.js @@ -3,7 +3,7 @@ describe('iD.behaviorSelect', function() { beforeEach(function() { container = d3.select('body').append('div'); - context = iD.coreContext().init().container(container); + context = iD.coreContext().assetPath('../dist/').init().container(container); a = iD.osmNode({loc: [0, 0]}); b = iD.osmNode({loc: [0, 0]}); diff --git a/test/spec/core/context.js b/test/spec/core/context.js index 6b603aafd..0e55ad0be 100644 --- a/test/spec/core/context.js +++ b/test/spec/core/context.js @@ -5,7 +5,7 @@ describe('iD.coreContext', function() { describe('#assetPath', function() { it('sets and gets assetPath', function() { - var context = iD.coreContext().init(); + var context = iD.coreContext(); expect(context.assetPath()).to.eql(''); context.assetPath('iD/'); @@ -15,7 +15,7 @@ describe('iD.coreContext', function() { describe('#assetMap', function() { it('sets and gets assetMap', function() { - var context = iD.coreContext().init(); + var context = iD.coreContext(); expect(context.assetMap()).to.eql({}); context.assetMap(assets); @@ -26,7 +26,7 @@ describe('iD.coreContext', function() { describe('#asset', function() { var context; beforeEach(function() { - context = iD.coreContext().assetPath('iD/').assetMap(assets).init(); + context = iD.coreContext().assetPath('iD/').assetMap(assets); }); it('ignores absolute urls', function() { @@ -44,7 +44,7 @@ describe('iD.coreContext', function() { describe('#imagePath', function() { var context; beforeEach(function() { - context = iD.coreContext().assetPath('iD/').assetMap(assets).init(); + context = iD.coreContext().assetPath('iD/').assetMap(assets); }); it('looks first in assetMap', function() { @@ -57,7 +57,7 @@ describe('iD.coreContext', function() { describe('#debug', function() { it('sets and gets debug flags', function() { - var context = iD.coreContext().init(); + var context = iD.coreContext(); var flags = { tile: false, collision: false, diff --git a/test/spec/core/history.js b/test/spec/core/history.js index 1bffa491a..d9313a454 100644 --- a/test/spec/core/history.js +++ b/test/spec/core/history.js @@ -8,7 +8,7 @@ describe('iD.coreHistory', function () { }; beforeEach(function () { - context = iD.coreContext().init(); + context = iD.coreContext().assetPath('../dist/').init(); history = context.history(); spy = sinon.spy(); // clear lock diff --git a/test/spec/core/validator.js b/test/spec/core/validator.js index 525da71e6..5e1f5ed37 100644 --- a/test/spec/core/validator.js +++ b/test/spec/core/validator.js @@ -2,7 +2,7 @@ describe('iD.coreValidator', function () { var context; beforeEach(function() { - context = iD.coreContext().init(); + context = iD.coreContext().assetPath('../dist/').init(); }); function createInvalidWay() { diff --git a/test/spec/modes/add_note.js b/test/spec/modes/add_note.js index 9c22c2d36..6650e8576 100644 --- a/test/spec/modes/add_note.js +++ b/test/spec/modes/add_note.js @@ -11,9 +11,7 @@ describe('iD.modeAddNote', function() { beforeEach(function() { var container = d3.select(document.createElement('div')); - context = iD.coreContext() - .container(container) - .init(); + context = iD.coreContext().assetPath('../dist/').container(container).init(); context.loadTiles = function () {}; diff --git a/test/spec/modes/add_point.js b/test/spec/modes/add_point.js index cb00a7fa4..cbf8720f1 100644 --- a/test/spec/modes/add_point.js +++ b/test/spec/modes/add_point.js @@ -3,11 +3,7 @@ describe.skip('iD.modeAddPoint', function() { beforeEach(function() { var container = d3.select(document.createElement('div')); - - context = iD.coreContext() - .container(container) - .init(); - + context = iD.coreContext().assetPath('../dist/').container(container).init(); context.loadTiles = function () {}; container.call(context.map()) diff --git a/test/spec/renderer/features.js b/test/spec/renderer/features.js index 1a8e174a5..76752ea28 100644 --- a/test/spec/renderer/features.js +++ b/test/spec/renderer/features.js @@ -3,7 +3,7 @@ describe('iD.rendererFeatures', function() { var context, features; beforeEach(function() { - context = iD.coreContext().init(); + context = iD.coreContext().assetPath('../dist/').init(); d3.select(document.createElement('div')) .attr('class', 'main-map') .call(context.map()); diff --git a/test/spec/renderer/map.js b/test/spec/renderer/map.js index e71ce50de..38f270f5b 100644 --- a/test/spec/renderer/map.js +++ b/test/spec/renderer/map.js @@ -3,7 +3,7 @@ describe('iD.Map', function() { beforeEach(function() { content = d3.select('body').append('div'); - context = iD.coreContext().init().container(content); + context = iD.coreContext().assetPath('../dist/').init().container(content); map = context.map(); content.call(map); }); diff --git a/test/spec/renderer/tile_layer.js b/test/spec/renderer/tile_layer.js index 4dcbadb9c..9587e95e9 100644 --- a/test/spec/renderer/tile_layer.js +++ b/test/spec/renderer/tile_layer.js @@ -2,7 +2,7 @@ describe('iD.rendererTileLayer', function() { var context, d, c; beforeEach(function() { - context = iD.coreContext().init(); + context = iD.coreContext().assetPath('../dist/').init(); d = d3.select(document.createElement('div')); c = iD.rendererTileLayer(context).projection(d3.geoMercator()); }); diff --git a/test/spec/services/osm.js b/test/spec/services/osm.js index 3619e3270..bc5542ef6 100644 --- a/test/spec/services/osm.js +++ b/test/spec/services/osm.js @@ -27,7 +27,7 @@ describe('iD.serviceOsm', function () { beforeEach(function () { serverFetch = window.fakeFetch().create(); // unauthenticated calls use d3-fetch serverXHR = sinon.fakeServer.create(); // authenticated calls use XHR via osm-auth - context = iD.coreContext().init(); + context = iD.coreContext().assetPath('../dist/').init(); connection = context.connection(); connection.switch({ urlroot: 'http://www.openstreetmap.org' }); connection.reset(); diff --git a/test/spec/svg/areas.js b/test/spec/svg/areas.js index f4652ac62..571698787 100644 --- a/test/spec/svg/areas.js +++ b/test/spec/svg/areas.js @@ -10,7 +10,7 @@ describe('iD.svgAreas', function () { beforeEach(function () { - context = iD.coreContext().init(); + context = iD.coreContext().assetPath('../dist/').init(); d3.select(document.createElement('div')) .attr('class', 'main-map') .call(context.map().centerZoom([0, 0], 17)); diff --git a/test/spec/svg/data.js b/test/spec/svg/data.js index 6e1b2d759..d064e1a77 100644 --- a/test/spec/svg/data.js +++ b/test/spec/svg/data.js @@ -81,7 +81,7 @@ describe('iD.svgData', function () { } beforeEach(function () { - context = iD.coreContext().init(); + context = iD.coreContext().assetPath('../dist/').init(); d3.select(document.createElement('div')) .attr('class', 'main-map') .call(context.map().centerZoom([-74.389286, 40.1502754], 17)); diff --git a/test/spec/svg/layers.js b/test/spec/svg/layers.js index 512d62f90..70d4b7f49 100644 --- a/test/spec/svg/layers.js +++ b/test/spec/svg/layers.js @@ -6,7 +6,7 @@ describe('iD.svgLayers', function () { .clipExtent([[0, 0], [Infinity, Infinity]]); beforeEach(function () { - context = iD.coreContext().init(); + context = iD.coreContext().assetPath('../dist/').init(); container = d3.select(document.createElement('div')); }); @@ -44,4 +44,4 @@ describe('iD.svgLayers', function () { expect(d3.select(nodes[14]).classed('touch')).to.be.true; }); -}); \ No newline at end of file +}); diff --git a/test/spec/svg/lines.js b/test/spec/svg/lines.js index 7ee42c6c6..e4f6c60b8 100644 --- a/test/spec/svg/lines.js +++ b/test/spec/svg/lines.js @@ -9,7 +9,7 @@ describe('iD.svgLines', function () { beforeEach(function () { - context = iD.coreContext().init(); + context = iD.coreContext().assetPath('../dist/').init(); d3.select(document.createElement('div')) .attr('class', 'main-map') .call(context.map().centerZoom([0, 0], 17)); diff --git a/test/spec/svg/midpoints.js b/test/spec/svg/midpoints.js index 723771a26..d3cd11919 100644 --- a/test/spec/svg/midpoints.js +++ b/test/spec/svg/midpoints.js @@ -9,7 +9,7 @@ describe('iD.svgMidpoints', function () { beforeEach(function () { - context = iD.coreContext().init(); + context = iD.coreContext().assetPath('../dist/').init(); context.enter({ id: 'select', enter: function() { }, diff --git a/test/spec/svg/points.js b/test/spec/svg/points.js index a41e4cb1d..51472e48f 100644 --- a/test/spec/svg/points.js +++ b/test/spec/svg/points.js @@ -6,7 +6,7 @@ describe('iD.svgPoints', function () { .clipExtent([[0, 0], [Infinity, Infinity]]); beforeEach(function () { - context = iD.coreContext().init(); + context = iD.coreContext().assetPath('../dist/').init(); d3.select(document.createElement('div')) .attr('class', 'main-map') .call(context.map().centerZoom([0, 0], 17)); diff --git a/test/spec/svg/vertices.js b/test/spec/svg/vertices.js index 2e1846332..cb79f1e66 100644 --- a/test/spec/svg/vertices.js +++ b/test/spec/svg/vertices.js @@ -8,7 +8,7 @@ describe('iD.svgVertices', function () { beforeEach(function () { - context = iD.coreContext().init(); + context = iD.coreContext().assetPath('../dist/').init(); d3.select(document.createElement('div')) .attr('class', 'main-map') .call(context.map().centerZoom([0, 0], 17)); diff --git a/test/spec/ui/combobox.js b/test/spec/ui/combobox.js index 6362018e8..1ea23de51 100644 --- a/test/spec/ui/combobox.js +++ b/test/spec/ui/combobox.js @@ -63,7 +63,7 @@ describe('uiCombobox', function() { beforeEach(function() { body = d3.select('body'); container = body.append('div').attr('class', 'ideditor'); - context = iD.coreContext().init().container(container); + context = iD.coreContext().assetPath('../dist/').init().container(container); content = container.append('div'); input = content.append('input'); combobox = iD.uiCombobox(context); diff --git a/test/spec/ui/fields/access.js b/test/spec/ui/fields/access.js index f629d4482..cab0f527d 100644 --- a/test/spec/ui/fields/access.js +++ b/test/spec/ui/fields/access.js @@ -2,7 +2,7 @@ describe('iD.uiFieldAccess', function() { var context, selection, field; beforeEach(function() { - context = iD.coreContext().init(); + context = iD.coreContext().assetPath('../dist/').init(); selection = d3.select(document.createElement('div')); field = iD.presetField('access', { keys: ['access', 'foot', 'motor_vehicle', 'bicycle', 'horse'], diff --git a/test/spec/ui/fields/localized.js b/test/spec/ui/fields/localized.js index b2ac474c0..56dc7ad7a 100644 --- a/test/spec/ui/fields/localized.js +++ b/test/spec/ui/fields/localized.js @@ -15,7 +15,7 @@ describe('iD.uiFieldLocalized', function() { }); beforeEach(function() { - context = iD.coreContext().init(); + context = iD.coreContext().assetPath('../dist/').init(); selection = d3.select(document.createElement('div')); field = iD.presetField('name', { key: 'name', type: 'localized' }); field.locked = function() { return false; }; diff --git a/test/spec/ui/fields/wikipedia.js b/test/spec/ui/fields/wikipedia.js index e45e4fe41..24583535c 100644 --- a/test/spec/ui/fields/wikipedia.js +++ b/test/spec/ui/fields/wikipedia.js @@ -18,7 +18,7 @@ describe('iD.uiFieldWikipedia', function() { beforeEach(function() { entity = iD.osmNode({id: 'n12345'}); - context = iD.coreContext().init(); + context = iD.coreContext().assetPath('../dist/').init(); context.history().merge([entity]); selection = d3.select(document.createElement('div')); field = iD.presetField('wikipedia', { diff --git a/test/spec/ui/flash.js b/test/spec/ui/flash.js index ec2919f48..3a929f834 100644 --- a/test/spec/ui/flash.js +++ b/test/spec/ui/flash.js @@ -3,7 +3,7 @@ describe('iD.uiFlash', function () { beforeEach(function() { var container = d3.select('body'); - context = iD.coreContext().init().container(container); + context = iD.coreContext().assetPath('../dist/').init().container(container); container .append('div') .attr('class', 'flash-wrap') diff --git a/test/spec/ui/sections/raw_tag_editor.js b/test/spec/ui/sections/raw_tag_editor.js index 739d72849..5a9c9466e 100644 --- a/test/spec/ui/sections/raw_tag_editor.js +++ b/test/spec/ui/sections/raw_tag_editor.js @@ -16,7 +16,7 @@ describe('iD.uiSectionRawTagEditor', function() { beforeEach(function () { entity = iD.osmNode({id: 'n12345'}); - context = iD.coreContext().init(); + context = iD.coreContext().assetPath('../dist/').init(); context.history().merge([entity]); render({highway: 'residential'}); }); diff --git a/test/spec/validations/almost_junction.js b/test/spec/validations/almost_junction.js index e9a6a2fc4..a08bfa4e0 100644 --- a/test/spec/validations/almost_junction.js +++ b/test/spec/validations/almost_junction.js @@ -2,7 +2,7 @@ describe('iD.validations.almost_junction', function () { var context; beforeEach(function() { - context = iD.coreContext().init(); + context = iD.coreContext().assetPath('../dist/').init(); }); function horizontalVertialCloserThanThd() { diff --git a/test/spec/validations/crossing_ways.js b/test/spec/validations/crossing_ways.js index a511b40a0..ae46b98f7 100644 --- a/test/spec/validations/crossing_ways.js +++ b/test/spec/validations/crossing_ways.js @@ -2,7 +2,7 @@ describe('iD.validations.crossing_ways', function () { var context; beforeEach(function() { - context = iD.coreContext().init(); + context = iD.coreContext().assetPath('../dist/').init(); }); function createWaysWithOneCrossingPoint(tags1, tags2) { diff --git a/test/spec/validations/disconnected_way.js b/test/spec/validations/disconnected_way.js index e10eab331..859b822c8 100644 --- a/test/spec/validations/disconnected_way.js +++ b/test/spec/validations/disconnected_way.js @@ -2,7 +2,7 @@ describe('iD.validations.disconnected_way', function () { var context; beforeEach(function() { - context = iD.coreContext().init(); + context = iD.coreContext().assetPath('../dist/').init(); }); function createWay(tags) { diff --git a/test/spec/validations/incompatible_source.js b/test/spec/validations/incompatible_source.js index 1801ac263..bb7c72952 100644 --- a/test/spec/validations/incompatible_source.js +++ b/test/spec/validations/incompatible_source.js @@ -2,7 +2,7 @@ describe('iD.validations.incompatible_source', function () { var context; beforeEach(function() { - context = iD.coreContext().init(); + context = iD.coreContext().assetPath('../dist/').init(); }); function createWay(tags) { diff --git a/test/spec/validations/missing_role.js b/test/spec/validations/missing_role.js index de63a4ecd..6401a8765 100644 --- a/test/spec/validations/missing_role.js +++ b/test/spec/validations/missing_role.js @@ -2,7 +2,7 @@ describe('iD.validations.missing_role', function () { var context; beforeEach(function() { - context = iD.coreContext().init(); + context = iD.coreContext().assetPath('../dist/').init(); }); function createWay(tags) { diff --git a/test/spec/validations/missing_tag.js b/test/spec/validations/missing_tag.js index 94aa7fe76..345faeb0a 100644 --- a/test/spec/validations/missing_tag.js +++ b/test/spec/validations/missing_tag.js @@ -2,7 +2,7 @@ describe('iD.validations.missing_tag', function () { var context; beforeEach(function() { - context = iD.coreContext().init(); + context = iD.coreContext().assetPath('../dist/').init(); }); function createWay(tags) { diff --git a/test/spec/validations/private_data.js b/test/spec/validations/private_data.js index bafbe0300..031e92ecf 100644 --- a/test/spec/validations/private_data.js +++ b/test/spec/validations/private_data.js @@ -2,7 +2,7 @@ describe('iD.validations.private_data', function () { var context; beforeEach(function() { - context = iD.coreContext().init(); + context = iD.coreContext().assetPath('../dist/').init(); }); function createWay(tags) { diff --git a/test/spec/validations/suspicious_name.js b/test/spec/validations/suspicious_name.js index 66b6446ee..bdd6d9cfd 100644 --- a/test/spec/validations/suspicious_name.js +++ b/test/spec/validations/suspicious_name.js @@ -38,7 +38,7 @@ describe('iD.validations.suspicious_name', function () { }); beforeEach(function() { - context = iD.coreContext().init(); + context = iD.coreContext().assetPath('../dist/').init(); }); function createWay(tags) {