Commit 5120a8a1 authored by Jake Lear's avatar Jake Lear

Add spec for iteration sidebar link

parent 019bf2e7
......@@ -90,12 +90,14 @@ export default {
};
},
computed: {
iteration() {
return this.iterations.find(({ id }) => id === this.currentIteration);
},
iterationTitle() {
// NOTE: Optional chaining guards when search result is empty
return this.iterations.find(({ id }) => id === this.currentIteration)?.title;
return this.iteration?.title;
},
iterationUrl() {
return this.iterations.find(({ id }) => id === this.currentIteration)?.webUrl;
return this.iteration?.webUrl;
},
showNoIterationContent() {
return !this.editing && !this.currentIteration;
......
import { shallowMount } from '@vue/test-utils';
import { GlNewDropdown, GlNewDropdownItem, GlButton, GlSearchBoxByType } from '@gitlab/ui';
import { GlNewDropdown, GlNewDropdownItem, GlButton, GlLink, GlSearchBoxByType } from '@gitlab/ui';
import createFlash from '~/flash';
import IterationSelect from 'ee/sidebar/components/iteration_select.vue';
import { iterationSelectTextMap } from 'ee/sidebar/constants';
......@@ -63,6 +63,17 @@ describe('IterationSelect', () => {
expect(wrapper.find('[data-testid="select-iteration"]').text()).toBe('title');
});
it('links to the current iteration', () => {
createComponent({
data: {
iterations: [{ id: 'id', title: 'title', webUrl: 'webUrl' }],
currentIteration: 'id',
},
});
expect(wrapper.find(GlLink).attributes().href).toBe('webUrl');
});
});
describe('when a user cannot edit', () => {
......
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