Commit 62b00145 authored by Filipa Lacerda's avatar Filipa Lacerda

Merge branch 'sh-suppress-diverging-count-commits-request' into 'master'

Skip requesting diverging commit counts if no branches are listed

See merge request gitlab-org/gitlab-ce!32496
parents fb63a00e 526ea7c5
......@@ -25,6 +25,11 @@ export default endpoint => {
const names = [...document.querySelectorAll('.js-branch-item')].map(
({ dataset }) => dataset.name,
);
if (names.length === 0) {
return true;
}
return axios
.get(endpoint, {
params: { names },
......
---
title: Skip requesting diverging commit counts if no branches are listed
merge_request: 32496
author:
type: performance
......@@ -25,13 +25,25 @@ describe('Divergence graph', () => {
mock.restore();
});
it('calls axos get with list of branch names', () =>
it('calls axios get with list of branch names', () =>
init('/-/diverging_counts').then(() => {
expect(axios.get).toHaveBeenCalledWith('/-/diverging_counts', {
params: { names: ['master', 'test/hello-world'] },
});
}));
describe('no branches listed', () => {
beforeEach(() => {
document.body.innerHTML = `<div></div>`;
});
it('avoids requesting diverging commit counts', () => {
expect(axios.get).not.toHaveBeenCalledWith('/-/diverging_counts');
init('/-/diverging_counts');
});
});
it('creates Vue components', () =>
init('/-/diverging_counts').then(() => {
expect(document.querySelector('[data-name="master"]').innerHTML).not.toEqual('');
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment