Commit 8235ee32 authored by Justin Boyson's avatar Justin Boyson Committed by Phil Hughes

Resolve "Add missing tooltip to Apply suggestion button"

parent dc8c63b9
...@@ -147,6 +147,7 @@ export default { ...@@ -147,6 +147,7 @@ export default {
</gl-button> </gl-button>
<apply-suggestion <apply-suggestion
v-if="isLoggedIn" v-if="isLoggedIn"
v-gl-tooltip.viewport="tooltipMessage"
:disabled="isDisableButton" :disabled="isDisableButton"
:default-commit-message="defaultCommitMessage" :default-commit-message="defaultCommitMessage"
class="gl-ml-3" class="gl-ml-3"
......
---
title: Fix tooltip not rendering
merge_request: 59202
author:
type: fixed
import { GlLoadingIcon } from '@gitlab/ui'; import { GlLoadingIcon } from '@gitlab/ui';
import { shallowMount } from '@vue/test-utils'; import { shallowMount } from '@vue/test-utils';
import { createMockDirective, getBinding } from 'helpers/vue_mock_directive';
import ApplySuggestion from '~/vue_shared/components/markdown/apply_suggestion.vue'; import ApplySuggestion from '~/vue_shared/components/markdown/apply_suggestion.vue';
import SuggestionDiffHeader from '~/vue_shared/components/markdown/suggestion_diff_header.vue'; import SuggestionDiffHeader from '~/vue_shared/components/markdown/suggestion_diff_header.vue';
...@@ -22,6 +23,9 @@ describe('Suggestion Diff component', () => { ...@@ -22,6 +23,9 @@ describe('Suggestion Diff component', () => {
...DEFAULT_PROPS, ...DEFAULT_PROPS,
...props, ...props,
}, },
directives: {
GlTooltip: createMockDirective(),
},
}); });
}; };
...@@ -218,15 +222,23 @@ describe('Suggestion Diff component', () => { ...@@ -218,15 +222,23 @@ describe('Suggestion Diff component', () => {
}); });
describe('tooltip message for apply button', () => { describe('tooltip message for apply button', () => {
const findTooltip = () => getBinding(findApplyButton().element, 'gl-tooltip');
it('renders correct tooltip message when button is applicable', () => { it('renders correct tooltip message when button is applicable', () => {
createComponent(); createComponent();
expect(wrapper.vm.tooltipMessage).toBe('This also resolves this thread'); const tooltip = findTooltip();
expect(tooltip.modifiers.viewport).toBe(true);
expect(tooltip.value).toBe('This also resolves this thread');
}); });
it('renders the inapplicable reason in the tooltip when button is not applicable', () => { it('renders the inapplicable reason in the tooltip when button is not applicable', () => {
const inapplicableReason = 'lorem'; const inapplicableReason = 'lorem';
createComponent({ canApply: false, inapplicableReason }); createComponent({ canApply: false, inapplicableReason });
expect(wrapper.vm.tooltipMessage).toBe(inapplicableReason); const tooltip = findTooltip();
expect(tooltip.modifiers.viewport).toBe(true);
expect(tooltip.value).toBe(inapplicableReason);
}); });
}); });
}); });
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