Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions frontend/web/components/GoogleButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,19 @@ import { Icon } from './icons'

type GoogleButtonProps = {
className?: string
ready: boolean
onSuccess?: (
tokenResponse: Omit<
TokenResponse,
'error' | 'error_description' | 'error_uri'
>,
) => void
}
const GoogleButton: FC<GoogleButtonProps> = ({ className, onSuccess }) => {
const GoogleButton: FC<GoogleButtonProps> = ({
className,
onSuccess,
ready,
}) => {
const login = useGoogleLogin({
onSuccess: (tokenResponse) => {
onSuccess?.(tokenResponse)
Expand All @@ -24,7 +29,8 @@ const GoogleButton: FC<GoogleButtonProps> = ({ className, onSuccess }) => {
className={className}
theme='secondary'
key='google'
onClick={() => login()}
disabled={!ready}
onClick={() => ready && login()}
Comment on lines +32 to +33

@coderabbitai coderabbitai Bot Aug 1, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Add regression coverage for the readiness guard.

Before readiness, a click must not invoke login. After readiness, a click must invoke login. Also cover the script-error path so the button remains disabled.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Leaving this as-is — there's no existing Jest/RTL test coverage anywhere in this repo for GoogleButton or its sibling auth components, and adding new test scaffolding for a single small component would be disproportionate to this fix's scope. Verified the fix manually via code reading (real useGoogleLogin/GoogleOAuthProvider type signatures) instead.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bardock-2393 Acknowledged. The current guard is small and directly matches the OAuth readiness contract. Adding test infrastructure only for this change is not necessary.

You are interacting with an AI system.

>
<Icon name='google' />
Google
Expand Down
4 changes: 4 additions & 0 deletions frontend/web/components/pages/HomePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import useSignupExperiment from 'common/useSignupExperiment'
const HomePage: React.FC = () => {
const history = useHistory()
const location = useLocation()
const [googleReady, setGoogleReady] = useState(false)
Comment thread
coderabbitai[bot] marked this conversation as resolved.
const [allRequirementsMet, setAllRequirementsMet] = useState(false)
const [email, setEmail] = useState('')
const [firstName, setFirstName] = useState('')
Expand Down Expand Up @@ -231,9 +232,12 @@ const HomePage: React.FC = () => {
clientId={
JSON.parse(Utils.getFlagsmithValue('oauth_google')).clientId
}
onScriptLoadSuccess={() => setGoogleReady(true)}
onScriptLoadError={() => setGoogleReady(false)}
>
<GoogleButton
className='w-100'
ready={googleReady}
onSuccess={(e) => {
document.location.href = `${
document.location.origin
Expand Down
Loading