Commit 86a705c4 authored by Jarek Ostrowski's avatar Jarek Ostrowski Committed by Natalia Tepluhina
parent 613044b1
<script> <script>
import $ from 'jquery'; import $ from 'jquery';
import { GlLoadingIcon } from '@gitlab/ui'; import { GlButton } from '@gitlab/ui';
import { mapActions } from 'vuex'; import { mapActions } from 'vuex';
import { __ } from '~/locale'; import { __ } from '~/locale';
import { deprecatedCreateFlash as Flash } from '~/flash'; import { deprecatedCreateFlash as Flash } from '~/flash';
...@@ -8,7 +8,7 @@ import eventHub from '../../event_hub'; ...@@ -8,7 +8,7 @@ import eventHub from '../../event_hub';
export default { export default {
components: { components: {
GlLoadingIcon, GlButton,
}, },
props: { props: {
fullPath: { fullPath: {
...@@ -64,18 +64,18 @@ export default { ...@@ -64,18 +64,18 @@ export default {
<template> <template>
<div class="sidebar-item-warning-message-actions"> <div class="sidebar-item-warning-message-actions">
<button type="button" class="btn btn-default gl-mr-3" @click="closeForm"> <gl-button class="gl-mr-3" @click="closeForm">
{{ __('Cancel') }} {{ __('Cancel') }}
</button> </gl-button>
<button <gl-button
type="button" category="secondary"
class="btn btn-close" variant="warning"
data-testid="confidential-toggle"
:disabled="isLoading" :disabled="isLoading"
:loading="isLoading"
data-testid="confidential-toggle"
@click.prevent="submitForm" @click.prevent="submitForm"
> >
<gl-loading-icon v-if="isLoading" inline />
{{ toggleButtonText }} {{ toggleButtonText }}
</button> </gl-button>
</div> </div>
</template> </template>
---
title: Update confidential form buttons to gl-button
merge_request: 40893
author:
type: changed
...@@ -39,7 +39,7 @@ RSpec.describe 'Issues > User sees live update', :js do ...@@ -39,7 +39,7 @@ RSpec.describe 'Issues > User sees live update', :js do
expect(page).to have_css('.sidebar-item-warning-message') expect(page).to have_css('.sidebar-item-warning-message')
within('.sidebar-item-warning-message') do within('.sidebar-item-warning-message') do
find('.btn-close').click find('[data-testid="confidential-toggle"]').click
end end
wait_for_requests wait_for_requests
......
import { shallowMount } from '@vue/test-utils'; import { shallowMount } from '@vue/test-utils';
import { GlLoadingIcon } from '@gitlab/ui';
import waitForPromises from 'helpers/wait_for_promises'; import waitForPromises from 'helpers/wait_for_promises';
import EditFormButtons from '~/sidebar/components/confidential/edit_form_buttons.vue'; import EditFormButtons from '~/sidebar/components/confidential/edit_form_buttons.vue';
import eventHub from '~/sidebar/event_hub'; import eventHub from '~/sidebar/event_hub';
...@@ -56,11 +55,11 @@ describe('Edit Form Buttons', () => { ...@@ -56,11 +55,11 @@ describe('Edit Form Buttons', () => {
}); });
it('disables the toggle button', () => { it('disables the toggle button', () => {
expect(findConfidentialToggle().attributes('disabled')).toBe('disabled'); expect(findConfidentialToggle().props('disabled')).toBe(true);
}); });
it('finds the GlLoadingIcon', () => { it('sets loading on the toggle button', () => {
expect(wrapper.find(GlLoadingIcon).exists()).toBe(true); expect(findConfidentialToggle().props('loading')).toBe(true);
}); });
}); });
...@@ -99,7 +98,7 @@ describe('Edit Form Buttons', () => { ...@@ -99,7 +98,7 @@ describe('Edit Form Buttons', () => {
describe('when succeeds', () => { describe('when succeeds', () => {
beforeEach(() => { beforeEach(() => {
createComponent({ data: { isLoading: false }, props: { confidential: true } }); createComponent({ data: { isLoading: false }, props: { confidential: true } });
findConfidentialToggle().trigger('click'); findConfidentialToggle().vm.$emit('click', new Event('click'));
}); });
it('dispatches the correct action', () => { it('dispatches the correct action', () => {
...@@ -109,9 +108,9 @@ describe('Edit Form Buttons', () => { ...@@ -109,9 +108,9 @@ describe('Edit Form Buttons', () => {
}); });
}); });
it('resets loading', () => { it('resets loading on the toggle button', () => {
return waitForPromises().then(() => { return waitForPromises().then(() => {
expect(wrapper.find(GlLoadingIcon).exists()).toBe(false); expect(findConfidentialToggle().props('loading')).toBe(false);
}); });
}); });
...@@ -135,7 +134,7 @@ describe('Edit Form Buttons', () => { ...@@ -135,7 +134,7 @@ describe('Edit Form Buttons', () => {
props: { confidential: true }, props: { confidential: true },
resolved: false, resolved: false,
}); });
findConfidentialToggle().trigger('click'); findConfidentialToggle().vm.$emit('click', new Event('click'));
}); });
it('calls flash with the correct message', () => { it('calls flash with the correct message', () => {
......
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