Commit f7648c58 authored by Scott Hampton's avatar Scott Hampton

Merge branch 'pb-disable-trigger-manual-action' into 'master'

Disable trigger manual job button after click

See merge request gitlab-org/gitlab!57885
parents 0425ff3d 7e7751bf
...@@ -43,6 +43,7 @@ export default { ...@@ -43,6 +43,7 @@ export default {
variables: [], variables: [],
key: '', key: '',
secretValue: '', secretValue: '',
triggerBtnDisabled: false,
}; };
}, },
computed: { computed: {
...@@ -98,6 +99,11 @@ export default { ...@@ -98,6 +99,11 @@ export default {
1, 1,
); );
}, },
trigger() {
this.triggerBtnDisabled = true;
this.triggerManualJob(this.variables);
},
}, },
}; };
</script> </script>
...@@ -182,7 +188,9 @@ export default { ...@@ -182,7 +188,9 @@ export default {
variant="info" variant="info"
category="primary" category="primary"
:aria-label="__('Trigger manual job')" :aria-label="__('Trigger manual job')"
@click="triggerManualJob(variables)" :disabled="triggerBtnDisabled"
data-testid="trigger-manual-job-btn"
@click="trigger"
> >
{{ action.button_title }} {{ action.button_title }}
</gl-button> </gl-button>
......
---
title: Disable trigger manual job button after click
merge_request: 57885
author:
type: fixed
import { GlButton } from '@gitlab/ui'; import { GlButton } from '@gitlab/ui';
import { shallowMount, createLocalVue } from '@vue/test-utils'; import { createLocalVue, mount, shallowMount } from '@vue/test-utils';
import Vue from 'vue';
import Vuex from 'vuex';
import Form from '~/jobs/components/manual_variables_form.vue'; import Form from '~/jobs/components/manual_variables_form.vue';
const localVue = createLocalVue(); const localVue = createLocalVue();
Vue.use(Vuex);
describe('Manual Variables Form', () => { describe('Manual Variables Form', () => {
let wrapper; let wrapper;
let store;
const requiredProps = { const requiredProps = {
action: { action: {
...@@ -16,16 +21,21 @@ describe('Manual Variables Form', () => { ...@@ -16,16 +21,21 @@ describe('Manual Variables Form', () => {
variablesSettingsUrl: '/settings', variablesSettingsUrl: '/settings',
}; };
const factory = (props = {}) => { const createComponent = (props = {}, mountFn = shallowMount) => {
wrapper = shallowMount(localVue.extend(Form), { store = new Vuex.Store({
actions: {
triggerManualJob: jest.fn(),
},
});
wrapper = mountFn(localVue.extend(Form), {
propsData: props, propsData: props,
localVue, localVue,
store,
}); });
}; };
beforeEach(() => { const findTriggerBtn = () => wrapper.find('[data-testid="trigger-manual-job-btn"]');
factory(requiredProps);
});
afterEach((done) => { afterEach((done) => {
// The component has a `nextTick` callback after some events so we need // The component has a `nextTick` callback after some events so we need
...@@ -38,8 +48,15 @@ describe('Manual Variables Form', () => { ...@@ -38,8 +48,15 @@ describe('Manual Variables Form', () => {
}); });
}); });
describe('shallowMount', () => {
beforeEach(() => {
createComponent(requiredProps);
});
it('renders empty form with correct placeholders', () => { it('renders empty form with correct placeholders', () => {
expect(wrapper.find({ ref: 'inputKey' }).attributes('placeholder')).toBe('Input variable key'); expect(wrapper.find({ ref: 'inputKey' }).attributes('placeholder')).toBe(
'Input variable key',
);
expect(wrapper.find({ ref: 'inputSecretValue' }).attributes('placeholder')).toBe( expect(wrapper.find({ ref: 'inputSecretValue' }).attributes('placeholder')).toBe(
'Input variable value', 'Input variable value',
); );
...@@ -100,4 +117,19 @@ describe('Manual Variables Form', () => { ...@@ -100,4 +117,19 @@ describe('Manual Variables Form', () => {
expect(wrapper.vm.variables.length).toBe(0); expect(wrapper.vm.variables.length).toBe(0);
}); });
}); });
});
describe('mount', () => {
beforeEach(() => {
createComponent(requiredProps, mount);
});
it('trigger button is disabled after trigger action', async () => {
expect(findTriggerBtn().props('disabled')).toBe(false);
await findTriggerBtn().trigger('click');
expect(findTriggerBtn().props('disabled')).toBe(true);
});
});
}); });
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