Commit 90d10172 authored by Nicolas Dular's avatar Nicolas Dular

Fix issue with loading tags on the compare page

Not all repositories have tags, so we need to deefault to an empty array
to not fail when we filter on tags. To be sure, we also default to an
empty array for branches.
parent 56d95d9a
......@@ -65,8 +65,8 @@ export default {
return axios
.get(endpoint)
.then(({ data }) => {
this.branches = data.Branches;
this.tags = data.Tags;
this.branches = data.Branches || [];
this.tags = data.Tags || [];
})
.catch(() => {
createFlash({
......
---
title: Fix issue with loading the repository compare page
merge_request: 55058
author:
type: fixed
......@@ -62,6 +62,20 @@ describe('RevisionDropdown component', () => {
expect(wrapper.vm.tags).toEqual(Tags);
});
it('sets branches and tags to be an empty array when no tags or branches are given', async () => {
axiosMock.onGet(defaultProps.refsProjectPath).replyOnce(200, {
Branches: undefined,
Tags: undefined,
});
createComponent();
await axios.waitForAll();
expect(wrapper.vm.branches).toEqual([]);
expect(wrapper.vm.tags).toEqual([]);
});
it('shows flash message on error', async () => {
axiosMock.onGet('some/invalid/path').replyOnce(404);
......
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