Skip to content

Commit 70240d7

Browse files
test: different provider appear in default Views
1 parent e51b9eb commit 70240d7

File tree

3 files changed

+109
-25
lines changed

3 files changed

+109
-25
lines changed

e2eTest/FirebaseSwiftUIExample/FirebaseSwiftUIExample.xcodeproj/xcshareddata/xcschemes/FirebaseSwiftUIExample.xcscheme

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,19 +28,14 @@
2828
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
2929
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
3030
shouldUseLaunchSchemeArgsEnv = "YES"
31-
shouldAutocreateTestPlan = "YES"
32-
codeCoverageEnabled = "NO"
33-
onlyGenerateCoverageForSpecifiedTargets = "NO">
34-
<TestPlans>
35-
</TestPlans>
31+
shouldAutocreateTestPlan = "YES">
3632
<Testables>
3733
<TestableReference
3834
skipped = "NO"
39-
parallelizable = "NO"
4035
testExecutionOrdering = "random">
4136
<BuildableReference
4237
BuildableIdentifier = "primary"
43-
BlueprintIdentifier = "46F89C412D64A86D000F8BC0"
38+
BlueprintIdentifier = "46F89C232D64A86D000F8BC0"
4439
BuildableName = "FirebaseSwiftUIExampleUITests.xctest"
4540
BlueprintName = "FirebaseSwiftUIExampleUITests"
4641
ReferencedContainer = "container:FirebaseSwiftUIExample.xcodeproj">

e2eTest/FirebaseSwiftUIExample/FirebaseSwiftUIExample/TestView.swift

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -56,18 +56,26 @@ struct TestView: View {
5656
mfaEnabled: isMfaEnabled
5757
)
5858

59-
authService = AuthService(
60-
configuration: configuration
61-
)
62-
.withGoogleSignIn()
63-
.withPhoneSignIn()
64-
.withAppleSignIn()
65-
.withTwitterSignIn()
66-
.withOAuthSignIn(OAuthProviderSwift.github())
67-
.withOAuthSignIn(OAuthProviderSwift.microsoft())
68-
.withOAuthSignIn(OAuthProviderSwift.yahoo())
69-
.withFacebookSignIn()
70-
.withEmailSignIn()
59+
let args = ProcessInfo.processInfo.arguments
60+
61+
// Configure providers based on launch arguments
62+
if args.contains("--no-providers") {
63+
// No providers enabled - just base AuthService
64+
authService = AuthService(configuration: configuration)
65+
} else {
66+
// Enable all providers
67+
authService = AuthService(configuration: configuration)
68+
.withGoogleSignIn()
69+
.withPhoneSignIn()
70+
.withAppleSignIn()
71+
.withTwitterSignIn()
72+
.withOAuthSignIn(OAuthProviderSwift.github())
73+
.withOAuthSignIn(OAuthProviderSwift.microsoft())
74+
.withOAuthSignIn(OAuthProviderSwift.yahoo())
75+
.withFacebookSignIn()
76+
.withEmailSignIn()
77+
.withEmailLinkSignIn()
78+
}
7179
authService.isPresented = true
7280
}
7381

e2eTest/FirebaseSwiftUIExample/FirebaseSwiftUIExampleUITests/FirebaseSwiftUIExampleUITests.swift

Lines changed: 87 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,99 @@ final class FirebaseSwiftUIExampleUITests: XCTestCase {
2929
override func tearDownWithError() throws {}
3030

3131
@MainActor
32-
func testExample() throws {
32+
func testNoProvidersInitialized() throws {
3333
let app = XCUIApplication()
34+
app.launchArguments.append("--test-view-enabled")
35+
app.launchArguments.append("--no-providers")
3436
app.launch()
37+
38+
// Verify email/password fields are NOT visible when no providers are initialized
39+
let emailField = app.textFields["email-field"]
40+
XCTAssertFalse(
41+
emailField.waitForExistence(timeout: 2),
42+
"Email field should NOT be visible when no providers are initialized"
43+
)
44+
45+
// Verify email link button is NOT visible
46+
let emailLinkButton = app.buttons["sign-in-with-email-link-button"]
47+
XCTAssertFalse(
48+
emailLinkButton.waitForExistence(timeout: 2),
49+
"Email link button should NOT be visible when no providers are initialized"
50+
)
51+
52+
// Verify provider buttons are NOT visible
53+
let googleButton = app.buttons["sign-in-with-google-button"]
54+
XCTAssertFalse(
55+
googleButton.waitForExistence(timeout: 2),
56+
"Google button should NOT be visible when no providers are initialized"
57+
)
58+
59+
let facebookButton = app.buttons["sign-in-with-facebook-button"]
60+
XCTAssertFalse(
61+
facebookButton.waitForExistence(timeout: 2),
62+
"Facebook button should NOT be visible when no providers are initialized"
63+
)
3564
}
3665

3766
@MainActor
38-
func testLaunchPerformance() throws {
39-
if #available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 7.0, *) {
40-
measure(metrics: [XCTApplicationLaunchMetric()]) {
41-
XCUIApplication().launch()
42-
}
67+
func testAllProvidersInitialized() throws {
68+
let app = XCUIApplication()
69+
app.launchArguments.append("--test-view-enabled")
70+
// No --no-providers flag means all providers are enabled by default
71+
app.launch()
72+
73+
// Verify email/password fields are visible when withEmailSignIn() is enabled
74+
let emailField = app.textFields["email-field"]
75+
XCTAssertTrue(
76+
emailField.waitForExistence(timeout: 5),
77+
"Email field should be visible when withEmailSignIn() is enabled"
78+
)
79+
80+
let passwordField = app.secureTextFields["password-field"]
81+
XCTAssertTrue(
82+
passwordField.waitForExistence(timeout: 5),
83+
"Password field should be visible when withEmailSignIn() is enabled"
84+
)
85+
86+
let signInButton = app.buttons["sign-in-button"]
87+
XCTAssertTrue(
88+
signInButton.waitForExistence(timeout: 5),
89+
"Sign-in button should be visible when withEmailSignIn() is enabled"
90+
)
91+
92+
// Verify email link button is visible when withEmailLinkSignIn() is enabled
93+
let emailLinkButton = app.buttons["sign-in-with-email-link-button"]
94+
XCTAssertTrue(
95+
emailLinkButton.waitForExistence(timeout: 5),
96+
"Email link button should be visible when withEmailLinkSignIn() is enabled"
97+
)
98+
99+
// Tap the email link button and verify it navigates to email link view
100+
emailLinkButton.tap()
101+
let emailLinkText = app.staticTexts["Send a sign-in link to your email"].firstMatch
102+
XCTAssertTrue(
103+
emailLinkText.waitForExistence(timeout: 5),
104+
"Email link view should appear after tapping email link button"
105+
)
106+
107+
// Go back to verify provider buttons
108+
let backButton = app.navigationBars.buttons.element(boundBy: 0)
109+
if backButton.exists {
110+
backButton.tap()
43111
}
112+
113+
// Verify provider buttons are visible
114+
let googleButton = app.buttons["sign-in-with-google-button"]
115+
XCTAssertTrue(
116+
googleButton.waitForExistence(timeout: 5),
117+
"Google sign-in button should be visible when withGoogleSignIn() is enabled"
118+
)
119+
120+
let facebookButton = app.buttons["sign-in-with-facebook-button"]
121+
XCTAssertTrue(
122+
facebookButton.waitForExistence(timeout: 5),
123+
"Facebook sign-in button should be visible when withFacebookSignIn() is enabled"
124+
)
44125
}
45126

46127
@MainActor

0 commit comments

Comments
 (0)