Commit 12d275ad authored by Filipa Lacerda's avatar Filipa Lacerda

Merge branch 'acet-disabled-comment-textarea-while-requesting' into 'master'

Disable comment textarea while submitting a new comment.

Closes #37858

See merge request gitlab-org/gitlab-ce!14541
parents be6344d9 cba95d9e
...@@ -272,6 +272,7 @@ ...@@ -272,6 +272,7 @@
v-model="note" v-model="note"
ref="textarea" ref="textarea"
slot="textarea" slot="textarea"
:disabled="isSubmitting"
placeholder="Write a comment or drag your files here..." placeholder="Write a comment or drag your files here..."
@keydown.up="editCurrentUserLastNote()" @keydown.up="editCurrentUserLastNote()"
@keydown.meta.enter="handleSave()"> @keydown.meta.enter="handleSave()">
......
...@@ -33,6 +33,30 @@ describe('issue_comment_form component', () => { ...@@ -33,6 +33,30 @@ describe('issue_comment_form component', () => {
expect(vm.$el.querySelector('.timeline-icon .user-avatar-link').getAttribute('href')).toEqual(userDataMock.path); expect(vm.$el.querySelector('.timeline-icon .user-avatar-link').getAttribute('href')).toEqual(userDataMock.path);
}); });
describe('handleSave', () => {
it('should request to save note when note is entered', () => {
vm.note = 'hello world';
spyOn(vm, 'saveNote').and.returnValue(new Promise(() => {}));
spyOn(vm, 'resizeTextarea');
spyOn(vm, 'stopPolling');
vm.handleSave();
expect(vm.isSubmitting).toEqual(true);
expect(vm.note).toEqual('');
expect(vm.saveNote).toHaveBeenCalled();
expect(vm.stopPolling).toHaveBeenCalled();
expect(vm.resizeTextarea).toHaveBeenCalled();
});
it('should toggle issue state when no note', () => {
spyOn(vm, 'toggleIssueState');
vm.handleSave();
expect(vm.toggleIssueState).toHaveBeenCalled();
});
});
describe('textarea', () => { describe('textarea', () => {
it('should render textarea with placeholder', () => { it('should render textarea with placeholder', () => {
expect( expect(
...@@ -40,6 +64,22 @@ describe('issue_comment_form component', () => { ...@@ -40,6 +64,22 @@ describe('issue_comment_form component', () => {
).toEqual('Write a comment or drag your files here...'); ).toEqual('Write a comment or drag your files here...');
}); });
it('should make textarea disabled while requesting', (done) => {
const $submitButton = $(vm.$el.querySelector('.js-comment-submit-button'));
vm.note = 'hello world';
spyOn(vm, 'stopPolling');
spyOn(vm, 'saveNote').and.returnValue(new Promise(() => {}));
vm.$nextTick(() => { // Wait for vm.note change triggered. It should enable $submitButton.
$submitButton.trigger('click');
vm.$nextTick(() => { // Wait for vm.isSubmitting triggered. It should disable textarea.
expect(vm.$el.querySelector('.js-main-target-form textarea').disabled).toBeTruthy();
done();
});
});
});
it('should support quick actions', () => { it('should support quick actions', () => {
expect( expect(
vm.$el.querySelector('.js-main-target-form textarea').getAttribute('data-supports-quick-actions'), vm.$el.querySelector('.js-main-target-form textarea').getAttribute('data-supports-quick-actions'),
......
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