Skip to content

test: SwiftUI integration tests and View tests for create user and sign-in #1257

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 14 commits into
base: main
Choose a base branch
from
Draft
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ import FirebaseAuth
import Foundation

public struct AuthConfiguration {
let shouldHideCancelButton: Bool
let interactiveDismissEnabled: Bool
let shouldAutoUpgradeAnonymousUsers: Bool
let customStringsBundle: Bundle?
let tosUrl: URL?
let privacyPolicyUrl: URL?
let emailLinkSignInActionCodeSettings: ActionCodeSettings?
let verifyEmailActionCodeSettings: ActionCodeSettings?
public let shouldHideCancelButton: Bool
public let interactiveDismissEnabled: Bool
public let shouldAutoUpgradeAnonymousUsers: Bool
public let customStringsBundle: Bundle?
public let tosUrl: URL?
public let privacyPolicyUrl: URL?
public let emailLinkSignInActionCodeSettings: ActionCodeSettings?
public let verifyEmailActionCodeSettings: ActionCodeSettings?

public init(shouldHideCancelButton: Bool = false,
interactiveDismissEnabled: Bool = true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public final class AuthService {
public var phoneAuthProvider: (any PhoneAuthProviderAuthUIProtocol)?

private var listenerManager: AuthListenerManager?
private var signedInCredential: AuthCredential?
public var signedInCredential: AuthCredential?

private var providers: [ExternalAuthProvider] = []
public func register(provider: ExternalAuthProvider) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ extension AuthPickerView: View {
.emailLoginFlowLabel : authService.string.emailSignUpFlowLabel)
.fontWeight(.semibold)
.foregroundColor(.blue)
}
}.accessibilityIdentifier("switch-auth-flow")
}
PrivacyTOCsView(displayMode: .footer)
Text(authService.errorMessage).foregroundColor(.red)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,13 @@ extension EmailAuthView: View {
.padding(.vertical, 6)
.background(Divider(), alignment: .bottom)
.padding(.bottom, 4)
.accessibilityIdentifier("email-field")

LabeledContent {
SecureField(authService.string.passwordInputLabel, text: $password)
.focused($focus, equals: .password)
.textInputAutocapitalization(.never)
.disableAutocorrection(true)
.submitLabel(.go)
.onSubmit {
Task { await signInWithEmailPassword() }
Expand All @@ -79,6 +82,7 @@ extension EmailAuthView: View {
.padding(.vertical, 6)
.background(Divider(), alignment: .bottom)
.padding(.bottom, 8)
.accessibilityIdentifier("password-field")

if authService.authenticationFlow == .login {
Button(action: {
Expand All @@ -92,6 +96,8 @@ extension EmailAuthView: View {
LabeledContent {
SecureField(authService.string.confirmPasswordInputLabel, text: $confirmPassword)
.focused($focus, equals: .confirmPassword)
.textInputAutocapitalization(.never)
.disableAutocorrection(true)
.submitLabel(.go)
.onSubmit {
Task { await createUserWithEmailPassword() }
Expand All @@ -102,6 +108,7 @@ extension EmailAuthView: View {
.padding(.vertical, 6)
.background(Divider(), alignment: .bottom)
.padding(.bottom, 8)
.accessibilityIdentifier("confirm-password-field")
}

Button(action: {
Expand All @@ -126,6 +133,7 @@ extension EmailAuthView: View {
.padding([.top, .bottom], 8)
.frame(maxWidth: .infinity)
.buttonStyle(.borderedProminent)
.accessibilityIdentifier("sign-in-button")
Button(action: {
authService.authView = .emailLink
}) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ extension SignedInView: View {
.font(.largeTitle)
.fontWeight(.bold)
.padding()
.accessibilityIdentifier("signed-in-text")
Text(authService.string.accountSettingsEmailLabel)
Text("\(authService.currentUser?.email ?? "Unknown")")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
objects = {

/* Begin PBXBuildFile section */
4600E5522DD777BE00EED5F3 /* FirebaseAuth in Frameworks */ = {isa = PBXBuildFile; productRef = 4600E5512DD777BE00EED5F3 /* FirebaseAuth */; };
4600E5542DD777BE00EED5F3 /* FirebaseCore in Frameworks */ = {isa = PBXBuildFile; productRef = 4600E5532DD777BE00EED5F3 /* FirebaseCore */; };
4607CC9C2D9BFE29009EC3F5 /* FirebaseAuthSwiftUI in Frameworks */ = {isa = PBXBuildFile; productRef = 4607CC9B2D9BFE29009EC3F5 /* FirebaseAuthSwiftUI */; };
4607CC9E2D9BFE29009EC3F5 /* FirebaseGoogleSwiftUI in Frameworks */ = {isa = PBXBuildFile; productRef = 4607CC9D2D9BFE29009EC3F5 /* FirebaseGoogleSwiftUI */; };
46CB7B252D773F2100F1FD0A /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 46CB7B242D773F2100F1FD0A /* GoogleService-Info.plist */; };
Expand Down Expand Up @@ -96,6 +98,8 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
4600E5542DD777BE00EED5F3 /* FirebaseCore in Frameworks */,
4600E5522DD777BE00EED5F3 /* FirebaseAuth in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -203,6 +207,8 @@
);
name = FirebaseSwiftUIExampleUITests;
packageProductDependencies = (
4600E5512DD777BE00EED5F3 /* FirebaseAuth */,
4600E5532DD777BE00EED5F3 /* FirebaseCore */,
);
productName = FirebaseSwiftUIExampleUITests;
productReference = 46F89C242D64A86D000F8BC0 /* FirebaseSwiftUIExampleUITests.xctest */;
Expand Down Expand Up @@ -242,6 +248,7 @@
minimizedProjectReferenceProxies = 1;
packageReferences = (
8D808CB52DB07EBD00D2293F /* XCLocalSwiftPackageReference "../../../../FirebaseUI-iOS" */,
4600E5502DD777BE00EED5F3 /* XCRemoteSwiftPackageReference "firebase-ios-sdk" */,
);
preferredProjectObjectVersion = 77;
productRefGroup = 46F89C092D64A86C000F8BC0 /* Products */;
Expand Down Expand Up @@ -511,7 +518,7 @@
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = YYX2P3XVJ7;
GENERATE_INFOPLIST_FILE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 18.2;
IPHONEOS_DEPLOYMENT_TARGET = 18.0;
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = io.invertase.testing.FirebaseSwiftUIExampleTests;
PRODUCT_NAME = "$(TARGET_NAME)";
Expand All @@ -530,7 +537,7 @@
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = YYX2P3XVJ7;
GENERATE_INFOPLIST_FILE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 18.2;
IPHONEOS_DEPLOYMENT_TARGET = 18.0;
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = io.invertase.testing.FirebaseSwiftUIExampleTests;
PRODUCT_NAME = "$(TARGET_NAME)";
Expand Down Expand Up @@ -623,7 +630,28 @@
};
/* End XCLocalSwiftPackageReference section */

/* Begin XCRemoteSwiftPackageReference section */
4600E5502DD777BE00EED5F3 /* XCRemoteSwiftPackageReference "firebase-ios-sdk" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/firebase/firebase-ios-sdk";
requirement = {
kind = upToNextMajorVersion;
minimumVersion = 11.12.0;
};
};
/* End XCRemoteSwiftPackageReference section */

/* Begin XCSwiftPackageProductDependency section */
4600E5512DD777BE00EED5F3 /* FirebaseAuth */ = {
isa = XCSwiftPackageProductDependency;
package = 4600E5502DD777BE00EED5F3 /* XCRemoteSwiftPackageReference "firebase-ios-sdk" */;
productName = FirebaseAuth;
};
4600E5532DD777BE00EED5F3 /* FirebaseCore */ = {
isa = XCSwiftPackageProductDependency;
package = 4600E5502DD777BE00EED5F3 /* XCRemoteSwiftPackageReference "firebase-ios-sdk" */;
productName = FirebaseCore;
};
4607CC9B2D9BFE29009EC3F5 /* FirebaseAuthSwiftUI */ = {
isa = XCSwiftPackageProductDependency;
productName = FirebaseAuthSwiftUI;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1620"
version = "1.7">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES"
buildArchitectures = "Automatic">
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
shouldAutocreateTestPlan = "YES">
<Testables>
<TestableReference
skipped = "NO"
parallelizable = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "46F89C192D64A86D000F8BC0"
BuildableName = "FirebaseSwiftUIExampleTests.xctest"
BlueprintName = "FirebaseSwiftUIExampleTests"
ReferencedContainer = "container:FirebaseSwiftUIExample.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1620"
version = "1.7">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES"
buildArchitectures = "Automatic">
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
shouldAutocreateTestPlan = "YES">
<Testables>
<TestableReference
skipped = "NO"
parallelizable = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "46F89C232D64A86D000F8BC0"
BuildableName = "FirebaseSwiftUIExampleUITests.xctest"
BlueprintName = "FirebaseSwiftUIExampleUITests"
ReferencedContainer = "container:FirebaseSwiftUIExample.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"projects": {
"default": "flutterfire-e2e-tests"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
firebase-debug.log*
firebase-debug.*.log*

# Firebase cache
.firebase/

# Firebase config

# Uncomment this if you'd like others to create their own Firebase project.
# For a team working on the same Firebase project(s), it is recommended to leave
# it commented so all members can deploy to the same project(s) in .firebaserc.
# .firebaserc

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# nyc test coverage
.nyc_output

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env

# dataconnect generated files
.dataconnect
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,12 @@ struct ContentView: View {
actionCodeSettings.linkDomain = "flutterfire-e2e-tests.firebaseapp.com"
actionCodeSettings.setIOSBundleID(Bundle.main.bundleIdentifier!)
let configuration = AuthConfiguration(
shouldAutoUpgradeAnonymousUsers: true,
shouldAutoUpgradeAnonymousUsers: uiAuthEmulator ? false : true,
tosUrl: URL(string: "https://example.com/tos"),
privacyPolicyUrl: URL(string: "https://example.com/privacy"),
emailLinkSignInActionCodeSettings: actionCodeSettings
)

authService = AuthService(
configuration: configuration
)
Expand Down
Loading