Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2023-12-20 15:07:18 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2023-12-20 15:07:18 +0300
commit6cde390d022b50a8a80c0f7d3950771474129562 (patch)
tree09f3ba747a6a9567372b9218cca11285d6e21db6 /spec
parent0b7d3f810f287523fd4ad72c019d78e8d2983f8a (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
-rw-r--r--spec/frontend/captcha/captcha_modal_spec.js63
1 files changed, 63 insertions, 0 deletions
diff --git a/spec/frontend/captcha/captcha_modal_spec.js b/spec/frontend/captcha/captcha_modal_spec.js
index 4bbed8ab3bb..977c685739f 100644
--- a/spec/frontend/captcha/captcha_modal_spec.js
+++ b/spec/frontend/captcha/captcha_modal_spec.js
@@ -1,6 +1,7 @@
import { GlModal } from '@gitlab/ui';
import { shallowMount } from '@vue/test-utils';
import { stubComponent } from 'helpers/stub_component';
+import waitForPromises from 'helpers/wait_for_promises';
import CaptchaModal from '~/captcha/captcha_modal.vue';
import { initRecaptchaScript } from '~/captcha/init_recaptcha_script';
@@ -36,6 +37,7 @@ describe('Captcha Modal', () => {
beforeEach(() => {
grecaptcha = {
render: jest.fn(),
+ reset: jest.fn(),
};
initRecaptchaScript.mockResolvedValue(grecaptcha);
@@ -156,4 +158,65 @@ describe('Captcha Modal', () => {
});
});
});
+
+ describe('when showModal is false', () => {
+ beforeEach(() => {
+ createComponent({ props: { showModal: false, needsCaptchaResponse: true } });
+ });
+
+ it('does not render the modal', () => {
+ expect(findGlModal().exists()).toBe(false);
+ });
+
+ it('renders captcha', () => {
+ expect(grecaptcha.render).toHaveBeenCalledWith(wrapper.vm.$refs.captcha, {
+ sitekey: captchaSiteKey,
+ callback: expect.any(Function),
+ });
+ });
+ });
+
+ describe('needsCaptchaResponse watcher', () => {
+ describe('when showModal is true', () => {
+ beforeEach(() => {
+ createComponent({ props: { showModal: true, needsCaptchaResponse: false } });
+ wrapper.setProps({ needsCaptchaResponse: true });
+ });
+
+ it('shows modal', () => {
+ expect(showSpy).toHaveBeenCalled();
+ });
+ });
+
+ describe('when showModal is false', () => {
+ beforeEach(() => {
+ createComponent({ props: { showModal: false, needsCaptchaResponse: false } });
+ wrapper.setProps({ needsCaptchaResponse: true });
+ });
+
+ it('does not render the modal', () => {
+ expect(findGlModal().exists()).toBe(false);
+ });
+
+ it('renders captcha', () => {
+ expect(grecaptcha.render).toHaveBeenCalledWith(wrapper.vm.$refs.captcha, {
+ sitekey: captchaSiteKey,
+ callback: expect.any(Function),
+ });
+ });
+ });
+ });
+
+ describe('resetSession watcher', () => {
+ beforeEach(() => {
+ createComponent({ props: { showModal: false, needsCaptchaResponse: true } });
+ });
+
+ it('calls reset when resetSession is true', async () => {
+ await waitForPromises();
+ await wrapper.setProps({ resetSession: true });
+
+ expect(grecaptcha.reset).toHaveBeenCalled();
+ });
+ });
});