generated from StanfordSpezi/SpeziTemplateApplication
-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ensure dismiss action for AccountSetupSheet is anchored correctly (#19)
# Ensure dismiss action for AccountSetupSheet is anchored correctly ## ♻️ Current situation & Problem Fixes the issue described in #18, where the Account Setup sheet wouldn't disappear after successfully logging in. Further this PR fixes the issue where the display name wouldn't be saved upon signup. This issue was fixed upstream in StanfordSpezi/SpeziFirebase#36. ## ⚙️ Release Notes * Fixed an issue where the Account Setup sheet wouldn't disappear after a successful login. * Fixed an issue where the name details wouldn't be saved after a successful signup. ## 📚 Documentation -- ## ✅ Testing UI test was added to verify the setup sheet is dismissed after login. ### Code of Conduct & Contributing Guidelines By submitting creating this pull request, you agree to follow our [Code of Conduct](https://github.com/StanfordBDHG/.github/blob/main/CODE_OF_CONDUCT.md) and [Contributing Guidelines](https://github.com/StanfordBDHG/.github/blob/main/CONTRIBUTING.md): - [x] I agree to follow the [Code of Conduct](https://github.com/StanfordBDHG/.github/blob/main/CODE_OF_CONDUCT.md) and [Contributing Guidelines](https://github.com/StanfordBDHG/.github/blob/main/CONTRIBUTING.md).
- Loading branch information
Showing
10 changed files
with
153 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
// | ||
// This source file is part of the ENGAGE-HF project based on the Stanford Spezi Template Application project | ||
// | ||
// SPDX-FileCopyrightText: 2023 Stanford University | ||
// | ||
// SPDX-License-Identifier: MIT | ||
// | ||
|
||
import SpeziAccount | ||
import SpeziOnboarding | ||
import SwiftUI | ||
|
||
|
||
private struct AccountInvitationCodeView: View { | ||
@Environment(\.dismiss) private var dismiss | ||
|
||
@Environment(Account.self) private var account | ||
|
||
|
||
var body: some View { | ||
InvitationCodeView() | ||
.onChange(of: account.signedIn, initial: true) { | ||
if account.signedIn { | ||
dismiss() | ||
} | ||
} | ||
} | ||
} | ||
|
||
|
||
struct AccountSetupSheet: View { | ||
@Environment(\.dismiss) private var dismiss | ||
|
||
var body: some View { | ||
OnboardingStack { | ||
AccountInvitationCodeView() // we need this indirection, otherwise the onChange doesn't trigger | ||
AccountSetup { _ in | ||
dismiss() | ||
} header: { | ||
AccountSetupHeader() | ||
} | ||
} | ||
} | ||
} | ||
|
||
|
||
#if DEBUG | ||
#Preview { | ||
Text(verbatim: "Base View") | ||
.sheet(isPresented: .constant(true)) { | ||
AccountSetupSheet() | ||
} | ||
.previewWith { | ||
AccountConfiguration { | ||
MockUserIdPasswordAccountService() | ||
} | ||
InvitationCodeModule() | ||
} | ||
} | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
// | ||
// This source file is part of the ENGAGE-HF project based on the Stanford Spezi Template Application project | ||
// | ||
// SPDX-FileCopyrightText: 2024 Stanford University | ||
// | ||
// SPDX-License-Identifier: MIT | ||
// | ||
|
||
import XCTest | ||
import XCTestExtensions | ||
|
||
|
||
final class AccountTests: XCTestCase { | ||
override func setUpWithError() throws { | ||
try super.setUpWithError() | ||
|
||
continueAfterFailure = false | ||
|
||
let app = XCUIApplication() | ||
app.launchArguments = ["--assumeOnboardingComplete", "--setupTestEnvironment"] | ||
app.launch() | ||
} | ||
|
||
func testInAppLogon() throws { | ||
let app = XCUIApplication() | ||
|
||
|
||
XCTAssert(app.buttons["Home"].waitForExistence(timeout: 2.0)) | ||
app.buttons["Home"].tap() | ||
|
||
|
||
XCTAssertTrue(app.navigationBars.buttons["Your Account"].waitForExistence(timeout: 2)) | ||
app.navigationBars.buttons["Your Account"].tap() | ||
|
||
XCTAssert(app.buttons["Logout"].waitForExistence(timeout: 2)) | ||
app.buttons["Logout"].tap() | ||
|
||
let alert = "Are you sure you want to logout?" | ||
XCTAssert(app.alerts[alert].waitForExistence(timeout: 6.0)) | ||
app.alerts[alert].buttons["Logout"].tap() | ||
|
||
sleep(2) | ||
|
||
|
||
// Login | ||
if app.buttons["I Already Have an Account"].waitForExistence(timeout: 2.0) { | ||
app.buttons["I Already Have an Account"].tap() | ||
} | ||
|
||
XCTAssert(app.textFields["E-Mail Address"].waitForExistence(timeout: 2)) | ||
try app.textFields["E-Mail Address"].enter(value: "[email protected]") | ||
|
||
XCTAssert(app.secureTextFields["Password"].waitForExistence(timeout: 2)) | ||
try app.secureTextFields["Password"].enter(value: "123456789") | ||
|
||
XCTAssertTrue(app.buttons["Login"].waitForExistence(timeout: 0.5)) | ||
app.buttons["Login"].tap() | ||
|
||
// ensure home view is in focus | ||
XCTAssert(app.buttons["Home"].waitForExistence(timeout: 2.0)) | ||
app.buttons["Home"].tap() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters