Commit 9be879c1 authored by Filipa Lacerda's avatar Filipa Lacerda

Merge branch 'fix-divergence-graph-error' into 'master'

Fix divergence graph loading error

Closes #64143

See merge request gitlab-org/gitlab-ce!30393
parents a5225156 fad92a2e
...@@ -36,7 +36,9 @@ export default endpoint => { ...@@ -36,7 +36,9 @@ export default endpoint => {
}, 100); }, 100);
Object.entries(data).forEach(([branchName, val]) => { Object.entries(data).forEach(([branchName, val]) => {
const el = document.querySelector(`.js-branch-${branchName} .js-branch-divergence-graph`); const el = document.querySelector(
`[data-name="${branchName}"] .js-branch-divergence-graph`,
);
if (!el) return; if (!el) return;
......
...@@ -10,12 +10,14 @@ describe('Divergence graph', () => { ...@@ -10,12 +10,14 @@ describe('Divergence graph', () => {
mock.onGet('/-/diverging_counts').reply(200, { mock.onGet('/-/diverging_counts').reply(200, {
master: { ahead: 1, behind: 1 }, master: { ahead: 1, behind: 1 },
'test/hello-world': { ahead: 1, behind: 1 },
}); });
jest.spyOn(axios, 'get'); jest.spyOn(axios, 'get');
document.body.innerHTML = ` document.body.innerHTML = `
<div class="js-branch-item" data-name="master"></div> <div class="js-branch-item" data-name="master"><div class="js-branch-divergence-graph"></div></div>
<div class="js-branch-item" data-name="test/hello-world"><div class="js-branch-divergence-graph"></div></div>
`; `;
}); });
...@@ -26,7 +28,13 @@ describe('Divergence graph', () => { ...@@ -26,7 +28,13 @@ describe('Divergence graph', () => {
it('calls axos get with list of branch names', () => it('calls axos get with list of branch names', () =>
init('/-/diverging_counts').then(() => { init('/-/diverging_counts').then(() => {
expect(axios.get).toHaveBeenCalledWith('/-/diverging_counts', { expect(axios.get).toHaveBeenCalledWith('/-/diverging_counts', {
params: { names: ['master'] }, params: { names: ['master', 'test/hello-world'] },
}); });
})); }));
it('creates Vue components', () =>
init('/-/diverging_counts').then(() => {
expect(document.querySelector('[data-name="master"]').innerHTML).not.toEqual('');
expect(document.querySelector('[data-name="test/hello-world"]').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