@@ -11,179 +11,87 @@ test.describe('Broker Protection Captcha', () => {
1111 const recaptchaResponseSelector = '#g-recaptcha-response' ;
1212
1313 test . describe ( 'getCaptchaInfo' , ( ) => {
14- test . describe ( 'with useEnhancedCaptchaSystem: "enabled"' , ( ) => {
15- test ( 'returns the expected response for the correct action data' , async ( { createConfiguredDbp } ) => {
16- const dbp = await createConfiguredDbp ( BROKER_PROTECTION_CONFIGS . enhancedCaptchaSystemEnabled ) ;
17- await dbp . navigatesTo ( recaptchaTargetPage ) ;
18- await dbp . receivesInlineAction ( createGetRecaptchaInfoAction ( ) ) ;
19- const sucessResponse = await dbp . getSuccessResponse ( ) ;
20-
21- dbp . isCaptchaMatch ( sucessResponse , { captchaType : 'recaptcha2' , targetPage : recaptchaTargetPage } ) ;
22- } ) ;
23-
24- test ( 'returns the expected response for the correct action data without the "captchaType" field' , async ( {
25- createConfiguredDbp,
26- } ) => {
27- const dbp = await createConfiguredDbp ( BROKER_PROTECTION_CONFIGS . enhancedCaptchaSystemEnabled ) ;
28- await dbp . navigatesTo ( recaptchaTargetPage ) ;
29- await dbp . receivesInlineAction ( createGetRecaptchaInfoAction ( { captchaType : undefined } ) ) ;
30- const sucessResponse = await dbp . getSuccessResponse ( ) ;
31-
32- dbp . isCaptchaMatch ( sucessResponse , { captchaType : 'recaptcha2' , targetPage : recaptchaTargetPage } ) ;
33- } ) ;
34-
35- test ( 'returns the expected type when the "captchaType" field does not match the detected captcha type' , async ( {
36- createConfiguredDbp,
37- } ) => {
38- const dbp = await createConfiguredDbp ( BROKER_PROTECTION_CONFIGS . enhancedCaptchaSystemEnabled ) ;
39- await dbp . navigatesTo ( recaptchaTargetPage ) ;
40- await dbp . receivesInlineAction ( createGetRecaptchaInfoAction ( { captchaType : 'recaptchaEnterprise' } ) ) ;
41- const sucessResponse = await dbp . getSuccessResponse ( ) ;
42-
43- dbp . isCaptchaMatch ( sucessResponse , { captchaType : 'recaptcha2' , targetPage : recaptchaTargetPage } ) ;
44- } ) ;
45-
46- test ( 'returns an error response for an action data with an invalid "captchaType" field' , async ( {
47- createConfiguredDbp,
48- } ) => {
49- const dbp = await createConfiguredDbp ( BROKER_PROTECTION_CONFIGS . enhancedCaptchaSystemEnabled ) ;
50- await dbp . navigatesTo ( recaptchaTargetPage ) ;
51- await dbp . receivesInlineAction ( createGetRecaptchaInfoAction ( { captchaType : 'invalid' } ) ) ;
52-
53- await dbp . isCaptchaError ( ) ;
54- } ) ;
14+ test ( 'returns the expected response for the correct action data' , async ( { createConfiguredDbp } ) => {
15+ const dbp = await createConfiguredDbp ( BROKER_PROTECTION_CONFIGS . default ) ;
16+ await dbp . navigatesTo ( recaptchaTargetPage ) ;
17+ await dbp . receivesInlineAction ( createGetRecaptchaInfoAction ( ) ) ;
18+ const sucessResponse = await dbp . getSuccessResponse ( ) ;
19+
20+ dbp . isCaptchaMatch ( sucessResponse , { captchaType : 'recaptcha2' , targetPage : recaptchaTargetPage } ) ;
21+ } ) ;
22+
23+ test ( 'returns the expected response for the correct action data without the "captchaType" field' , async ( {
24+ createConfiguredDbp,
25+ } ) => {
26+ const dbp = await createConfiguredDbp ( BROKER_PROTECTION_CONFIGS . default ) ;
27+ await dbp . navigatesTo ( recaptchaTargetPage ) ;
28+ await dbp . receivesInlineAction ( createGetRecaptchaInfoAction ( { captchaType : undefined } ) ) ;
29+ const sucessResponse = await dbp . getSuccessResponse ( ) ;
30+
31+ dbp . isCaptchaMatch ( sucessResponse , { captchaType : 'recaptcha2' , targetPage : recaptchaTargetPage } ) ;
5532 } ) ;
5633
57- test . describe ( 'with useEnhancedCaptchaSystem: "disabled"' , ( ) => {
58- test ( 'returns the expected response for the correct action data' , async ( { createConfiguredDbp } ) => {
59- const dbp = await createConfiguredDbp ( BROKER_PROTECTION_CONFIGS . enhancedCaptchaSystemDisabled ) ;
60- await dbp . navigatesTo ( recaptchaTargetPage ) ;
61- await dbp . receivesInlineAction ( createGetRecaptchaInfoAction ( ) ) ;
62- const sucessResponse = await dbp . getSuccessResponse ( ) ;
63-
64- dbp . isCaptchaMatch ( sucessResponse , { captchaType : 'recaptcha2' , targetPage : recaptchaTargetPage } ) ;
65- } ) ;
66-
67- test ( 'returns the expected response for the correct action data without the "captchaType" field' , async ( {
68- createConfiguredDbp,
69- } ) => {
70- const dbp = await createConfiguredDbp ( BROKER_PROTECTION_CONFIGS . enhancedCaptchaSystemDisabled ) ;
71- await dbp . navigatesTo ( recaptchaTargetPage ) ;
72- await dbp . receivesInlineAction ( createGetRecaptchaInfoAction ( { captchaType : undefined } ) ) ;
73- const sucessResponse = await dbp . getSuccessResponse ( ) ;
74-
75- dbp . isCaptchaMatch ( sucessResponse , { captchaType : 'recaptcha2' , targetPage : recaptchaTargetPage } ) ;
76- } ) ;
77-
78- test ( 'returns the expected type when the "captchaType" field does not match the detected captcha type' , async ( {
79- createConfiguredDbp,
80- } ) => {
81- const dbp = await createConfiguredDbp ( BROKER_PROTECTION_CONFIGS . enhancedCaptchaSystemDisabled ) ;
82- await dbp . navigatesTo ( recaptchaTargetPage ) ;
83- await dbp . receivesInlineAction ( createGetRecaptchaInfoAction ( { captchaType : 'recaptchaEnterprise' } ) ) ;
84- const sucessResponse = await dbp . getSuccessResponse ( ) ;
85-
86- dbp . isCaptchaMatch ( sucessResponse , { captchaType : 'recaptcha2' , targetPage : recaptchaTargetPage } ) ;
87- } ) ;
88-
89- test ( 'returns the expected response for an action data with an invalid "captchaType" field' , async ( {
90- createConfiguredDbp,
91- } ) => {
92- const dbp = await createConfiguredDbp ( BROKER_PROTECTION_CONFIGS . enhancedCaptchaSystemDisabled ) ;
93- await dbp . navigatesTo ( recaptchaTargetPage ) ;
94- await dbp . receivesInlineAction ( createGetRecaptchaInfoAction ( { captchaType : 'invalid' } ) ) ;
95- const sucessResponse = await dbp . getSuccessResponse ( ) ;
96-
97- dbp . isCaptchaMatch ( sucessResponse , { captchaType : 'recaptcha2' , targetPage : recaptchaTargetPage } ) ;
98- } ) ;
34+ test ( 'returns the expected type when the "captchaType" field does not match the detected captcha type' , async ( {
35+ createConfiguredDbp,
36+ } ) => {
37+ const dbp = await createConfiguredDbp ( BROKER_PROTECTION_CONFIGS . default ) ;
38+ await dbp . navigatesTo ( recaptchaTargetPage ) ;
39+ await dbp . receivesInlineAction ( createGetRecaptchaInfoAction ( { captchaType : 'recaptchaEnterprise' } ) ) ;
40+ const sucessResponse = await dbp . getSuccessResponse ( ) ;
41+
42+ dbp . isCaptchaMatch ( sucessResponse , { captchaType : 'recaptcha2' , targetPage : recaptchaTargetPage } ) ;
43+ } ) ;
44+
45+ test ( 'returns an error response for an action data with an invalid "captchaType" field' , async ( { createConfiguredDbp } ) => {
46+ const dbp = await createConfiguredDbp ( BROKER_PROTECTION_CONFIGS . default ) ;
47+ await dbp . navigatesTo ( recaptchaTargetPage ) ;
48+ await dbp . receivesInlineAction ( createGetRecaptchaInfoAction ( { captchaType : 'invalid' } ) ) ;
49+
50+ await dbp . isCaptchaError ( ) ;
9951 } ) ;
10052 } ) ;
10153
10254 test . describe ( 'solveCaptchaInfo' , ( ) => {
103- test . describe ( 'with useEnhancedCaptchaSystem: "enabled"' , ( ) => {
104- test ( 'solves the captcha for the correct action data' , async ( { createConfiguredDbp } ) => {
105- const dbp = await createConfiguredDbp ( BROKER_PROTECTION_CONFIGS . enhancedCaptchaSystemEnabled ) ;
106- await dbp . navigatesTo ( recaptchaTargetPage ) ;
107- await dbp . receivesInlineAction ( createSolveRecaptchaAction ( ) ) ;
108- dbp . getSuccessResponse ( ) ;
109-
110- await dbp . isCaptchaTokenFilled ( recaptchaResponseSelector ) ;
111- } ) ;
112-
113- test ( 'solves the captcha for the correct action data without the "captchaType" field' , async ( { createConfiguredDbp } ) => {
114- const dbp = await createConfiguredDbp ( BROKER_PROTECTION_CONFIGS . enhancedCaptchaSystemEnabled ) ;
115- await dbp . navigatesTo ( recaptchaTargetPage ) ;
116- await dbp . receivesInlineAction ( createSolveRecaptchaAction ( { captchaType : undefined } ) ) ;
117- dbp . getSuccessResponse ( ) ;
118-
119- await dbp . isCaptchaTokenFilled ( recaptchaResponseSelector ) ;
120- } ) ;
121-
122- test ( 'solves the captcha for an action data when the "captchaType" field does not match the detected captcha type' , async ( {
123- createConfiguredDbp,
124- } ) => {
125- const dbp = await createConfiguredDbp ( BROKER_PROTECTION_CONFIGS . enhancedCaptchaSystemEnabled ) ;
126- await dbp . navigatesTo ( recaptchaTargetPage ) ;
127- await dbp . receivesInlineAction ( createSolveRecaptchaAction ( { captchaType : 'recaptchaEnterprise' } ) ) ;
128- dbp . getSuccessResponse ( ) ;
129-
130- await dbp . isCaptchaTokenFilled ( recaptchaResponseSelector ) ;
131- } ) ;
132-
133- test ( 'returns an error response for an action data with an invalid "captchaType" field' , async ( {
134- createConfiguredDbp,
135- } ) => {
136- const dbp = await createConfiguredDbp ( BROKER_PROTECTION_CONFIGS . enhancedCaptchaSystemEnabled ) ;
137- await dbp . navigatesTo ( recaptchaTargetPage ) ;
138- await dbp . receivesInlineAction ( createSolveRecaptchaAction ( { captchaType : 'invalid' } ) ) ;
139-
140- await dbp . isCaptchaError ( ) ;
141- } ) ;
55+ test ( 'solves the captcha for the correct action data' , async ( { createConfiguredDbp } ) => {
56+ const dbp = await createConfiguredDbp ( BROKER_PROTECTION_CONFIGS . default ) ;
57+ await dbp . navigatesTo ( recaptchaTargetPage ) ;
58+ await dbp . receivesInlineAction ( createSolveRecaptchaAction ( ) ) ;
59+ dbp . getSuccessResponse ( ) ;
60+
61+ await dbp . isCaptchaTokenFilled ( recaptchaResponseSelector ) ;
62+ } ) ;
63+
64+ test ( 'solves the captcha for the correct action data without the "captchaType" field' , async ( { createConfiguredDbp } ) => {
65+ const dbp = await createConfiguredDbp ( BROKER_PROTECTION_CONFIGS . default ) ;
66+ await dbp . navigatesTo ( recaptchaTargetPage ) ;
67+ await dbp . receivesInlineAction ( createSolveRecaptchaAction ( { captchaType : undefined } ) ) ;
68+ dbp . getSuccessResponse ( ) ;
69+
70+ await dbp . isCaptchaTokenFilled ( recaptchaResponseSelector ) ;
14271 } ) ;
14372
144- test . describe ( 'with useEnhancedCaptchaSystem: "disabled"' , ( ) => {
145- test ( 'solves the captcha for the correct action data' , async ( { createConfiguredDbp } ) => {
146- const dbp = await createConfiguredDbp ( BROKER_PROTECTION_CONFIGS . enhancedCaptchaSystemDisabled ) ;
147- await dbp . navigatesTo ( recaptchaTargetPage ) ;
148- await dbp . receivesInlineAction ( createSolveRecaptchaAction ( ) ) ;
149- dbp . getSuccessResponse ( ) ;
150-
151- await dbp . isCaptchaTokenFilled ( recaptchaResponseSelector ) ;
152- } ) ;
153-
154- test ( 'solves the captcha for the correct action data without the "captchaType" field' , async ( { createConfiguredDbp } ) => {
155- const dbp = await createConfiguredDbp ( BROKER_PROTECTION_CONFIGS . enhancedCaptchaSystemDisabled ) ;
156- await dbp . navigatesTo ( recaptchaTargetPage ) ;
157- await dbp . receivesInlineAction ( createSolveRecaptchaAction ( { captchaType : undefined } ) ) ;
158- dbp . getSuccessResponse ( ) ;
159-
160- await dbp . isCaptchaTokenFilled ( recaptchaResponseSelector ) ;
161- } ) ;
162-
163- test ( 'solves the captcha for an action when the "captchaType" field does not match the detected captcha type' , async ( {
164- createConfiguredDbp,
165- } ) => {
166- const dbp = await createConfiguredDbp ( BROKER_PROTECTION_CONFIGS . enhancedCaptchaSystemDisabled ) ;
167- await dbp . navigatesTo ( recaptchaTargetPage ) ;
168- await dbp . receivesInlineAction ( createSolveRecaptchaAction ( { captchaType : 'recaptchaEnterprise' } ) ) ;
169- dbp . getSuccessResponse ( ) ;
170-
171- await dbp . isCaptchaTokenFilled ( recaptchaResponseSelector ) ;
172- } ) ;
173-
174- test ( 'solves the captcha for an action data with an invalid "captchaType" field' , async ( { createConfiguredDbp } ) => {
175- const dbp = await createConfiguredDbp ( BROKER_PROTECTION_CONFIGS . enhancedCaptchaSystemDisabled ) ;
176- await dbp . navigatesTo ( recaptchaTargetPage ) ;
177- await dbp . receivesInlineAction ( createSolveRecaptchaAction ( { captchaType : 'invalid' } ) ) ;
178- dbp . getSuccessResponse ( ) ;
179-
180- await dbp . isCaptchaTokenFilled ( recaptchaResponseSelector ) ;
181- } ) ;
73+ test ( 'solves the captcha for an action data when the "captchaType" field does not match the detected captcha type' , async ( {
74+ createConfiguredDbp,
75+ } ) => {
76+ const dbp = await createConfiguredDbp ( BROKER_PROTECTION_CONFIGS . default ) ;
77+ await dbp . navigatesTo ( recaptchaTargetPage ) ;
78+ await dbp . receivesInlineAction ( createSolveRecaptchaAction ( { captchaType : 'recaptchaEnterprise' } ) ) ;
79+ dbp . getSuccessResponse ( ) ;
80+
81+ await dbp . isCaptchaTokenFilled ( recaptchaResponseSelector ) ;
82+ } ) ;
83+
84+ test ( 'returns an error response for an action data with an invalid "captchaType" field' , async ( { createConfiguredDbp } ) => {
85+ const dbp = await createConfiguredDbp ( BROKER_PROTECTION_CONFIGS . default ) ;
86+ await dbp . navigatesTo ( recaptchaTargetPage ) ;
87+ await dbp . receivesInlineAction ( createSolveRecaptchaAction ( { captchaType : 'invalid' } ) ) ;
88+
89+ await dbp . isCaptchaError ( ) ;
18290 } ) ;
18391 } ) ;
18492
18593 test ( 'remove query params from captcha url' , async ( { createConfiguredDbp } ) => {
186- const dbp = await createConfiguredDbp ( BROKER_PROTECTION_CONFIGS . enhancedCaptchaSystemEnabled ) ;
94+ const dbp = await createConfiguredDbp ( BROKER_PROTECTION_CONFIGS . default ) ;
18795 await dbp . navigatesTo ( 're-captcha.html?fname=john&lname=smith' ) ;
18896 await dbp . receivesInlineAction ( createGetRecaptchaInfoAction ( ) ) ;
18997 const sucessResponse = await dbp . getSuccessResponse ( ) ;
0 commit comments