Commit 3aa2b656 authored by Brandon Labuschagne's avatar Brandon Labuschagne

Merge branch 'remove-captcha-from-description-vue' into 'master'

Remove CAPTCHA support from issue description.vue component

See merge request gitlab-org/gitlab!55136
parents e697d3da ca58ffae
...@@ -4,7 +4,6 @@ import $ from 'jquery'; ...@@ -4,7 +4,6 @@ import $ from 'jquery';
import { deprecatedCreateFlash as createFlash } from '~/flash'; import { deprecatedCreateFlash as createFlash } from '~/flash';
import { s__, sprintf } from '~/locale'; import { s__, sprintf } from '~/locale';
import TaskList from '../../task_list'; import TaskList from '../../task_list';
import recaptchaModalImplementor from '../../vue_shared/mixins/recaptcha_modal_implementor';
import animateMixin from '../mixins/animate'; import animateMixin from '../mixins/animate';
export default { export default {
...@@ -12,7 +11,7 @@ export default { ...@@ -12,7 +11,7 @@ export default {
SafeHtml, SafeHtml,
}, },
mixins: [animateMixin, recaptchaModalImplementor], mixins: [animateMixin],
props: { props: {
canUpdate: { canUpdate: {
...@@ -87,21 +86,11 @@ export default { ...@@ -87,21 +86,11 @@ export default {
fieldName: 'description', fieldName: 'description',
lockVersion: this.lockVersion, lockVersion: this.lockVersion,
selector: '.detail-page-description', selector: '.detail-page-description',
onSuccess: this.taskListUpdateSuccess.bind(this),
onError: this.taskListUpdateError.bind(this), onError: this.taskListUpdateError.bind(this),
}); });
} }
}, },
taskListUpdateSuccess(data) {
try {
this.checkForSpam(data);
this.closeRecaptcha();
} catch (error) {
if (error && error.name === 'SpamError') this.openRecaptcha();
}
},
taskListUpdateError() { taskListUpdateError() {
createFlash( createFlash(
sprintf( sprintf(
...@@ -165,7 +154,5 @@ export default { ...@@ -165,7 +154,5 @@ export default {
> >
</textarea> </textarea>
<!-- eslint-enable vue/no-mutating-props --> <!-- eslint-enable vue/no-mutating-props -->
<recaptcha-modal v-show="showRecaptcha" :html="recaptchaHTML" @close="closeRecaptcha" />
</div> </div>
</template> </template>
...@@ -70,36 +70,6 @@ describe('Description component', () => { ...@@ -70,36 +70,6 @@ describe('Description component', () => {
}); });
}); });
it('opens reCAPTCHA dialog if update rejected as spam', () => {
let modal;
const recaptchaChild = vm.$children.find(
// eslint-disable-next-line no-underscore-dangle
(child) => child.$options._componentTag === 'recaptcha-modal',
);
recaptchaChild.scriptSrc = '//scriptsrc';
vm.taskListUpdateSuccess({
recaptcha_html: '<div class="g-recaptcha">recaptcha_html</div>',
});
return vm
.$nextTick()
.then(() => {
modal = vm.$el.querySelector('.js-recaptcha-modal');
expect(modal.style.display).not.toEqual('none');
expect(modal.querySelector('.g-recaptcha').textContent).toEqual('recaptcha_html');
expect(document.body.querySelector('.js-recaptcha-script').src).toMatch('//scriptsrc');
})
.then(() => modal.querySelector('.close').click())
.then(() => vm.$nextTick())
.then(() => {
expect(modal.style.display).toEqual('none');
expect(document.body.querySelector('.js-recaptcha-script')).toBeNull();
});
});
it('applies syntax highlighting and math when description changed', () => { it('applies syntax highlighting and math when description changed', () => {
const vmSpy = jest.spyOn(vm, 'renderGFM'); const vmSpy = jest.spyOn(vm, 'renderGFM');
const prototypeSpy = jest.spyOn($.prototype, 'renderGFM'); const prototypeSpy = jest.spyOn($.prototype, 'renderGFM');
...@@ -144,7 +114,6 @@ describe('Description component', () => { ...@@ -144,7 +114,6 @@ describe('Description component', () => {
dataType: 'issuableType', dataType: 'issuableType',
fieldName: 'description', fieldName: 'description',
selector: '.detail-page-description', selector: '.detail-page-description',
onSuccess: expect.any(Function),
onError: expect.any(Function), onError: expect.any(Function),
lockVersion: 0, lockVersion: 0,
}); });
......
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