miguelcobain/ember-leaflet

Dynamically setting bounds errors asynchronously in test

Opened this issue · 1 comments

I have an if block in my template to choose between layers.marker or layers.geojson depending on my data, so I was updating my @bounds={{this.bounds}} with this.bounds = layer.getBounds() inside @onLayeradd. This seems to work fine, but for some reason in test--some few tests after the actual test that contains the map--I get the following error that fails a later unrelated test:

TypeError: Cannot read properties of undefined (reading '_leaflet_pos')
Source: 	
TypeError: Cannot read properties of undefined (reading '_leaflet_pos')
    at getPosition (http://localhost:7357/assets/vendor.js:62595:14)
    at NewClass._getMapPanePos (http://localhost:7357/assets/vendor.js:64633:12)
    at NewClass._getNewPixelOrigin (http://localhost:7357/assets/vendor.js:64650:69)
    at NewClass._move (http://localhost:7357/assets/vendor.js:64369:30)
    at NewClass._onZoomTransitionEnd (http://localhost:7357/assets/vendor.js:64871:10)

Stack trace:

getPosition (leaflet-src.js:2563)
_getMapPanePos (leaflet-src.js:4601)
_getNewPixelOrigin (leaflet-src.js:4618)
_move (leaflet-src.js:4337)
_onZoomTransitionEnd (leaflet-src.js:4839)
setTimeout (async)
_animateZoom (leaflet-src.js:4827)
(anonymous) (leaflet-src.js:4792)
requestAnimationFrame (async)
requestAnimFrame (leaflet-src.js:245)
_tryAnimatedZoom (leaflet-src.js:4789)
setView (leaflet-src.js:3308)
fitBounds (leaflet-src.js:3408)
updateOption (base-layer.js:270)
(anonymous) (runtime.js:7012)
compute (did-update.js:32)
getValue (index.js:2931)
(anonymous) (manager.js:399)
(anonymous) (reference.js:170)
track (validator.js:798)
valueForRef (reference.js:169)
evaluate (runtime.js:2599)
_execute (runtime.js:5231)
(anonymous) (runtime.js:5201)
runInTrackingTransaction (validator.js:158)
execute (runtime.js:5201)
rerender (runtime.js:5580)
(anonymous) (index.js:5395)
(anonymous) (index.js:5361)
(anonymous) (index.js:5713)
inTransaction (runtime.js:5020)
_renderRoots (index.js:5692)
_renderRootsTransaction (index.js:5745)
_revalidate (index.js:5786)
invoke (backburner.js:351)
flush (backburner.js:241)
flush (backburner.js:447)
_end (backburner.js:999)
end (backburner.js:729)
_run (backburner.js:1054)
_join (backburner.js:1028)
join (backburner.js:779)
loopEnd (index.js:5503)
_trigger (backburner.js:1123)
_end (backburner.js:1018)
Backburner._boundAutorunEnd (backburner.js:648)
Promise.then (async)
iterations (backburner.js:28)
flush (index.js:45)
_scheduleAutorun (backburner.js:1218)
_end (backburner.js:1009)
Backburner._boundAutorunEnd (backburner.js:648)
Promise.then (async)
iterations (backburner.js:28)
flush (index.js:45)
_scheduleAutorun (backburner.js:1218)
_end (backburner.js:1009)
Backburner._boundAutorunEnd (backburner.js:648)
Promise.then (async)
iterations (backburner.js:28)
flush (index.js:45)
_scheduleAutorun (backburner.js:1218)
_end (backburner.js:1009)
Backburner._boundAutorunEnd (backburner.js:648)
Promise.then (async)
iterations (backburner.js:28)
flush (index.js:45)
_scheduleAutorun (backburner.js:1218)
_end (backburner.js:1009)
Backburner._boundAutorunEnd (backburner.js:648)
Promise.then (async)
iterations (backburner.js:28)
flush (index.js:45)
_scheduleAutorun (backburner.js:1218)
_end (backburner.js:1009)
Backburner._boundAutorunEnd (backburner.js:648)
Promise.then (async)
iterations (backburner.js:28)
flush (index.js:45)
_scheduleAutorun (backburner.js:1218)
_end (backburner.js:1009)
Backburner._boundAutorunEnd (backburner.js:648)
Promise.then (async)
iterations (backburner.js:28)
flush (index.js:45)
_scheduleAutorun (backburner.js:1218)
_end (backburner.js:1009)
Backburner._boundAutorunEnd (backburner.js:648)
Promise.then (async)
iterations (backburner.js:28)
flush (index.js:45)
_scheduleAutorun (backburner.js:1218)
_ensureInstance (backburner.js:1206)
schedule (backburner.js:805)
(anonymous) (rsvp.js:14)
then (rsvp.js:560)
resolve (router_js.js:1165)
Transition (router_js.js:301)
getTransitionByIntent (router_js.js:1611)
transitionByIntent (router_js.js:1539)
doTransition (router_js.js:1687)
handleURL (router_js.js:2147)
_doURLTransition (router.js:565)
handleURL (router.js:559)
visit (instance.js:251)
(anonymous) (setup-application-context.js:114)
Promise.then (async)
visit (setup-application-context.js:113)
(anonymous) (leaflet-test.js:8)
runTest (qunit.js:465)
run (qunit.js:463)
eval (qunit.js:505)
processTaskQueue (qunit.js:390)
advanceTaskQueue (qunit.js:384)
advance (qunit.js:382)
eval (qunit.js:591)
setTimeout (async)
internalStart (qunit.js:591)
release (qunit.js:575)
resolve (qunit.js:576)
Promise.then (async)
resolvePromise (qunit.js:578)
callHook (qunit.js:467)
runHook (qunit.js:476)
processTaskQueue (qunit.js:390)
advanceTaskQueue (qunit.js:384)
advance (qunit.js:382)
eval (qunit.js:591)
setTimeout (async)
internalStart (qunit.js:591)
release (qunit.js:575)
resolve (qunit.js:576)
Promise.then (async)
resolvePromise (qunit.js:578)
callHook (qunit.js:467)
runHook (qunit.js:476)
processTaskQueue (qunit.js:390)
eval (qunit.js:390)
Promise.then (async)
processTaskQueue (qunit.js:390)
eval (qunit.js:390)
Promise.then (async)
processTaskQueue (qunit.js:390)
advanceTaskQueue (qunit.js:384)
advance (qunit.js:382)
advanceTestQueue (qunit.js:392)
advance (qunit.js:382)
unblockAndAdvanceQueue (qunit.js:751)
Promise.then (async)
begin (qunit.js:759)
eval (qunit.js:751)
setTimeout (async)
scheduleBegin (qunit.js:751)
load (qunit.js:750)
load (async)
addEvent (qunit.js:852)
eval (qunit.js:944)
eval (qunit.js:963)
eval (qunit.js:1260)
./node_modules/qunit/qunit/qunit.js (chunk.vendors-node_modules_qunit_qunit_qunit_js.ddea705634baced826d9.js:17)
__webpack_require__ (chunk.tests.9e760c6f445887b02182.js:53)
eval (tests.js:15)
Module.exports (loader.js:106)
Module._reify (loader.js:143)
Module.reify (loader.js:130)
Module.exports (loader.js:104)
requireModule (loader.js:27)
(anonymous) (tests-suffix.js:1)

I changed my code to set bounds from the start (L.geoJSON(this.geoJSON).getBounds()) and it the error seems to go away. I'll be using this new pattern from here on out, but figured I'd put up an issue considering if @bounds is intended to be updatable.

Would it be possible to submit a PR with a failing test?
I could take a look at that.
Perhaps that would unveil the bug under the hood.