Skip to content

Commit 88d036c

Browse files
authored
Merge pull request #169 from magento-lynx/graphql-api-enhancements
2 parents d9d1406 + fa80860 commit 88d036c

File tree

3 files changed

+15
-5
lines changed

3 files changed

+15
-5
lines changed

ReCaptchaWebapiGraphQl/Model/Resolver/ReCaptchaV3.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,8 @@ public function resolve(
8282
'badge_position' => $this->reCaptchaV3Config->getBadgePosition(),
8383
'language_code' => $this->reCaptchaV3Config->getLanguageCode(),
8484
'failure_message' => $this->getFailureMessage(),
85-
'forms' => $this->getEnumFormTypes()
85+
'forms' => $this->getEnumFormTypes(),
86+
'theme' => $this->reCaptchaV3Config->getTheme()
8687
];
8788
}
8889

ReCaptchaWebapiGraphQl/Test/Api/ReCaptchaV3ConfigTest.php

+12-4
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
namespace Magento\ReCaptchaWebapiGraphQl\Test\Api;
99

10+
use Exception;
1011
use Magento\Framework\Encryption\EncryptorInterface;
1112
use Magento\TestFramework\Fixture\Config;
1213
use Magento\Framework\App\ResourceConnection;
@@ -29,6 +30,7 @@ class ReCaptchaV3ConfigTest extends GraphQlAbstract
2930
language_code
3031
failure_message
3132
forms
33+
theme
3234
}
3335
}
3436
QUERY;
@@ -49,6 +51,7 @@ public function setUp(): void
4951
Config('recaptcha_frontend/type_recaptcha_v3/score_threshold', 0.75),
5052
Config('recaptcha_frontend/type_recaptcha_v3/position', 'bottomright'),
5153
Config('recaptcha_frontend/type_recaptcha_v3/lang', 'en'),
54+
Config('recaptcha_frontend/type_recaptcha_v3/theme', 'light'),
5255
Config('recaptcha_frontend/failure_messages/validation_failure_message', 'Test failure message'),
5356
Config('recaptcha_frontend/type_for/customer_login', 'recaptcha_v3')
5457
]
@@ -65,7 +68,8 @@ public function testQueryRecaptchaNoPublicKeyConfigured(): void
6568
'failure_message' => 'Test failure message',
6669
'forms' => [
6770
'CUSTOMER_LOGIN'
68-
]
71+
],
72+
'theme' => 'light'
6973
]
7074
],
7175
$this->graphQlQuery(self::QUERY)
@@ -76,6 +80,7 @@ public function testQueryRecaptchaNoPublicKeyConfigured(): void
7680
Config('recaptcha_frontend/type_recaptcha_v3/score_threshold', 0.75),
7781
Config('recaptcha_frontend/type_recaptcha_v3/position', 'bottomright'),
7882
Config('recaptcha_frontend/type_recaptcha_v3/lang', 'en'),
83+
Config('recaptcha_frontend/type_recaptcha_v3/theme', 'light'),
7984
Config('recaptcha_frontend/failure_messages/validation_failure_message', 'Test failure message')
8085
]
8186
public function testQueryRecaptchaNoFormsConfigured(): void
@@ -100,7 +105,8 @@ public function testQueryRecaptchaNoFormsConfigured(): void
100105
'badge_position' => 'bottomright',
101106
'language_code' => 'en',
102107
'failure_message' => 'Test failure message',
103-
'forms' => []
108+
'forms' => [],
109+
'theme' => 'light'
104110
]
105111
],
106112
$this->graphQlQuery(self::QUERY)
@@ -111,6 +117,7 @@ public function testQueryRecaptchaNoFormsConfigured(): void
111117
Config('recaptcha_frontend/type_recaptcha_v3/score_threshold', 0.75),
112118
Config('recaptcha_frontend/type_recaptcha_v3/position', 'bottomright'),
113119
Config('recaptcha_frontend/type_recaptcha_v3/lang', 'en'),
120+
Config('recaptcha_frontend/type_recaptcha_v3/theme', 'dark'),
114121
Config('recaptcha_frontend/failure_messages/validation_failure_message', 'Test failure message'),
115122
Config('recaptcha_frontend/type_for/customer_login', 'recaptcha_v3')
116123
]
@@ -138,7 +145,8 @@ public function testQueryRecaptchaConfigured(): void
138145
'failure_message' => 'Test failure message',
139146
'forms' => [
140147
'CUSTOMER_LOGIN'
141-
]
148+
],
149+
'theme' => 'dark'
142150
]
143151
],
144152
$this->graphQlQuery(self::QUERY)
@@ -151,7 +159,7 @@ public function tearDown(): void
151159
$resource = Bootstrap::getObjectManager()->get(ResourceConnection::class);
152160
/** @var AdapterInterface $connection */
153161
$connection = $resource->getConnection(ResourceConnection::DEFAULT_CONNECTION);
154-
162+
155163
$connection->delete(
156164
$resource->getTableName('core_config_data')
157165
);

ReCaptchaWebapiGraphQl/etc/schema.graphqls

+1
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,5 @@ type ReCaptchaConfigurationV3 @doc(description: "Contains reCAPTCHA V3-Invisible
5050
language_code: String @doc(description: "A two-character code that specifies the language that is used for Google reCAPTCHA text and messaging.")
5151
failure_message: String! @doc(description: "The message that appears to the user if validation fails.")
5252
forms: [ReCaptchaFormEnum!]! @doc(description: "A list of forms on the storefront that have been configured to use reCAPTCHA V3.")
53+
theme: String! @doc(description: "Theme to be used to render reCaptcha.")
5354
}

0 commit comments

Comments
 (0)