Skip to content

Commit 8e1e104

Browse files
committed
refactor: Update react tests to use core config
1 parent 5e4103e commit 8e1e104

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+613
-1046
lines changed

packages/firebaseui-react/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@
2323
"lint": "tsc --noEmit",
2424
"format": "prettier --write \"src/**/*.ts\"",
2525
"clean": "rimraf dist",
26-
"test:unit": "TEST_TYPE=unit vitest run tests/unit",
27-
"test:unit:watch": "TEST_TYPE=unit vitest tests/unit",
28-
"test:integration": "TEST_TYPE=integration vitest run tests/integration",
29-
"test:integration:watch": "TEST_TYPE=integration vitest tests/integration"
26+
"test:unit": "vitest run tests/unit",
27+
"test:unit:watch": "vitest tests/unit",
28+
"test:integration": "vitest run tests/integration",
29+
"test:integration:watch": "vitest tests/integration"
3030
},
3131
"peerDependencies": {
3232
"@firebase-ui/core": "workspace:*",

packages/firebaseui-react/src/auth/forms/email-link-form.tsx

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,11 @@ import { useEffect, useMemo, useState } from "react";
1212
import { useAuth, useUI } from "~/hooks";
1313
import { Button } from "../../components/button";
1414
import { FieldInfo } from "../../components/field-info";
15-
import {
16-
TermsAndPrivacy,
17-
TermsAndPrivacyProps,
18-
} from "../../components/terms-and-privacy";
15+
import { Policies } from "../../components/policies";
1916

20-
interface EmailLinkFormProps extends TermsAndPrivacyProps {}
17+
interface EmailLinkFormProps {}
2118

22-
export function EmailLinkForm({
23-
tosUrl,
24-
privacyPolicyUrl,
25-
}: EmailLinkFormProps) {
19+
export function EmailLinkForm(_: EmailLinkFormProps) {
2620
const ui = useUI();
2721
const auth = useAuth(ui);
2822

@@ -124,7 +118,7 @@ export function EmailLinkForm({
124118
/>
125119
</fieldset>
126120

127-
<TermsAndPrivacy tosUrl={tosUrl} privacyPolicyUrl={privacyPolicyUrl} />
121+
<Policies />
128122

129123
<fieldset>
130124
<Button type="submit" disabled={ui.state !== "idle"}>

packages/firebaseui-react/src/auth/forms/email-password-form.tsx

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,16 @@ import { useMemo, useState } from "react";
1212
import { useUI } from "~/hooks";
1313
import { Button } from "../../components/button";
1414
import { FieldInfo } from "../../components/field-info";
15-
import {
16-
TermsAndPrivacy,
17-
TermsAndPrivacyProps,
18-
} from "../../components/terms-and-privacy";
15+
import { Policies } from "../../components/policies";
1916

20-
interface EmailPasswordFormProps extends TermsAndPrivacyProps {
17+
interface EmailPasswordFormProps {
2118
onForgotPasswordClick?: () => void;
2219
onRegisterClick?: () => void;
2320
}
2421

2522
export function EmailPasswordForm({
2623
onForgotPasswordClick,
2724
onRegisterClick,
28-
tosUrl,
29-
privacyPolicyUrl,
3025
}: EmailPasswordFormProps) {
3126
const ui = useUI();
3227

@@ -155,7 +150,7 @@ export function EmailPasswordForm({
155150
/>
156151
</fieldset>
157152

158-
<TermsAndPrivacy tosUrl={tosUrl} privacyPolicyUrl={privacyPolicyUrl} />
153+
<Policies />
159154

160155
<fieldset>
161156
<Button type="submit" disabled={ui.state !== "idle"}>

packages/firebaseui-react/src/auth/forms/forgot-password-form.tsx

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,14 @@ import { useMemo, useState } from "react";
1212
import { useUI } from "~/hooks";
1313
import { Button } from "../../components/button";
1414
import { FieldInfo } from "../../components/field-info";
15-
import {
16-
TermsAndPrivacy,
17-
TermsAndPrivacyProps,
18-
} from "../../components/terms-and-privacy";
15+
import { Policies } from "../../components/policies";
1916

20-
interface ForgotPasswordFormProps extends TermsAndPrivacyProps {
17+
interface ForgotPasswordFormProps {
2118
onBackToSignInClick?: () => void;
2219
}
2320

2421
export function ForgotPasswordForm({
2522
onBackToSignInClick,
26-
tosUrl,
27-
privacyPolicyUrl,
2823
}: ForgotPasswordFormProps) {
2924
const ui = useUI();
3025

@@ -113,7 +108,7 @@ export function ForgotPasswordForm({
113108
/>
114109
</fieldset>
115110

116-
<TermsAndPrivacy tosUrl={tosUrl} privacyPolicyUrl={privacyPolicyUrl} />
111+
<Policies />
117112

118113
<fieldset>
119114
<Button type="submit" disabled={ui.state !== "idle"}>

packages/firebaseui-react/src/auth/forms/phone-form.tsx

Lines changed: 9 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -18,27 +18,20 @@ import { useAuth, useUI } from "~/hooks";
1818
import { Button } from "../../components/button";
1919
import { CountrySelector } from "../../components/country-selector";
2020
import { FieldInfo } from "../../components/field-info";
21-
import {
22-
TermsAndPrivacy,
23-
TermsAndPrivacyProps,
24-
} from "../../components/terms-and-privacy";
21+
import { Policies } from "../../components/policies";
2522

26-
interface PhoneNumberFormProps extends TermsAndPrivacyProps {
23+
interface PhoneNumberFormProps {
2724
onSubmit: (phoneNumber: string) => Promise<void>;
2825
formError: string | null;
2926
recaptchaVerifier: RecaptchaVerifier | null;
3027
recaptchaContainerRef: React.RefObject<HTMLDivElement | null>;
31-
showTerms?: boolean;
3228
}
3329

3430
function PhoneNumberForm({
3531
onSubmit,
3632
formError,
3733
recaptchaVerifier,
3834
recaptchaContainerRef,
39-
showTerms,
40-
tosUrl,
41-
privacyPolicyUrl,
4235
}: PhoneNumberFormProps) {
4336
const ui = useUI();
4437

@@ -128,9 +121,7 @@ function PhoneNumberForm({
128121
<div className="fui-recaptcha-container" ref={recaptchaContainerRef} />
129122
</fieldset>
130123

131-
{showTerms && (
132-
<TermsAndPrivacy tosUrl={tosUrl} privacyPolicyUrl={privacyPolicyUrl} />
133-
)}
124+
<Policies />
134125

135126
<fieldset>
136127
<Button
@@ -185,11 +176,10 @@ function useResendTimer(initialDelay: number) {
185176
return { timeLeft, canResend, startTimer };
186177
}
187178

188-
interface VerificationFormProps extends TermsAndPrivacyProps {
179+
interface VerificationFormProps {
189180
onSubmit: (code: string) => Promise<void>;
190181
onResend: () => Promise<void>;
191182
formError: string | null;
192-
showTerms?: boolean;
193183
isResending: boolean;
194184
canResend: boolean;
195185
timeLeft: number;
@@ -200,13 +190,10 @@ function VerificationForm({
200190
onSubmit,
201191
onResend,
202192
formError,
203-
showTerms,
204193
isResending,
205194
canResend,
206195
timeLeft,
207196
recaptchaContainerRef,
208-
tosUrl,
209-
privacyPolicyUrl,
210197
}: VerificationFormProps) {
211198
const ui = useUI();
212199

@@ -281,9 +268,7 @@ function VerificationForm({
281268
<div className="fui-recaptcha-container" ref={recaptchaContainerRef} />
282269
</fieldset>
283270

284-
{showTerms && (
285-
<TermsAndPrivacy tosUrl={tosUrl} privacyPolicyUrl={privacyPolicyUrl} />
286-
)}
271+
<Policies />
287272

288273
<fieldset>
289274
<Button type="submit" disabled={ui.state !== "idle"}>
@@ -298,24 +283,20 @@ function VerificationForm({
298283
{isResending
299284
? getTranslation(ui, "labels", "sending")
300285
: !canResend
301-
? `${getTranslation(ui, "labels", "resendCode")} (${timeLeft}s)`
302-
: getTranslation(ui, "labels", "resendCode")}
286+
? `${getTranslation(ui, "labels", "resendCode")} (${timeLeft}s)`
287+
: getTranslation(ui, "labels", "resendCode")}
303288
</Button>
304289
{formError && <div className="fui-form__error">{formError}</div>}
305290
</fieldset>
306291
</form>
307292
);
308293
}
309294

310-
export interface PhoneFormProps extends TermsAndPrivacyProps {
295+
export interface PhoneFormProps {
311296
resendDelay?: number;
312297
}
313298

314-
export function PhoneForm({
315-
resendDelay = 30,
316-
tosUrl,
317-
privacyPolicyUrl,
318-
}: PhoneFormProps) {
299+
export function PhoneForm({ resendDelay = 30 }: PhoneFormProps) {
319300
const ui = useUI();
320301
const auth = useAuth(ui);
321302

@@ -437,23 +418,17 @@ export function PhoneForm({
437418
onSubmit={handleVerificationSubmit}
438419
onResend={handleResend}
439420
formError={formError}
440-
showTerms={false}
441421
isResending={isResending}
442422
canResend={canResend}
443423
timeLeft={timeLeft}
444424
recaptchaContainerRef={recaptchaContainerRef}
445-
tosUrl={tosUrl}
446-
privacyPolicyUrl={privacyPolicyUrl}
447425
/>
448426
) : (
449427
<PhoneNumberForm
450428
onSubmit={handlePhoneSubmit}
451429
formError={formError}
452430
recaptchaVerifier={recaptchaVerifier}
453431
recaptchaContainerRef={recaptchaContainerRef}
454-
showTerms
455-
tosUrl={tosUrl}
456-
privacyPolicyUrl={privacyPolicyUrl}
457432
/>
458433
)}
459434
</div>

packages/firebaseui-react/src/auth/forms/register-form.tsx

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,13 @@ import { useMemo, useState } from "react";
1212
import { useUI } from "~/hooks";
1313
import { Button } from "../../components/button";
1414
import { FieldInfo } from "../../components/field-info";
15-
import {
16-
TermsAndPrivacy,
17-
TermsAndPrivacyProps,
18-
} from "../../components/terms-and-privacy";
15+
import { Policies } from "../../components/policies";
1916

20-
interface RegisterFormProps extends TermsAndPrivacyProps {
17+
interface RegisterFormProps {
2118
onBackToSignInClick?: () => void;
2219
}
2320

24-
export function RegisterForm({
25-
onBackToSignInClick,
26-
tosUrl,
27-
privacyPolicyUrl,
28-
}: RegisterFormProps) {
21+
export function RegisterForm({ onBackToSignInClick }: RegisterFormProps) {
2922
const ui = useUI();
3023

3124
const [formError, setFormError] = useState<string | null>(null);
@@ -139,7 +132,7 @@ export function RegisterForm({
139132
/>
140133
</fieldset>
141134

142-
<TermsAndPrivacy tosUrl={tosUrl} privacyPolicyUrl={privacyPolicyUrl} />
135+
<Policies />
143136

144137
<fieldset>
145138
<Button type="submit" disabled={ui.state !== "idle"}>

packages/firebaseui-react/src/auth/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export {
1717
type SignUpAuthScreenProps,
1818
} from "./screens/sign-up-auth-screen";
1919

20-
export { OAuthScreen, type OAuthAuthScreenProps } from "./screens/oauth-screen";
20+
export { OAuthScreen, type OAuthScreenProps } from "./screens/oauth-screen";
2121

2222
export {
2323
PasswordResetScreen,

packages/firebaseui-react/src/auth/screens/email-link-auth-screen.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import type { PropsWithChildren } from "react";
12
import { getTranslation } from "@firebase-ui/core";
23
import { Divider } from "~/components/divider";
34
import { useUI } from "~/hooks";
@@ -9,9 +10,7 @@ import {
910
} from "../../components/card";
1011
import { EmailLinkForm } from "../forms/email-link-form";
1112

12-
export interface EmailLinkAuthScreenProps {
13-
children?: React.ReactNode | React.ReactNode[];
14-
}
13+
export type EmailLinkAuthScreenProps = PropsWithChildren;
1514

1615
export function EmailLinkAuthScreen({ children }: EmailLinkAuthScreenProps) {
1716
const ui = useUI();

packages/firebaseui-react/src/auth/screens/oauth-screen.tsx

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,12 @@ import {
66
CardSubtitle,
77
CardTitle,
88
} from "../../components/card";
9-
import {
10-
TermsAndPrivacy,
11-
TermsAndPrivacyProps,
12-
} from "../../components/terms-and-privacy";
9+
import { PropsWithChildren } from "react";
10+
import { Policies } from "~/components/policies";
1311

14-
export interface OAuthAuthScreenProps extends TermsAndPrivacyProps {
15-
children: React.ReactNode | React.ReactNode[];
16-
}
12+
export type OAuthScreenProps = PropsWithChildren;
1713

18-
export function OAuthScreen({
19-
children,
20-
tosUrl,
21-
privacyPolicyUrl,
22-
}: OAuthAuthScreenProps) {
14+
export function OAuthScreen({ children }: OAuthScreenProps) {
2315
const ui = useUI();
2416

2517
// TODO: Translations for oauth providers
@@ -34,7 +26,7 @@ export function OAuthScreen({
3426
<CardSubtitle>{subtitleText}</CardSubtitle>
3527
</CardHeader>
3628
{children}
37-
<TermsAndPrivacy tosUrl={tosUrl} privacyPolicyUrl={privacyPolicyUrl} />
29+
<Policies />
3830
</Card>
3931
</div>
4032
);

packages/firebaseui-react/src/auth/screens/password-reset-screen.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ import {
88
} from "../../components/card";
99
import { ForgotPasswordForm } from "../forms/forgot-password-form";
1010

11-
export interface PasswordResetScreenProps {
11+
export type PasswordResetScreenProps = {
1212
onBackToSignInClick?: () => void;
13-
}
13+
};
1414

1515
export function PasswordResetScreen({
1616
onBackToSignInClick,

0 commit comments

Comments
 (0)