Commit d9ef279e authored by Tom Quirk's avatar Tom Quirk

Add tests for design sidebar To-Do button

Including updating feature flag check to a computed prop
parent 971caaaf
...@@ -61,8 +61,8 @@ export default { ...@@ -61,8 +61,8 @@ export default {
resolvedCommentsToggleIcon() { resolvedCommentsToggleIcon() {
return this.resolvedDiscussionsExpanded ? 'chevron-down' : 'chevron-right'; return this.resolvedDiscussionsExpanded ? 'chevron-down' : 'chevron-right';
}, },
hasPendingTodo() { showTodoButton() {
return Boolean(this.design.pendingTodo); return gon.features?.designManagementTodoButton;
}, },
}, },
watch: { watch: {
...@@ -99,29 +99,20 @@ export default { ...@@ -99,29 +99,20 @@ export default {
updateDiscussionWithOpenForm(id) { updateDiscussionWithOpenForm(id) {
this.discussionWithOpenForm = id; this.discussionWithOpenForm = id;
}, },
toggleTodo() {
// TODO implement
}, },
},
showTodoButton: gon.features?.designManagementTodoButton,
resolveCommentsToggleText: s__('DesignManagement|Resolved Comments'), resolveCommentsToggleText: s__('DesignManagement|Resolved Comments'),
cookieKey: 'hide_design_resolved_comments_popover', cookieKey: 'hide_design_resolved_comments_popover',
}; };
</script> </script>
<template> <template>
<div class="image-notes" @click="handleSidebarClick"> <div class="image-notes" :class="{ 'gl-pt-0': showTodoButton }" @click="handleSidebarClick">
<div <div
v-if="$options.showTodoButton" v-if="showTodoButton"
class="gl-display-flex gl-justify-content-space-between gl-border-b-1 gl-border-b-gray-100" class="gl-py-4 gl-mb-4 gl-display-flex gl-justify-content-space-between gl-align-items-center gl-border-b-1 gl-border-b-solid gl-border-b-gray-100"
> >
<span>{{ __('To-Do') }}</span> <span>{{ __('To-Do') }}</span>
<todo-button <todo-button issuable-type="design" :issuable-id="design.iid" />
issuable-type="design"
:issuable-id="design.iid"
:is-todo="hasPendingTodo"
@click="toggleTodo"
/>
</div> </div>
<h2 class="gl-font-weight-bold gl-mt-0"> <h2 class="gl-font-weight-bold gl-mt-0">
{{ issue.title }} {{ issue.title }}
......
...@@ -6,6 +6,7 @@ import Participants from '~/sidebar/components/participants/participants.vue'; ...@@ -6,6 +6,7 @@ import Participants from '~/sidebar/components/participants/participants.vue';
import DesignDiscussion from '~/design_management/components/design_notes/design_discussion.vue'; import DesignDiscussion from '~/design_management/components/design_notes/design_discussion.vue';
import design from '../mock_data/design'; import design from '../mock_data/design';
import updateActiveDiscussionMutation from '~/design_management/graphql/mutations/update_active_discussion.mutation.graphql'; import updateActiveDiscussionMutation from '~/design_management/graphql/mutations/update_active_discussion.mutation.graphql';
import TodoButton from '~/vue_shared/components/todo_button.vue';
const scrollIntoViewMock = jest.fn(); const scrollIntoViewMock = jest.fn();
HTMLElement.prototype.scrollIntoView = scrollIntoViewMock; HTMLElement.prototype.scrollIntoView = scrollIntoViewMock;
...@@ -241,4 +242,28 @@ describe('Design management design sidebar component', () => { ...@@ -241,4 +242,28 @@ describe('Design management design sidebar component', () => {
expect(Cookies.set).toHaveBeenCalledWith(cookieKey, 'true', { expires: 365 * 10 }); expect(Cookies.set).toHaveBeenCalledWith(cookieKey, 'true', { expires: 365 * 10 });
}); });
}); });
it('does not render To-Do button by default', () => {
createComponent();
expect(wrapper.find(TodoButton).exists()).toBe(false);
});
describe('when `design_management_todo_button` feature flag is enabled', () => {
beforeEach(() => {
window.gon = {
features: {
designManagementTodoButton: true,
},
};
createComponent();
});
it('renders sidebar root element with no top padding', () => {
expect(wrapper.classes()).toContain('gl-pt-0');
});
it('renders todo_button component', () => {
expect(wrapper.find(TodoButton).exists()).toBe(true);
});
});
}); });
...@@ -32,6 +32,8 @@ exports[`Design management design index page renders design index 1`] = ` ...@@ -32,6 +32,8 @@ exports[`Design management design index page renders design index 1`] = `
<div <div
class="image-notes" class="image-notes"
> >
<!---->
<h2 <h2
class="gl-font-weight-bold gl-mt-0" class="gl-font-weight-bold gl-mt-0"
> >
...@@ -179,6 +181,8 @@ exports[`Design management design index page with error GlAlert is rendered in c ...@@ -179,6 +181,8 @@ exports[`Design management design index page with error GlAlert is rendered in c
<div <div
class="image-notes" class="image-notes"
> >
<!---->
<h2 <h2
class="gl-font-weight-bold gl-mt-0" class="gl-font-weight-bold gl-mt-0"
> >
......
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