Commit 47de47a0 authored by Raihan Kabir's avatar Raihan Kabir Committed by Paul Slaughter

Migrate assignee sidebar loading spinner to new one

https://gitlab.com/gitlab-org/gitlab/-/merge_requests/24919
parent a7eb81e3
<script> <script>
import { GlLoadingIcon } from '@gitlab/ui';
import { n__ } from '~/locale'; import { n__ } from '~/locale';
export default { export default {
name: 'AssigneeTitle', name: 'AssigneeTitle',
components: {
GlLoadingIcon,
},
props: { props: {
loading: { loading: {
type: Boolean, type: Boolean,
...@@ -34,7 +38,7 @@ export default { ...@@ -34,7 +38,7 @@ export default {
<template> <template>
<div class="title hide-collapsed"> <div class="title hide-collapsed">
{{ assigneeTitle }} {{ assigneeTitle }}
<i v-if="loading" aria-hidden="true" class="fa fa-spinner fa-spin block-loading"></i> <gl-loading-icon v-if="loading" inline class="align-bottom" />
<a <a
v-if="editable" v-if="editable"
class="js-sidebar-dropdown-toggle edit-link float-right" class="js-sidebar-dropdown-toggle edit-link float-right"
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
#js-vue-sidebar-assignees{ data: { field: "#{issuable_type}", signed_in: signed_in } } #js-vue-sidebar-assignees{ data: { field: "#{issuable_type}", signed_in: signed_in } }
.title.hide-collapsed .title.hide-collapsed
= _('Assignee') = _('Assignee')
= icon('spinner spin') .spinner.spinner-sm.align-bottom
.selectbox.hide-collapsed .selectbox.hide-collapsed
- if assignees.none? - if assignees.none?
......
---
title: Migrated from .fa-spinner to .spinner in app/assets/javascripts/sidebar/components/assignees/assignee_title.vue
merge_request: 24919
author: rk4bir
type: changed
import Vue from 'vue'; import { shallowMount } from '@vue/test-utils';
import { mockTracking, triggerEvent } from 'spec/helpers/tracking_helper'; import { GlLoadingIcon } from '@gitlab/ui';
import AssigneeTitle from '~/sidebar/components/assignees/assignee_title.vue'; import { mockTracking, triggerEvent } from 'helpers/tracking_helper';
import Component from '~/sidebar/components/assignees/assignee_title.vue';
describe('AssigneeTitle component', () => { describe('AssigneeTitle component', () => {
let component; let wrapper;
let AssigneeTitleComponent;
beforeEach(() => { const createComponent = props => {
AssigneeTitleComponent = Vue.extend(AssigneeTitle); return shallowMount(Component, {
propsData: {
numberOfAssignees: 0,
editable: false,
...props,
},
});
};
afterEach(() => {
wrapper.destroy();
wrapper = null;
}); });
describe('assignee title', () => { describe('assignee title', () => {
it('renders assignee', () => { it('renders assignee', () => {
component = new AssigneeTitleComponent({ wrapper = createComponent({
propsData: {
numberOfAssignees: 1, numberOfAssignees: 1,
editable: false, editable: false,
}, });
}).$mount();
expect(component.$el.innerText.trim()).toEqual('Assignee'); expect(wrapper.vm.$el.innerText.trim()).toEqual('Assignee');
}); });
it('renders 2 assignees', () => { it('renders 2 assignees', () => {
component = new AssigneeTitleComponent({ wrapper = createComponent({
propsData: {
numberOfAssignees: 2, numberOfAssignees: 2,
editable: false, editable: false,
}, });
}).$mount();
expect(component.$el.innerText.trim()).toEqual('2 Assignees'); expect(wrapper.vm.$el.innerText.trim()).toEqual('2 Assignees');
}); });
}); });
describe('gutter toggle', () => { describe('gutter toggle', () => {
it('does not show toggle by default', () => { it('does not show toggle by default', () => {
component = new AssigneeTitleComponent({ wrapper = createComponent({
propsData: {
numberOfAssignees: 2, numberOfAssignees: 2,
editable: false, editable: false,
}, });
}).$mount();
expect(component.$el.querySelector('.gutter-toggle')).toBeNull(); expect(wrapper.vm.$el.querySelector('.gutter-toggle')).toBeNull();
}); });
it('shows toggle when showToggle is true', () => { it('shows toggle when showToggle is true', () => {
component = new AssigneeTitleComponent({ wrapper = createComponent({
propsData: {
numberOfAssignees: 2, numberOfAssignees: 2,
editable: false, editable: false,
showToggle: true, showToggle: true,
}, });
}).$mount();
expect(component.$el.querySelector('.gutter-toggle')).toEqual(jasmine.any(Object)); expect(wrapper.vm.$el.querySelector('.gutter-toggle')).toEqual(expect.any(Object));
}); });
}); });
it('does not render spinner by default', () => { it('does not render spinner by default', () => {
component = new AssigneeTitleComponent({ wrapper = createComponent({
propsData: {
numberOfAssignees: 0, numberOfAssignees: 0,
editable: false, editable: false,
}, });
}).$mount();
expect(component.$el.querySelector('.fa')).toBeNull(); expect(wrapper.find(GlLoadingIcon).exists()).toBeFalsy();
}); });
it('renders spinner when loading', () => { it('renders spinner when loading', () => {
component = new AssigneeTitleComponent({ wrapper = createComponent({
propsData: {
loading: true, loading: true,
numberOfAssignees: 0, numberOfAssignees: 0,
editable: false, editable: false,
}, });
}).$mount();
expect(component.$el.querySelector('.fa')).not.toBeNull(); expect(wrapper.find(GlLoadingIcon).exists()).toBeTruthy();
}); });
it('does not render edit link when not editable', () => { it('does not render edit link when not editable', () => {
component = new AssigneeTitleComponent({ wrapper = createComponent({
propsData: {
numberOfAssignees: 0, numberOfAssignees: 0,
editable: false, editable: false,
}, });
}).$mount();
expect(component.$el.querySelector('.edit-link')).toBeNull(); expect(wrapper.vm.$el.querySelector('.edit-link')).toBeNull();
}); });
it('renders edit link when editable', () => { it('renders edit link when editable', () => {
component = new AssigneeTitleComponent({ wrapper = createComponent({
propsData: {
numberOfAssignees: 0, numberOfAssignees: 0,
editable: true, editable: true,
}, });
}).$mount();
expect(component.$el.querySelector('.edit-link')).not.toBeNull(); expect(wrapper.vm.$el.querySelector('.edit-link')).not.toBeNull();
}); });
it('tracks the event when edit is clicked', () => { it('tracks the event when edit is clicked', () => {
component = new AssigneeTitleComponent({ wrapper = createComponent({
propsData: {
numberOfAssignees: 0, numberOfAssignees: 0,
editable: true, editable: true,
}, });
}).$mount();
const spy = mockTracking('_category_', component.$el, spyOn); const spy = mockTracking('_category_', wrapper.element, jest.spyOn);
triggerEvent('.js-sidebar-dropdown-toggle'); triggerEvent('.js-sidebar-dropdown-toggle');
expect(spy).toHaveBeenCalledWith('_category_', 'click_edit_button', { expect(spy).toHaveBeenCalledWith('_category_', 'click_edit_button', {
......
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