diff --git a/core/js/js.js b/core/js/js.js index 1d3ec6ec778..69ebabdb419 100644 --- a/core/js/js.js +++ b/core/js/js.js @@ -752,7 +752,8 @@ var OC={ // sometimes "beforeunload" happens later, so need to defer the reload a bit setTimeout(function() { if (!self._userIsNavigatingAway && !self._reloadCalled) { - OC.reload(); + OC.Notification.show(t('core', 'Problem loading page, reloading in 5 seconds')); + setTimeout(OC.reload, 5000); // only call reload once self._reloadCalled = true; } diff --git a/core/js/tests/specs/coreSpec.js b/core/js/tests/specs/coreSpec.js index 02eb1b95c1d..3d19a38c416 100644 --- a/core/js/tests/specs/coreSpec.js +++ b/core/js/tests/specs/coreSpec.js @@ -938,10 +938,13 @@ describe('Core base tests', function() { }); describe('global ajax errors', function() { var reloadStub, ajaxErrorStub, clock; + var notificationStub; + var waitTimeMs = 6000; beforeEach(function() { clock = sinon.useFakeTimers(); reloadStub = sinon.stub(OC, 'reload'); + notificationStub = sinon.stub(OC.Notification, 'show'); // unstub the error processing method ajaxErrorStub = OC._processAjaxError; ajaxErrorStub.restore(); @@ -949,6 +952,7 @@ describe('Core base tests', function() { }); afterEach(function() { reloadStub.restore(); + notificationStub.restore(); clock.restore(); }); @@ -973,7 +977,7 @@ describe('Core base tests', function() { $(document).trigger(new $.Event('ajaxError'), xhr); // trigger timers - clock.tick(1000); + clock.tick(waitTimeMs); if (expectedCall) { expect(reloadStub.calledOnce).toEqual(true); @@ -989,7 +993,7 @@ describe('Core base tests', function() { $(document).trigger(new $.Event('ajaxError'), xhr); // trigger timers - clock.tick(1000); + clock.tick(waitTimeMs); expect(reloadStub.calledOnce).toEqual(true); }); @@ -1000,9 +1004,17 @@ describe('Core base tests', function() { $(document).trigger(new $.Event('ajaxError'), xhr); - clock.tick(1000); + clock.tick(waitTimeMs); expect(reloadStub.notCalled).toEqual(true); }); + it('displays notification', function() { + var xhr = { status: 401 }; + + $(document).trigger(new $.Event('ajaxError'), xhr); + + clock.tick(waitTimeMs); + expect(notificationStub.calledOnce).toEqual(true); + }); }); });