Skip to content

Commit c9a1f55

Browse files
format
1 parent 7440d4e commit c9a1f55

File tree

2 files changed

+16
-13
lines changed

2 files changed

+16
-13
lines changed

e2eTest/FirebaseSwiftUIExample/FirebaseSwiftUIExampleUITests/MFAEnrolmentUITests.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,21 +23,21 @@ import XCTest
2323

2424
final class MFAEnrollmentUITests: XCTestCase {
2525
var app: XCUIApplication!
26-
26+
2727
override func setUpWithError() throws {
2828
continueAfterFailure = false
2929
}
30-
30+
3131
override func tearDownWithError() throws {
3232
// Clean up: Terminate app
3333
if let app = app {
3434
app.terminate()
3535
}
3636
app = nil
37-
37+
3838
// Small delay between tests to allow emulator to settle
3939
Thread.sleep(forTimeInterval: 0.5)
40-
40+
4141
try super.tearDownWithError()
4242
}
4343

@@ -226,7 +226,7 @@ final class MFAEnrollmentUITests: XCTestCase {
226226
let phoneField = app.textFields["phone-number-field"]
227227
XCTAssertTrue(phoneField.waitForExistence(timeout: 10))
228228
// Generate unique phone number using timestamp to avoid conflicts between tests
229-
let uniqueId = Int(Date().timeIntervalSince1970 * 1000) % 1000000
229+
let uniqueId = Int(Date().timeIntervalSince1970 * 1000) % 1_000_000
230230
let phoneNumberWithoutDialCode = "7\(String(format: "%09d", uniqueId))"
231231
UIPasteboard.general.string = phoneNumberWithoutDialCode
232232
phoneField.tap()
@@ -258,9 +258,9 @@ final class MFAEnrollmentUITests: XCTestCase {
258258

259259
// Paste each digit into the corresponding text field
260260
let codeDigits = Array(code)
261-
let fields = [verificationCodeField1, verificationCodeField2, verificationCodeField3,
261+
let fields = [verificationCodeField1, verificationCodeField2, verificationCodeField3,
262262
verificationCodeField4, verificationCodeField5, verificationCodeField6]
263-
263+
264264
for (index, digit) in codeDigits.enumerated() where index < fields.count {
265265
let field = fields[index]
266266
UIPasteboard.general.string = String(digit)

e2eTest/FirebaseSwiftUIExample/FirebaseSwiftUIExampleUITests/TestUtils.swift

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,9 @@ func createEmail() -> String {
139139
guard let http = sendResp as? HTTPURLResponse, http.statusCode == 200 else {
140140
let errorBody = String(data: sendData, encoding: .utf8) ?? "Unknown error"
141141
throw NSError(domain: "EmulatorError", code: 1,
142-
userInfo: [NSLocalizedDescriptionKey: "Failed to send verification email: \(errorBody)"])
142+
userInfo: [
143+
NSLocalizedDescriptionKey: "Failed to send verification email: \(errorBody)",
144+
])
143145
}
144146

145147
// Add a small delay to ensure the OOB code is registered in the emulator
@@ -156,12 +158,12 @@ func createEmail() -> String {
156158

157159
// Step 2: Fetch OOB codes from emulator with retry logic
158160
let oobURL = URL(string: "\(base)/emulator/v1/projects/\(projectID)/oobCodes")!
159-
161+
160162
var codeItem: OobItem?
161163
var attempts = 0
162164
let maxAttempts = 5
163-
164-
while codeItem == nil && attempts < maxAttempts {
165+
166+
while codeItem == nil, attempts < maxAttempts {
165167
let (oobData, oobResp) = try await URLSession.shared.data(from: oobURL)
166168
guard (oobResp as? HTTPURLResponse)?.statusCode == 200 else {
167169
throw NSError(domain: "EmulatorError", code: 2,
@@ -182,15 +184,16 @@ func createEmail() -> String {
182184
return d0 > d1
183185
}
184186
.first
185-
187+
186188
if codeItem == nil {
187189
attempts += 1
188190
if attempts < maxAttempts {
189191
// Wait before retrying
190192
try await Task.sleep(nanoseconds: 500_000_000) // 0.5 seconds
191193
} else {
192194
// Log available codes for debugging
193-
let availableCodes = envelope.oobCodes.map { "Email: \($0.email), Type: \($0.requestType)" }.joined(separator: "; ")
195+
let availableCodes = envelope.oobCodes.map { "Email: \($0.email), Type: \($0.requestType)" }
196+
.joined(separator: "; ")
194197
throw NSError(domain: "EmulatorError", code: 3,
195198
userInfo: [
196199
NSLocalizedDescriptionKey: "No VERIFY_EMAIL OOB code found for \(email) after \(maxAttempts) attempts. Available codes: \(availableCodes)",

0 commit comments

Comments
 (0)