Commit 0d582137 authored by Axel García's avatar Axel García

Testing and base styles for epic label select

- Replace some CSS with utility classes
- Make sure all color selector look nice
- Improve testing
parent f3175ac6
...@@ -88,12 +88,16 @@ export default { ...@@ -88,12 +88,16 @@ export default {
@click.prevent="handleColorClick(color)" @click.prevent="handleColorClick(color)"
/> />
</div> </div>
<div class="color-input-container d-flex"> <div class="color-input-container gl-display-flex">
<span <span
class="dropdown-label-color-preview position-relative position-relative d-inline-block" class="dropdown-label-color-preview position-relative position-relative d-inline-block"
:style="{ backgroundColor: selectedColor }" :style="{ backgroundColor: selectedColor }"
></span> ></span>
<gl-form-input v-model.trim="selectedColor" :placeholder="__('Use custom color #FF0000')" /> <gl-form-input
v-model.trim="selectedColor"
class="gl-rounded-top-left-none gl-rounded-bottom-left-none"
:placeholder="__('Use custom color #FF0000')"
/>
</div> </div>
</div> </div>
<div class="dropdown-actions clearfix pt-2 px-2"> <div class="dropdown-actions clearfix pt-2 px-2">
......
...@@ -1089,6 +1089,10 @@ header.header-content .dropdown-menu.frequent-items-dropdown-menu { ...@@ -1089,6 +1089,10 @@ header.header-content .dropdown-menu.frequent-items-dropdown-menu {
.dropdown-label-color-preview { .dropdown-label-color-preview {
border: 1px solid $gray-100; border: 1px solid $gray-100;
border-right: 0; border-right: 0;
&[style] {
border-color: transparent;
}
} }
} }
} }
......
...@@ -150,15 +150,4 @@ ...@@ -150,15 +150,4 @@
.dropdown-footer .list-unstyled { .dropdown-footer .list-unstyled {
@include gl-m-0; @include gl-m-0;
} }
.color-input-container {
.dropdown-label-color-preview[style] {
@include gl-border-none;
}
.gl-form-input {
@include gl-rounded-top-left-none;
@include gl-rounded-bottom-left-none;
}
}
} }
import Vuex from 'vuex'; import Vuex from 'vuex';
import { shallowMount, createLocalVue } from '@vue/test-utils'; import { shallowMount, createLocalVue } from '@vue/test-utils';
import { GlIcon } from '@gitlab/ui'; import { GlIcon, GlButton } from '@gitlab/ui';
import DropdownButton from '~/vue_shared/components/sidebar/labels_select_vue/dropdown_button.vue'; import DropdownButton from '~/vue_shared/components/sidebar/labels_select_vue/dropdown_button.vue';
import labelSelectModule from '~/vue_shared/components/sidebar/labels_select_vue/store'; import labelSelectModule from '~/vue_shared/components/sidebar/labels_select_vue/store';
...@@ -34,6 +34,10 @@ describe('DropdownButton', () => { ...@@ -34,6 +34,10 @@ describe('DropdownButton', () => {
wrapper.destroy(); wrapper.destroy();
}); });
const findDropdownButton = () => wrapper.find(GlButton);
const findDropdownText = () => wrapper.find('.dropdown-toggle-text');
const findDropdownIcon = () => wrapper.find(GlIcon);
describe('methods', () => { describe('methods', () => {
describe('handleButtonClick', () => { describe('handleButtonClick', () => {
it.each` it.each`
...@@ -41,24 +45,19 @@ describe('DropdownButton', () => { ...@@ -41,24 +45,19 @@ describe('DropdownButton', () => {
${'standalone'} ${'standalone'}
${'embedded'} ${'embedded'}
`( `(
'calls action `toggleDropdownContents` and stops event propagation when `state.variant` is "$variant"', 'toggles dropdown content and stops event propagation when `state.variant` is "$variant"',
({ variant }) => { ({ variant }) => {
const event = { const event = { stopPropagation: jest.fn() };
stopPropagation: jest.fn(),
};
wrapper = createComponent({ wrapper = createComponent({
...mockConfig, ...mockConfig,
variant, variant,
}); });
jest.spyOn(wrapper.vm, 'toggleDropdownContents'); findDropdownButton().vm.$emit('click', event);
wrapper.vm.handleButtonClick(event); expect(store.state.showDropdownContents).toBe(true);
expect(wrapper.vm.toggleDropdownContents).toHaveBeenCalled();
expect(event.stopPropagation).toHaveBeenCalled(); expect(event.stopPropagation).toHaveBeenCalled();
wrapper.destroy();
}, },
); );
}); });
...@@ -70,7 +69,7 @@ describe('DropdownButton', () => { ...@@ -70,7 +69,7 @@ describe('DropdownButton', () => {
}); });
it('renders default button text element', () => { it('renders default button text element', () => {
const dropdownTextEl = wrapper.find('.dropdown-toggle-text'); const dropdownTextEl = findDropdownText();
expect(dropdownTextEl.exists()).toBe(true); expect(dropdownTextEl.exists()).toBe(true);
expect(dropdownTextEl.text()).toBe('Label'); expect(dropdownTextEl.text()).toBe('Label');
...@@ -78,7 +77,7 @@ describe('DropdownButton', () => { ...@@ -78,7 +77,7 @@ describe('DropdownButton', () => {
it('renders provided button text element', () => { it('renders provided button text element', () => {
store.state.dropdownButtonText = 'Custom label'; store.state.dropdownButtonText = 'Custom label';
const dropdownTextEl = wrapper.find('.dropdown-toggle-text'); const dropdownTextEl = findDropdownText();
return wrapper.vm.$nextTick().then(() => { return wrapper.vm.$nextTick().then(() => {
expect(dropdownTextEl.text()).toBe('Custom label'); expect(dropdownTextEl.text()).toBe('Custom label');
...@@ -86,7 +85,7 @@ describe('DropdownButton', () => { ...@@ -86,7 +85,7 @@ describe('DropdownButton', () => {
}); });
it('renders chevron icon element', () => { it('renders chevron icon element', () => {
const iconEl = wrapper.find(GlIcon); const iconEl = findDropdownIcon();
expect(iconEl.exists()).toBe(true); expect(iconEl.exists()).toBe(true);
expect(iconEl.props('name')).toBe('chevron-down'); expect(iconEl.props('name')).toBe('chevron-down');
......
...@@ -96,15 +96,13 @@ describe('LabelsSelectRoot', () => { ...@@ -96,15 +96,13 @@ describe('LabelsSelectRoot', () => {
`( `(
'renders component root element with CSS class `$cssClass` when `state.variant` is "$variant"', 'renders component root element with CSS class `$cssClass` when `state.variant` is "$variant"',
({ variant, cssClass }) => { ({ variant, cssClass }) => {
const wrapperStandalone = createComponent({ wrapper = createComponent({
...mockConfig, ...mockConfig,
variant, variant,
}); });
return wrapperStandalone.vm.$nextTick(() => { return wrapper.vm.$nextTick(() => {
expect(wrapperStandalone.classes()).toContain(cssClass); expect(wrapper.classes()).toContain(cssClass);
wrapperStandalone.destroy();
}); });
}, },
); );
......
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