Skip to content

Commit b45344a

Browse files
committed
chore: Update angular to latest config
1 parent 469cf12 commit b45344a

32 files changed

+145
-209
lines changed

packages/angular/projects/firebaseui-angular/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
"peerDependencies": {
55
"@angular/common": "^19.1.0",
66
"@angular/core": "^19.1.0",
7-
"@firebase-ui/core": "workspace:*"
7+
"@firebase-ui/core": "workspace:*",
8+
"@firebase-ui/translations": "workspace:*"
89
},
910
"dependencies": {
1011
"@tanstack/angular-form": "^1.1.0",

packages/angular/projects/firebaseui-angular/src/lib/auth/forms/email-link-form/email-link-form.component.ts

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
import { Component, inject, Input, OnInit } from '@angular/core';
22
import { CommonModule } from '@angular/common';
33
import { injectForm, TanStackField } from '@tanstack/angular-form';
4-
import { FirebaseUi } from '../../../provider';
5-
import { Auth } from '@angular/fire/auth';
6-
import { Router } from '@angular/router';
4+
import { FirebaseUI } from '../../../provider';
75
import { ButtonComponent } from '../../../components/button/button.component';
86
import { TermsAndPrivacyComponent } from '../../../components/terms-and-privacy/terms-and-privacy.component';
97
import {
108
createEmailLinkFormSchema,
119
FirebaseUIError,
12-
fuiCompleteEmailLinkSignIn,
13-
fuiSendSignInLinkToEmail,
10+
completeEmailLinkSignIn,
11+
sendSignInLinkToEmail,
1412
} from '@firebase-ui/core';
1513
import { firstValueFrom } from 'rxjs';
1614

@@ -65,8 +63,7 @@ import { firstValueFrom } from 'rxjs';
6563
`,
6664
})
6765
export class EmailLinkFormComponent implements OnInit {
68-
private ui = inject(FirebaseUi);
69-
private auth = inject(Auth);
66+
private ui = inject(FirebaseUI);
7067

7168
formError: string | null = null;
7269
emailSent = false;
@@ -102,13 +99,7 @@ export class EmailLinkFormComponent implements OnInit {
10299

103100
private async completeSignIn() {
104101
try {
105-
await fuiCompleteEmailLinkSignIn(this.auth, window.location.href, {
106-
translations: this.config?.translations,
107-
language: this.config?.language,
108-
enableAutoUpgradeAnonymous: this.config?.enableAutoUpgradeAnonymous,
109-
enableHandleExistingCredential:
110-
this.config?.enableHandleExistingCredential,
111-
});
102+
await completeEmailLinkSignIn(await firstValueFrom(this.ui.config()), window.location.href);
112103
} catch (error) {
113104
if (error instanceof FirebaseUIError) {
114105
this.formError = error.message;
@@ -151,11 +142,7 @@ export class EmailLinkFormComponent implements OnInit {
151142
return;
152143
}
153144

154-
await fuiSendSignInLinkToEmail(this.auth, email, {
155-
translations: this.config?.translations,
156-
language: this.config?.language,
157-
enableAutoUpgradeAnonymous: this.config?.enableAutoUpgradeAnonymous,
158-
});
145+
await sendSignInLinkToEmail(await firstValueFrom(this.ui.config()), email);
159146

160147
this.emailSent = true;
161148
} catch (error) {

packages/angular/projects/firebaseui-angular/src/lib/auth/forms/email-password-form/email-password-form.component.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import { EmailPasswordFormComponent } from './email-password-form.component';
1515
// Define window properties for testing
1616
declare global {
1717
interface Window {
18-
fuiSignInWithEmailAndPassword: any;
18+
signInWithEmailAndPassword: any;
1919
createEmailFormSchema: any;
2020
}
2121
}
@@ -90,11 +90,11 @@ describe('EmailPasswordFormComponent', () => {
9090

9191
// Create spies for the global functions
9292
signInSpy = jasmine
93-
.createSpy('fuiSignInWithEmailAndPassword')
93+
.createSpy('signInWithEmailAndPassword')
9494
.and.returnValue(Promise.resolve());
9595

9696
// Define the function on the window object
97-
Object.defineProperty(window, 'fuiSignInWithEmailAndPassword', {
97+
Object.defineProperty(window, 'signInWithEmailAndPassword', {
9898
value: signInSpy,
9999
writable: true,
100100
configurable: true,

packages/angular/projects/firebaseui-angular/src/lib/auth/forms/email-password-form/email-password-form.component.ts

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
import { Component, inject, Input, OnInit } from '@angular/core';
22
import { CommonModule } from '@angular/common';
33
import { injectForm, TanStackField } from '@tanstack/angular-form';
4-
import { FirebaseUi } from '../../../provider';
5-
import { Auth } from '@angular/fire/auth';
4+
import { FirebaseUI } from '../../../provider';
65
import { ButtonComponent } from '../../../components/button/button.component';
76
import { TermsAndPrivacyComponent } from '../../../components/terms-and-privacy/terms-and-privacy.component';
87
import {
98
createEmailFormSchema,
109
EmailFormSchema,
1110
FirebaseUIError,
12-
fuiSignInWithEmailAndPassword,
11+
signInWithEmailAndPassword,
1312
} from '@firebase-ui/core';
1413
import { firstValueFrom } from 'rxjs';
1514
import { Router } from '@angular/router';
@@ -105,8 +104,7 @@ import { Router } from '@angular/router';
105104
`,
106105
})
107106
export class EmailPasswordFormComponent implements OnInit {
108-
private ui = inject(FirebaseUi);
109-
private auth = inject(Auth);
107+
private ui = inject(FirebaseUI);
110108
private router = inject(Router);
111109

112110
@Input({ required: true }) forgotPasswordRoute!: string;
@@ -186,13 +184,7 @@ export class EmailPasswordFormComponent implements OnInit {
186184
}
187185

188186
this.formError = null;
189-
await fuiSignInWithEmailAndPassword(this.auth, email, password, {
190-
translations: this.config?.translations,
191-
language: this.config?.language,
192-
enableAutoUpgradeAnonymous: this.config?.enableAutoUpgradeAnonymous,
193-
enableHandleExistingCredential:
194-
this.config?.enableHandleExistingCredential,
195-
});
187+
await signInWithEmailAndPassword(await firstValueFrom(this.ui.config()), email, password);
196188
} catch (error) {
197189
if (error instanceof FirebaseUIError) {
198190
this.formError = error.message;

packages/angular/projects/firebaseui-angular/src/lib/auth/forms/forgot-password-form/forgot-password-form.component.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import { ForgotPasswordFormComponent } from './forgot-password-form.component';
1515
// Define window properties for testing
1616
declare global {
1717
interface Window {
18-
fuiSendPasswordResetEmail: any;
18+
sendPasswordResetEmail: any;
1919
createForgotPasswordFormSchema: any;
2020
}
2121
}
@@ -78,11 +78,11 @@ describe('ForgotPasswordFormComponent', () => {
7878

7979
// Create spies for the global functions
8080
sendResetEmailSpy = jasmine
81-
.createSpy('fuiSendPasswordResetEmail')
81+
.createSpy('sendPasswordResetEmail')
8282
.and.returnValue(Promise.resolve());
8383

8484
// Define the function on the window object
85-
Object.defineProperty(window, 'fuiSendPasswordResetEmail', {
85+
Object.defineProperty(window, 'sendPasswordResetEmail', {
8686
value: sendResetEmailSpy,
8787
writable: true,
8888
configurable: true,

packages/angular/projects/firebaseui-angular/src/lib/auth/forms/forgot-password-form/forgot-password-form.component.ts

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
import { Component, inject, Input, OnInit } from '@angular/core';
22
import { CommonModule } from '@angular/common';
33
import { injectForm, TanStackField } from '@tanstack/angular-form';
4-
import { FirebaseUi } from '../../../provider';
4+
import { FirebaseUI } from '../../../provider';
55
import { Auth } from '@angular/fire/auth';
66
import { ButtonComponent } from '../../../components/button/button.component';
77
import { TermsAndPrivacyComponent } from '../../../components/terms-and-privacy/terms-and-privacy.component';
88
import {
99
createForgotPasswordFormSchema,
1010
FirebaseUIError,
11-
ForgotPasswordFormSchema,
12-
fuiSendPasswordResetEmail,
11+
sendPasswordResetEmail,
1312
} from '@firebase-ui/core';
1413
import { firstValueFrom } from 'rxjs';
1514
import { Router } from '@angular/router';
@@ -75,8 +74,7 @@ import { Router } from '@angular/router';
7574
`,
7675
})
7776
export class ForgotPasswordFormComponent implements OnInit {
78-
private ui = inject(FirebaseUi);
79-
private auth = inject(Auth);
77+
private ui = inject(FirebaseUI);
8078
private router = inject(Router);
8179

8280
@Input({ required: true }) signInRoute!: string;
@@ -149,10 +147,7 @@ export class ForgotPasswordFormComponent implements OnInit {
149147
}
150148

151149
// Send password reset email
152-
await fuiSendPasswordResetEmail(this.auth, email, {
153-
translations: this.config?.translations,
154-
language: this.config?.language,
155-
});
150+
await sendPasswordResetEmail(await firstValueFrom(this.ui.config()), email);
156151

157152
this.emailSent = true;
158153
} catch (error) {

packages/angular/projects/firebaseui-angular/src/lib/auth/forms/phone-form/phone-form.component.spec.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ import {
1313
} from '@angular/fire/auth';
1414
import { FirebaseUIError } from '@firebase-ui/core';
1515
import { TanStackField } from '@tanstack/angular-form';
16-
import { of } from 'rxjs';
17-
import { FirebaseUi } from '../../../provider';
16+
import { firstValueFrom, of } from 'rxjs';
17+
import { FirebaseUI } from '../../../provider';
1818
import {
1919
PhoneFormComponent,
2020
PhoneNumberFormComponent,
@@ -23,7 +23,7 @@ import {
2323

2424
// Mock Firebase UI Core functions
2525
const mockFuiSignInWithPhoneNumber = jasmine
26-
.createSpy('fuiSignInWithPhoneNumber')
26+
.createSpy('signInWithPhoneNumber')
2727
.and.returnValue(
2828
Promise.resolve({
2929
confirm: jasmine.createSpy('confirm').and.returnValue(Promise.resolve()),
@@ -132,8 +132,8 @@ class TestPhoneFormComponent extends PhoneFormComponent {
132132
}
133133

134134
// Make protected methods directly accessible for testing
135-
testGetAuth() {
136-
return this['auth']; // Access private property with indexing
135+
async testGetAuth() {
136+
return (await firstValueFrom(this['ui'].config())).getAuth();
137137
}
138138

139139
testGetUi() {
@@ -157,7 +157,7 @@ class TestPhoneFormComponent extends PhoneFormComponent {
157157
this.phoneNumber = phoneNumber;
158158
// Call our mock function directly
159159
const result = await mockFuiSignInWithPhoneNumber(
160-
this.testGetAuth(),
160+
await this.testGetAuth(),
161161
phoneNumber,
162162
this.recaptchaVerifier,
163163
{
@@ -382,7 +382,7 @@ describe('PhoneFormComponent', () => {
382382
MockCountrySelectorComponent,
383383
],
384384
providers: [
385-
{ provide: FirebaseUi, useValue: mockFirebaseUi },
385+
{ provide: FirebaseUI, useValue: mockFirebaseUi },
386386
{ provide: Auth, useValue: mockAuthService },
387387
],
388388
}).compileComponents();
@@ -423,7 +423,7 @@ describe('PhoneFormComponent', () => {
423423
expect(component.confirmationResult).toBeNull();
424424
});
425425

426-
it('should call fuiSignInWithPhoneNumber when handling phone submission', fakeAsync(() => {
426+
it('should call signInWithPhoneNumber when handling phone submission', fakeAsync(() => {
427427
component.handlePhoneSubmit('1234567890');
428428
tick();
429429

@@ -459,7 +459,7 @@ describe('PhoneFormComponent', () => {
459459
expect(mockFuiConfirmPhoneNumber).toHaveBeenCalled();
460460
}));
461461

462-
it('should call fuiSignInWithPhoneNumber when handling resend code', fakeAsync(() => {
462+
it('should call signInWithPhoneNumber when handling resend code', fakeAsync(() => {
463463
component.confirmationResult = {} as ConfirmationResult;
464464
component.canResend = true;
465465
component.phoneNumber = '1234567890';

0 commit comments

Comments
 (0)