diff --git a/polygerrit-ui/app/elements/admin/gr-plugin-list/gr-plugin-list.js b/polygerrit-ui/app/elements/admin/gr-plugin-list/gr-plugin-list.js index 1bcbcaa55c..6cbc94a6ca 100644 --- a/polygerrit-ui/app/elements/admin/gr-plugin-list/gr-plugin-list.js +++ b/polygerrit-ui/app/elements/admin/gr-plugin-list/gr-plugin-list.js @@ -81,7 +81,10 @@ }, _getPlugins(filter, pluginsPerPage, offset) { - return this.$.restAPI.getPlugins(filter, pluginsPerPage, offset) + const errFn = response => { + this.fire('page-error', {response}); + }; + return this.$.restAPI.getPlugins(filter, pluginsPerPage, offset, errFn) .then(plugins => { if (!plugins) { this._plugins = []; diff --git a/polygerrit-ui/app/elements/admin/gr-plugin-list/gr-plugin-list_test.html b/polygerrit-ui/app/elements/admin/gr-plugin-list/gr-plugin-list_test.html index 5752aa13ac..9781cf74ec 100644 --- a/polygerrit-ui/app/elements/admin/gr-plugin-list/gr-plugin-list_test.html +++ b/polygerrit-ui/app/elements/admin/gr-plugin-list/gr-plugin-list_test.html @@ -131,8 +131,12 @@ limitations under the License. offset: 25, }; element._paramsChanged(value).then(() => { - assert.isTrue(element.$.restAPI.getPlugins.lastCall - .calledWithExactly('test', 25, 25)); + assert.equal(element.$.restAPI.getPlugins.lastCall.args[0], + 'test'); + assert.equal(element.$.restAPI.getPlugins.lastCall.args[1], + 25); + assert.equal(element.$.restAPI.getPlugins.lastCall.args[2], + 25); done(); }); }); @@ -152,5 +156,26 @@ limitations under the License. assert.equal(getComputedStyle(element.$.loading).display, 'none'); }); }); + + suite('404', () => { + test('fires page-error', done => { + const response = {status: 404}; + sandbox.stub(element.$.restAPI, 'getPlugins', + (filter, pluginsPerPage, opt_offset, errFn) => { + errFn(response); + }); + + element.addEventListener('page-error', e => { + assert.deepEqual(e.detail.response, response); + done(); + }); + + const value = { + filter: 'test', + offset: 25, + }; + element._paramsChanged(value); + }); + }); }); diff --git a/polygerrit-ui/app/elements/admin/gr-repo-detail-list/gr-repo-detail-list.js b/polygerrit-ui/app/elements/admin/gr-repo-detail-list/gr-repo-detail-list.js index eaad353b35..feaadc73e2 100644 --- a/polygerrit-ui/app/elements/admin/gr-repo-detail-list/gr-repo-detail-list.js +++ b/polygerrit-ui/app/elements/admin/gr-repo-detail-list/gr-repo-detail-list.js @@ -118,16 +118,19 @@ this._loading = true; this._items = []; Polymer.dom.flush(); + const errFn = response => { + this.fire('page-error', {response}); + }; if (detailType === DETAIL_TYPES.BRANCHES) { return this.$.restAPI.getRepoBranches( - filter, repo, itemsPerPage, offset) .then(items => { + filter, repo, itemsPerPage, offset, errFn).then(items => { if (!items) { return; } this._items = items; this._loading = false; }); } else if (detailType === DETAIL_TYPES.TAGS) { return this.$.restAPI.getRepoTags( - filter, repo, itemsPerPage, offset) .then(items => { + filter, repo, itemsPerPage, offset, errFn).then(items => { if (!items) { return; } this._items = items; this._loading = false; diff --git a/polygerrit-ui/app/elements/admin/gr-repo-detail-list/gr-repo-detail-list_test.html b/polygerrit-ui/app/elements/admin/gr-repo-detail-list/gr-repo-detail-list_test.html index 6f75805795..24edadc8d4 100644 --- a/polygerrit-ui/app/elements/admin/gr-repo-detail-list/gr-repo-detail-list_test.html +++ b/polygerrit-ui/app/elements/admin/gr-repo-detail-list/gr-repo-detail-list_test.html @@ -305,12 +305,41 @@ limitations under the License. offset: 25, }; element._paramsChanged(params).then(() => { - assert.isTrue(element.$.restAPI.getRepoBranches.lastCall - .calledWithExactly('test', 'test', 25, 25)); + assert.equal(element.$.restAPI.getRepoBranches.lastCall.args[0], + 'test'); + assert.equal(element.$.restAPI.getRepoBranches.lastCall.args[1], + 'test'); + assert.equal(element.$.restAPI.getRepoBranches.lastCall.args[2], + 25); + assert.equal(element.$.restAPI.getRepoBranches.lastCall.args[3], + 25); done(); }); }); }); + + suite('404', () => { + test('fires page-error', done => { + const response = {status: 404}; + sandbox.stub(element.$.restAPI, 'getRepoBranches', + (filter, repo, reposBranchesPerPage, opt_offset, errFn) => { + errFn(response); + }); + + element.addEventListener('page-error', e => { + assert.deepEqual(e.detail.response, response); + done(); + }); + + const params = { + detail: 'branches', + repo: 'test', + filter: 'test', + offset: 25, + }; + element._paramsChanged(params); + }); + }); }); suite('Tags', () => { @@ -459,8 +488,14 @@ limitations under the License. offset: 25, }; element._paramsChanged(params).then(() => { - assert.isTrue(element.$.restAPI.getRepoTags.lastCall - .calledWithExactly('test', 'test', 25, 25)); + assert.equal(element.$.restAPI.getRepoTags.lastCall.args[0], + 'test'); + assert.equal(element.$.restAPI.getRepoTags.lastCall.args[1], + 'test'); + assert.equal(element.$.restAPI.getRepoTags.lastCall.args[2], + 25); + assert.equal(element.$.restAPI.getRepoTags.lastCall.args[3], + 25); done(); }); }); @@ -491,5 +526,28 @@ limitations under the License. assert.isTrue(element._handleCloseCreate.called); }); }); + + suite('404', () => { + test('fires page-error', done => { + const response = {status: 404}; + sandbox.stub(element.$.restAPI, 'getRepoTags', + (filter, repo, reposTagsPerPage, opt_offset, errFn) => { + errFn(response); + }); + + element.addEventListener('page-error', e => { + assert.deepEqual(e.detail.response, response); + done(); + }); + + const params = { + repo: 'test', + detail: 'tags', + filter: 'test', + offset: 25, + }; + element._paramsChanged(params); + }); + }); });