overleaf-cep/services/web/frontend/js/shared/components/recaptcha-2.tsx
Jakob Ackermann 7b69d61540 [saas-e2e] initial revision of SaaS E2E tests running in the dev-env (#24311)
* [saas-e2e] initial revision of SaaS E2E tests running in the dev-env

* [v1] make rubocop happy

* [v1] make rubocop happy

* [saas-e2e] more retries for webpack startup check

Co-authored-by: Alf Eaton <alf.eaton@overleaf.com>

* [web] restrict e2e_test_setup.mjs to running in the dev-env

Co-authored-by: Mathias Jakobsen <mathias.jakobsen@overleaf.com>

* [saas-e2e] import latest split-tests from production

---------

Co-authored-by: Alf Eaton <alf.eaton@overleaf.com>
Co-authored-by: Mathias Jakobsen <mathias.jakobsen@overleaf.com>
GitOrigin-RevId: 034343ee56b8d059090d8a5de74eaac24429b527
2025-03-24 10:46:15 +00:00

36 lines
924 B
TypeScript

import ReCAPTCHA from 'react-google-recaptcha'
import getMeta from '@/utils/meta'
import { ExposedSettings } from '../../../../types/exposed-settings'
interface ReCaptcha2Props
extends Pick<React.ComponentProps<typeof ReCAPTCHA>, 'onChange'> {
page: keyof ExposedSettings['recaptchaDisabled']
recaptchaRef: React.LegacyRef<ReCAPTCHA>
}
export function ReCaptcha2({
page: site,
onChange,
recaptchaRef,
}: ReCaptcha2Props) {
const { recaptchaSiteKey, recaptchaDisabled } = getMeta('ol-ExposedSettings')
if (!recaptchaSiteKey) {
return null
}
if (site && recaptchaDisabled[site]) {
return null
}
if (process.env.NODE_ENV === 'development' && window.Cypress) {
return null // Disable captcha for E2E tests in dev-env.
}
return (
<ReCAPTCHA
ref={recaptchaRef}
size="invisible"
sitekey={recaptchaSiteKey}
onChange={onChange}
badge="inline"
/>
)
}