Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Error messages are localized (English and Japanese). A request that fails without the API's `error_message` shows "Something went wrong while communicating with the server. Please try again later." (`NATIVEAPPTEMPLATE-2001`); developer-only errors (`NATIVEAPPTEMPLATE-1001`, `2002`鈥揱2008`, `4001`鈥揱4004`) show "An unexpected error occurred." The API's `error_message` is shown without the " [Status: nnn]" suffix. Error codes are unchanged; status codes, field names and underlying errors go to the log (`CodedError.debugDescription`)

### Fixed
- A failed sign-in's error message stayed on screen after the next attempt signed in; a new attempt now dismisses it
- Debug builds lost the local API when launched other than from Xcode, e.g. from the Home Screen or when iOS relaunched the app after its language was changed in Settings: the endpoint came only from the scheme's environment variables, which only Xcode passes. It now comes from `API.xcconfig` (override it in the gitignored `API.local.xcconfig`) and is built into `Info.plist`; `NATIVEAPPTEMPLATE_API_*` environment variables still win. The scheme no longer sets them

### Added
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ final class SignInEmailAndPasswordViewModel {
let theEmail = email.trimmingCharacters(in: whitespacesAndNewlines)
let thePassword = password.trimmingCharacters(in: whitespacesAndNewlines)

// The previous attempt's error no longer applies, and would stay over the
// shops after this attempt signs in
messageBus.dismiss()

do {
isLoggingIn = true
try await sessionController.login(email: theEmail, password: thePassword)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,25 @@ struct SignInEmailAndPasswordViewModelTest {
#expect(viewModel.isLoggingIn == false)
}

@Test("A new attempt dismisses the previous attempt's error")
func signInDismissesPreviousError() async {
let viewModel = SignInEmailAndPasswordViewModel(
sessionController: sessionController,
messageBus: messageBus
)
// TestSessionController starts signed in; the wait below must see this sign-in
sessionController.userState = .notLoggedIn
messageBus.post(message: Message(error: NativeAppTemplateAPIError.requestFailed(nil, 401, "Invalid email or password.")))

viewModel.email = "test@example.com"
viewModel.password = "password123"
viewModel.signIn()

await waitUntil { sessionController.userState == .loggedIn && !viewModel.isLoggingIn }

#expect(messageBus.messageVisible == false)
}

@Test
func signInError() async {
// Simulate an error by setting the sessionController to throw an error
Expand Down
Loading