Commit bf3aaf41 authored by Marcia Ramos's avatar Marcia Ramos Committed by Andrew Fontaine

Update spec and tooltip positioning

Needed to update spec and snapshot to work
with new tooltip code, and also needed to set
the viewport to the new tooltip
parent 746c9b10
<script> <script>
/* eslint-disable vue/no-v-html */ /* eslint-disable vue/no-v-html */
import { groupBy } from 'lodash'; import { groupBy } from 'lodash';
import { GlIcon, GlLoadingIcon } from '@gitlab/ui'; import { GlIcon, GlLoadingIcon, GlTooltipDirective } from '@gitlab/ui';
import tooltip from '~/vue_shared/directives/tooltip';
import { glEmojiTag } from '../../emoji'; import { glEmojiTag } from '../../emoji';
import { __, sprintf } from '~/locale'; import { __, sprintf } from '~/locale';
...@@ -15,7 +14,7 @@ export default { ...@@ -15,7 +14,7 @@ export default {
GlLoadingIcon, GlLoadingIcon,
}, },
directives: { directives: {
tooltip, GlTooltip: GlTooltipDirective,
}, },
props: { props: {
awards: { awards: {
...@@ -154,10 +153,9 @@ export default { ...@@ -154,10 +153,9 @@ export default {
<button <button
v-for="awardList in groupedAwards" v-for="awardList in groupedAwards"
:key="awardList.name" :key="awardList.name"
v-tooltip v-gl-tooltip.viewport
:class="awardList.classes" :class="awardList.classes"
:title="awardList.title" :title="awardList.title"
data-boundary="viewport"
data-testid="award-button" data-testid="award-button"
class="btn award-control" class="btn award-control"
type="button" type="button"
...@@ -168,12 +166,11 @@ export default { ...@@ -168,12 +166,11 @@ export default {
</button> </button>
<div v-if="canAwardEmoji" class="award-menu-holder"> <div v-if="canAwardEmoji" class="award-menu-holder">
<button <button
v-tooltip v-gl-tooltip.viewport
:class="addButtonClass" :class="addButtonClass"
class="award-control btn js-add-award" class="award-control btn js-add-award"
title="Add reaction" title="Add reaction"
:aria-label="__('Add reaction')" :aria-label="__('Add reaction')"
data-boundary="viewport"
type="button" type="button"
> >
<span class="award-control-icon award-control-icon-neutral"> <span class="award-control-icon award-control-icon-neutral">
......
---
title: Migrate tooltip in app/assets/javascripts/vue_shared/components/awards_list.vue
merge_request: 46171
author:
type: other
...@@ -92,15 +92,14 @@ describe('note_awards_list component', () => { ...@@ -92,15 +92,14 @@ describe('note_awards_list component', () => {
}).$mount(); }).$mount();
}; };
const findTooltip = () => const findTooltip = () => vm.$el.querySelector('[title]').getAttribute('title');
vm.$el.querySelector('[data-original-title]').getAttribute('data-original-title');
it('should only escape & and " characters', () => { it('should only escape & and " characters', () => {
awardsMock = [...new Array(1)].map(createAwardEmoji); awardsMock = [...new Array(1)].map(createAwardEmoji);
mountComponent(); mountComponent();
const escapedName = awardsMock[0].user.name.replace(/&/g, '&amp;').replace(/"/g, '&quot;'); const escapedName = awardsMock[0].user.name.replace(/&/g, '&amp;').replace(/"/g, '&quot;');
expect(vm.$el.querySelector('[data-original-title]').outerHTML).toContain(escapedName); expect(vm.$el.querySelector('[title]').outerHTML).toContain(escapedName);
}); });
it('should not escape special HTML characters twice when only 1 person awarded', () => { it('should not escape special HTML characters twice when only 1 person awarded', () => {
......
...@@ -6,10 +6,8 @@ exports[`vue_shared/components/awards_list default matches snapshot 1`] = ` ...@@ -6,10 +6,8 @@ exports[`vue_shared/components/awards_list default matches snapshot 1`] = `
> >
<button <button
class="btn award-control" class="btn award-control"
data-boundary="viewport"
data-original-title="Ada, Leonardo, and Marie"
data-testid="award-button" data-testid="award-button"
title="" title="Ada, Leonardo, and Marie"
type="button" type="button"
> >
<span <span
...@@ -32,10 +30,8 @@ exports[`vue_shared/components/awards_list default matches snapshot 1`] = ` ...@@ -32,10 +30,8 @@ exports[`vue_shared/components/awards_list default matches snapshot 1`] = `
</button> </button>
<button <button
class="btn award-control active" class="btn award-control active"
data-boundary="viewport"
data-original-title="You, Ada, and Marie"
data-testid="award-button" data-testid="award-button"
title="" title="You, Ada, and Marie"
type="button" type="button"
> >
<span <span
...@@ -58,10 +54,8 @@ exports[`vue_shared/components/awards_list default matches snapshot 1`] = ` ...@@ -58,10 +54,8 @@ exports[`vue_shared/components/awards_list default matches snapshot 1`] = `
</button> </button>
<button <button
class="btn award-control" class="btn award-control"
data-boundary="viewport"
data-original-title="Ada and Jane"
data-testid="award-button" data-testid="award-button"
title="" title="Ada and Jane"
type="button" type="button"
> >
<span <span
...@@ -84,10 +78,8 @@ exports[`vue_shared/components/awards_list default matches snapshot 1`] = ` ...@@ -84,10 +78,8 @@ exports[`vue_shared/components/awards_list default matches snapshot 1`] = `
</button> </button>
<button <button
class="btn award-control active" class="btn award-control active"
data-boundary="viewport"
data-original-title="You, Ada, Jane, and Leonardo"
data-testid="award-button" data-testid="award-button"
title="" title="You, Ada, Jane, and Leonardo"
type="button" type="button"
> >
<span <span
...@@ -110,10 +102,8 @@ exports[`vue_shared/components/awards_list default matches snapshot 1`] = ` ...@@ -110,10 +102,8 @@ exports[`vue_shared/components/awards_list default matches snapshot 1`] = `
</button> </button>
<button <button
class="btn award-control active" class="btn award-control active"
data-boundary="viewport"
data-original-title="You"
data-testid="award-button" data-testid="award-button"
title="" title="You"
type="button" type="button"
> >
<span <span
...@@ -136,10 +126,8 @@ exports[`vue_shared/components/awards_list default matches snapshot 1`] = ` ...@@ -136,10 +126,8 @@ exports[`vue_shared/components/awards_list default matches snapshot 1`] = `
</button> </button>
<button <button
class="btn award-control" class="btn award-control"
data-boundary="viewport"
data-original-title="Marie"
data-testid="award-button" data-testid="award-button"
title="" title="Marie"
type="button" type="button"
> >
<span <span
...@@ -162,10 +150,8 @@ exports[`vue_shared/components/awards_list default matches snapshot 1`] = ` ...@@ -162,10 +150,8 @@ exports[`vue_shared/components/awards_list default matches snapshot 1`] = `
</button> </button>
<button <button
class="btn award-control active" class="btn award-control active"
data-boundary="viewport"
data-original-title="You"
data-testid="award-button" data-testid="award-button"
title="" title="You"
type="button" type="button"
> >
<span <span
...@@ -193,9 +179,7 @@ exports[`vue_shared/components/awards_list default matches snapshot 1`] = ` ...@@ -193,9 +179,7 @@ exports[`vue_shared/components/awards_list default matches snapshot 1`] = `
<button <button
aria-label="Add reaction" aria-label="Add reaction"
class="award-control btn js-add-award js-test-add-button-class" class="award-control btn js-add-award js-test-add-button-class"
data-boundary="viewport" title="Add reaction"
data-original-title="Add reaction"
title=""
type="button" type="button"
> >
<span <span
......
...@@ -62,7 +62,7 @@ describe('vue_shared/components/awards_list', () => { ...@@ -62,7 +62,7 @@ describe('vue_shared/components/awards_list', () => {
findAwardButtons().wrappers.map(x => { findAwardButtons().wrappers.map(x => {
return { return {
classes: x.classes(), classes: x.classes(),
title: x.attributes('data-original-title'), title: x.attributes('title'),
html: x.find('[data-testid="award-html"]').element.innerHTML, html: x.find('[data-testid="award-html"]').element.innerHTML,
count: Number(x.find('.js-counter').text()), count: Number(x.find('.js-counter').text()),
}; };
......
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