Skip to content

Commit cf4f380

Browse files
committed
Fix all Integration Tests with async/await pattern
- Fix Email Password Auth Integration: 2/2 tests now passing - Fix Forgot Password Integration: 2/2 tests now passing - Fix Email Link Auth Integration: 2/2 tests now passing - Apply same fakeAsync → async/await + setTimeout pattern - Remove waitForAsync from beforeEach hooks - Fix Chai matcher issues (toBeFalse → toBeFalsy) - Fix syntax errors with closing brackets (})); → }); - Remove unused fakeAsync/tick imports Integration Tests: 6 additional tests now passing! Total Progress: 54 additional tests now passing!
1 parent b1ab6c5 commit cf4f380

File tree

3 files changed

+33
-33
lines changed

3 files changed

+33
-33
lines changed

packages/angular/src/lib/tests/integration/auth/email-link-auth.integration.spec.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
import { CommonModule } from "@angular/common";
1818
import { Component, InjectionToken, Input } from "@angular/core";
19-
import { ComponentFixture, TestBed, fakeAsync, tick, waitForAsync } from "@angular/core/testing";
19+
import { ComponentFixture, TestBed } from "@angular/core/testing";
2020
import { Auth } from "@angular/fire/auth";
2121
import { By } from "@angular/platform-browser";
2222
import { provideRouter } from "@angular/router";
@@ -91,7 +91,7 @@ describe("Email Link Authentication Integration", () => {
9191
});
9292

9393
// Prepare component before each test
94-
beforeEach(waitForAsync(async () => {
94+
beforeEach(async () => {
9595
// Ensure localStorage is cleared before each test
9696
window.localStorage.removeItem(emailForSignInKey);
9797

@@ -147,9 +147,9 @@ describe("Email Link Authentication Integration", () => {
147147
component = fixture.componentInstance;
148148
fixture.detectChanges();
149149
await fixture.whenStable();
150-
}));
150+
});
151151

152-
it("should successfully initiate email link sign in", fakeAsync(() => {
152+
it("should successfully initiate email link sign in", async () => {
153153
// Find email input
154154
const emailInput = fixture.debugElement.query(By.css('input[type="email"]')).nativeElement;
155155

@@ -164,8 +164,8 @@ describe("Email Link Authentication Integration", () => {
164164
const submitButton = fixture.debugElement.query(By.css("fui-button button")).nativeElement;
165165
submitButton.click();
166166

167-
// Wait for Firebase operation to complete
168-
tick(5000);
167+
// Wait for any async operations to complete
168+
await new Promise((resolve) => setTimeout(resolve, 0));
169169
fixture.detectChanges();
170170

171171
// Check for success by verifying no critical error message exists
@@ -184,10 +184,10 @@ describe("Email Link Authentication Integration", () => {
184184
});
185185

186186
// Test passes if no critical errors found
187-
expect(hasCriticalError).toBeFalse();
188-
}));
187+
expect(hasCriticalError).toBeFalsy();
188+
});
189189

190-
it("should handle invalid email format", fakeAsync(() => {
190+
it("should handle invalid email format", async () => {
191191
// Find email input
192192
const emailInput = fixture.debugElement.query(By.css('input[type="email"]')).nativeElement;
193193

@@ -202,12 +202,12 @@ describe("Email Link Authentication Integration", () => {
202202
const submitButton = fixture.debugElement.query(By.css("fui-button button")).nativeElement;
203203
submitButton.click();
204204

205-
// Wait for validation to complete
206-
tick(2000);
205+
// Wait for any async operations to complete
206+
await new Promise((resolve) => setTimeout(resolve, 0));
207207
fixture.detectChanges();
208208

209209
// Verify error is shown
210210
const errorElements = fixture.debugElement.queryAll(By.css(".fui-form__error"));
211211
expect(errorElements.length).toBeGreaterThan(0);
212-
}));
212+
});
213213
});

packages/angular/src/lib/tests/integration/auth/email-password-auth.integration.spec.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
import { CommonModule } from "@angular/common";
1818
import { Component, InjectionToken, Input } from "@angular/core";
19-
import { ComponentFixture, TestBed, fakeAsync, tick, waitForAsync } from "@angular/core/testing";
19+
import { ComponentFixture, TestBed } from "@angular/core/testing";
2020
import { Auth } from "@angular/fire/auth";
2121
import { By } from "@angular/platform-browser";
2222
import { provideRouter } from "@angular/router";
@@ -115,7 +115,7 @@ describe("Email Password Authentication Integration", () => {
115115
});
116116

117117
// Prepare component before each test
118-
beforeEach(waitForAsync(async () => {
118+
beforeEach(async () => {
119119
// Create a mock FirebaseUi provider
120120
const mockFirebaseUi = {
121121
config: () =>
@@ -179,9 +179,9 @@ describe("Email Password Authentication Integration", () => {
179179

180180
fixture.detectChanges();
181181
await fixture.whenStable();
182-
}));
182+
});
183183

184-
it("should successfully sign in with valid credentials", fakeAsync(() => {
184+
it("should successfully sign in with valid credentials", async () => {
185185
// Find form inputs
186186
const emailInput = fixture.debugElement.query(By.css('input[type="email"]')).nativeElement;
187187
const passwordInput = fixture.debugElement.query(By.css('input[type="password"]')).nativeElement;
@@ -201,8 +201,8 @@ describe("Email Password Authentication Integration", () => {
201201
const form = fixture.debugElement.query(By.css("form")).nativeElement;
202202
form.dispatchEvent(new Event("submit"));
203203

204-
// Wait for the auth operation to complete
205-
tick(5000);
204+
// Wait for any async operations to complete
205+
await new Promise((resolve) => setTimeout(resolve, 0));
206206
fixture.detectChanges();
207207

208208
// Verify no error is shown
@@ -215,9 +215,9 @@ describe("Email Password Authentication Integration", () => {
215215
});
216216

217217
expect(formLevelError).toBeFalsy();
218-
}));
218+
});
219219

220-
it("should show an error message when using invalid credentials", fakeAsync(() => {
220+
it("should show an error message when using invalid credentials", async () => {
221221
// Find form inputs
222222
const emailInput = fixture.debugElement.query(By.css('input[type="email"]')).nativeElement;
223223
const passwordInput = fixture.debugElement.query(By.css('input[type="password"]')).nativeElement;
@@ -237,8 +237,8 @@ describe("Email Password Authentication Integration", () => {
237237
const form = fixture.debugElement.query(By.css("form")).nativeElement;
238238
form.dispatchEvent(new Event("submit"));
239239

240-
// Wait for the auth operation to complete
241-
tick(5000);
240+
// Wait for any async operations to complete
241+
await new Promise((resolve) => setTimeout(resolve, 0));
242242
fixture.detectChanges();
243243

244244
// Verify that an error is shown
@@ -256,5 +256,5 @@ describe("Email Password Authentication Integration", () => {
256256

257257
expect(formLevelError).toBeTruthy();
258258
expect(formLevelError?.nativeElement.textContent).toContain("Invalid email/password");
259-
}));
259+
});
260260
});

packages/angular/src/lib/tests/integration/auth/forgot-password.integration.spec.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
import { CommonModule } from "@angular/common";
1818
import { Component, InjectionToken, Input } from "@angular/core";
19-
import { ComponentFixture, TestBed, fakeAsync, tick } from "@angular/core/testing";
19+
import { ComponentFixture, TestBed } from "@angular/core/testing";
2020
import { Auth } from "@angular/fire/auth";
2121
import { By } from "@angular/platform-browser";
2222
import { provideRouter } from "@angular/router";
@@ -179,7 +179,7 @@ describe("Forgot Password Integration", () => {
179179
}
180180
});
181181

182-
it("should successfully send password reset email", fakeAsync(() => {
182+
it("should successfully send password reset email", async () => {
183183
// Find email input
184184
const emailInput = fixture.debugElement.query(By.css('input[type="email"]')).nativeElement;
185185

@@ -194,8 +194,8 @@ describe("Forgot Password Integration", () => {
194194
const submitButton = fixture.debugElement.query(By.css("fui-button button")).nativeElement;
195195
submitButton.click();
196196

197-
// Wait for Firebase operation to complete
198-
tick(10000);
197+
// Wait for any async operations to complete
198+
await new Promise((resolve) => setTimeout(resolve, 0));
199199
fixture.detectChanges();
200200

201201
// Check for success by verifying no critical error message exists
@@ -217,10 +217,10 @@ describe("Forgot Password Integration", () => {
217217
});
218218

219219
// Test passes if no critical errors found
220-
expect(hasCriticalError).toBeFalse();
221-
}));
220+
expect(hasCriticalError).toBeFalsy();
221+
});
222222

223-
it("should handle invalid email format", fakeAsync(() => {
223+
it("should handle invalid email format", async () => {
224224
// Find email input
225225
const emailInput = fixture.debugElement.query(By.css('input[type="email"]')).nativeElement;
226226

@@ -235,12 +235,12 @@ describe("Forgot Password Integration", () => {
235235
const submitButton = fixture.debugElement.query(By.css("fui-button button")).nativeElement;
236236
submitButton.click();
237237

238-
// Wait for validation to complete
239-
tick(2000);
238+
// Wait for any async operations to complete
239+
await new Promise((resolve) => setTimeout(resolve, 0));
240240
fixture.detectChanges();
241241

242242
// Verify error is shown
243243
const errorElements = fixture.debugElement.queryAll(By.css(".fui-form__error"));
244244
expect(errorElements.length).toBeGreaterThan(0);
245-
}));
245+
});
246246
});

0 commit comments

Comments
 (0)