Commit 6b1e2864 authored by Natalia Tepluhina's avatar Natalia Tepluhina

Merge branch '337785-tooltips-no-longer-displayed-on-milestone-in-sidebar' into 'master'

Fix due date tooltip on milestone in sidebar

See merge request gitlab-org/gitlab!68130
parents 07f6bb69 59a6f8df
...@@ -13,6 +13,7 @@ import { ...@@ -13,6 +13,7 @@ import {
import createFlash from '~/flash'; import createFlash from '~/flash';
import { getIdFromGraphQLId } from '~/graphql_shared/utils'; import { getIdFromGraphQLId } from '~/graphql_shared/utils';
import { IssuableType } from '~/issue_show/constants'; import { IssuableType } from '~/issue_show/constants';
import { timeFor } from '~/lib/utils/datetime_utility';
import { __, s__, sprintf } from '~/locale'; import { __, s__, sprintf } from '~/locale';
import SidebarEditableItem from '~/sidebar/components/sidebar_editable_item.vue'; import SidebarEditableItem from '~/sidebar/components/sidebar_editable_item.vue';
import { import {
...@@ -204,6 +205,9 @@ export default { ...@@ -204,6 +205,9 @@ export default {
attributeTypeIcon() { attributeTypeIcon() {
return this.icon || this.issuableAttribute; return this.icon || this.issuableAttribute;
}, },
tooltipText() {
return timeFor(this.currentAttribute?.dueDate);
},
i18n() { i18n() {
return { return {
noAttribute: sprintf(s__('DropdownWidget|No %{issuableAttribute}'), { noAttribute: sprintf(s__('DropdownWidget|No %{issuableAttribute}'), {
...@@ -346,6 +350,7 @@ export default { ...@@ -346,6 +350,7 @@ export default {
:currentAttribute="currentAttribute" :currentAttribute="currentAttribute"
> >
<gl-link <gl-link
v-gl-tooltip="tooltipText"
class="gl-text-gray-900! gl-font-weight-bold" class="gl-text-gray-900! gl-font-weight-bold"
:href="attributeUrl" :href="attributeUrl"
:data-qa-selector="`${issuableAttribute}_link`" :data-qa-selector="`${issuableAttribute}_link`"
......
...@@ -2,5 +2,6 @@ fragment MilestoneFragment on Milestone { ...@@ -2,5 +2,6 @@ fragment MilestoneFragment on Milestone {
id id
title title
webUrl: webPath webUrl: webPath
dueDate
expired expired
} }
...@@ -19,6 +19,7 @@ export default { ...@@ -19,6 +19,7 @@ export default {
[IssuableAttributeType.Iteration]: __('Iteration'), [IssuableAttributeType.Iteration]: __('Iteration'),
[IssuableAttributeType.Epic]: __('Epic'), [IssuableAttributeType.Epic]: __('Epic'),
none: __('None'), none: __('None'),
expired: __('(expired)'),
}, },
props: { props: {
issuableAttribute: { issuableAttribute: {
......
...@@ -12,11 +12,13 @@ import { createLocalVue, shallowMount, mount } from '@vue/test-utils'; ...@@ -12,11 +12,13 @@ import { createLocalVue, shallowMount, mount } from '@vue/test-utils';
import VueApollo from 'vue-apollo'; import VueApollo from 'vue-apollo';
import createMockApollo from 'helpers/mock_apollo_helper'; import createMockApollo from 'helpers/mock_apollo_helper';
import { createMockDirective, getBinding } from 'helpers/vue_mock_directive';
import { extendedWrapper } from 'helpers/vue_test_utils_helper'; import { extendedWrapper } from 'helpers/vue_test_utils_helper';
import waitForPromises from 'helpers/wait_for_promises'; import waitForPromises from 'helpers/wait_for_promises';
import createFlash from '~/flash'; import createFlash from '~/flash';
import { getIdFromGraphQLId } from '~/graphql_shared/utils'; import { getIdFromGraphQLId } from '~/graphql_shared/utils';
import { IssuableType } from '~/issue_show/constants'; import { IssuableType } from '~/issue_show/constants';
import { timeFor } from '~/lib/utils/datetime_utility';
import SidebarDropdownWidget from '~/sidebar/components/sidebar_dropdown_widget.vue'; import SidebarDropdownWidget from '~/sidebar/components/sidebar_dropdown_widget.vue';
import SidebarEditableItem from '~/sidebar/components/sidebar_editable_item.vue'; import SidebarEditableItem from '~/sidebar/components/sidebar_editable_item.vue';
import { IssuableAttributeType } from '~/sidebar/constants'; import { IssuableAttributeType } from '~/sidebar/constants';
...@@ -54,6 +56,7 @@ describe('SidebarDropdownWidget', () => { ...@@ -54,6 +56,7 @@ describe('SidebarDropdownWidget', () => {
const mutationSuccessWithErrors = () => jest.fn().mockResolvedValue({ data: promiseWithErrors }); const mutationSuccessWithErrors = () => jest.fn().mockResolvedValue({ data: promiseWithErrors });
const findGlLink = () => wrapper.findComponent(GlLink); const findGlLink = () => wrapper.findComponent(GlLink);
const findDateTooltip = () => getBinding(findGlLink().element, 'gl-tooltip');
const findDropdown = () => wrapper.findComponent(GlDropdown); const findDropdown = () => wrapper.findComponent(GlDropdown);
const findDropdownText = () => wrapper.findComponent(GlDropdownText); const findDropdownText = () => wrapper.findComponent(GlDropdownText);
const findSearchBox = () => wrapper.findComponent(GlSearchBoxByType); const findSearchBox = () => wrapper.findComponent(GlSearchBoxByType);
...@@ -155,6 +158,9 @@ describe('SidebarDropdownWidget', () => { ...@@ -155,6 +158,9 @@ describe('SidebarDropdownWidget', () => {
}, },
}, },
}, },
directives: {
GlTooltip: createMockDirective(),
},
stubs: { stubs: {
SidebarEditableItem, SidebarEditableItem,
GlSearchBoxByType, GlSearchBoxByType,
...@@ -177,7 +183,7 @@ describe('SidebarDropdownWidget', () => { ...@@ -177,7 +183,7 @@ describe('SidebarDropdownWidget', () => {
beforeEach(() => { beforeEach(() => {
createComponent({ createComponent({
data: { data: {
currentAttribute: { id: 'id', title: 'title', webUrl: 'webUrl' }, currentAttribute: { id: 'id', title: 'title', webUrl: 'webUrl', dueDate: '2021-09-09' },
}, },
stubs: { stubs: {
GlDropdown, GlDropdown,
...@@ -223,6 +229,10 @@ describe('SidebarDropdownWidget', () => { ...@@ -223,6 +229,10 @@ describe('SidebarDropdownWidget', () => {
expect(findSelectedAttribute().text()).toBe('Some milestone title'); expect(findSelectedAttribute().text()).toBe('Some milestone title');
}); });
it('displays time for milestone due date in tooltip', () => {
expect(findDateTooltip().value).toBe(timeFor('2021-09-09'));
});
describe('when current attribute does not exist', () => { describe('when current attribute does not exist', () => {
it('renders "None" as the selected attribute title', () => { it('renders "None" as the selected attribute title', () => {
createComponent(); createComponent();
......
...@@ -562,6 +562,7 @@ export const mockMilestone1 = { ...@@ -562,6 +562,7 @@ export const mockMilestone1 = {
webUrl: 'http://gdk.test:3000/groups/gitlab-org/-/milestones/1', webUrl: 'http://gdk.test:3000/groups/gitlab-org/-/milestones/1',
state: 'active', state: 'active',
expired: false, expired: false,
dueDate: '2030-09-09',
}; };
export const mockMilestone2 = { export const mockMilestone2 = {
...@@ -571,6 +572,7 @@ export const mockMilestone2 = { ...@@ -571,6 +572,7 @@ export const mockMilestone2 = {
webUrl: 'http://gdk.test:3000/groups/gitlab-org/-/milestones/2', webUrl: 'http://gdk.test:3000/groups/gitlab-org/-/milestones/2',
state: 'active', state: 'active',
expired: false, expired: false,
dueDate: '2030-09-09',
}; };
export const mockProjectMilestonesResponse = { export const mockProjectMilestonesResponse = {
...@@ -618,6 +620,7 @@ export const mockMilestoneMutationResponse = { ...@@ -618,6 +620,7 @@ export const mockMilestoneMutationResponse = {
title: 'Awesome Milestone', title: 'Awesome Milestone',
state: 'active', state: 'active',
expired: false, expired: false,
dueDate: '2030-09-09',
__typename: 'Milestone', __typename: 'Milestone',
}, },
__typename: 'Issue', __typename: 'Issue',
......
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