fix(app): signing out or deleting the account keeps the person's app until it is done

Both went through the launch screen (SessionStateLoading), which closed the
person's app before asking the instance; a failure then opened it again
with no word of why. The person's state stays now, saying what is under
way (`busy`), and a failure keeps them signed in with why (`problem`). An
instance out of reach still signs out on the device (Serverpod's
signOutDevice), as signing out of a borrowed device must work offline, so
only the device's own storage fails a sign-out; a deletion fails whenever
the instance isn't reached or refuses.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Tizian 「ティツィアーン」 <raisondetredev@pm.me>
This commit is contained in:
Tizian 「ティツィアーン」 2026-10-21 19:44:43 +02:00
commit 662c30b117
Signed by: raisondetredev
GPG key ID: 07F6FCF405488B64

View file

@ -69,10 +69,12 @@ void main() {
bloc.add(const SessionEventSignOutRequested());
// The person's app stays while signing out, never the launch screen in
// between.
await expectLater(
bloc.stream,
emitsInOrder([
const SessionStateLoading(),
const SessionStateActive(stored, busy: SessionAction.signOut),
const SessionStateSignedOut(),
]),
);
@ -208,11 +210,65 @@ void main() {
await expectLater(
bloc.stream,
emitsInOrder([
const SessionStateLoading(),
const SessionStateActive(stored, busy: SessionAction.delete),
const SessionStateSignedOut(),
]),
);
expect(gateway.accountDeletions, 1);
expect(gateway.signIns, 0);
});
test('a deletion that fails keeps the person signed in, their app in '
'place, and says so; asked again, it tries again', () async {
const stored = SignedIn(authUserId: 'github-1', isIdentified: true);
start(status: stored);
bloc.add(const SessionEventStarted());
await expectLater(bloc.stream, emits(const SessionStateActive(stored)));
gateway.deletionError = Exception('No connection');
bloc.add(const SessionEventDeleteRequested());
await expectLater(
bloc.stream,
emitsInOrder([
const SessionStateActive(stored, busy: SessionAction.delete),
const SessionStateActive(stored, problem: SessionProblem.deleteFailed),
]),
);
expect(gateway.status, stored);
expect(mark.signedOut, isFalse);
gateway.deletionError = null;
bloc.add(const SessionEventDeleteRequested());
await expectLater(
bloc.stream,
emitsInOrder([
const SessionStateActive(stored, busy: SessionAction.delete),
const SessionStateSignedOut(),
]),
);
expect(gateway.accountDeletions, 2);
});
test('a sign-out that fails keeps the person signed in, their app in '
'place, and says so', () async {
const stored = SignedIn(authUserId: 'github-1', isIdentified: true);
start(status: stored);
bloc.add(const SessionEventStarted());
await expectLater(bloc.stream, emits(const SessionStateActive(stored)));
gateway.signOutError = Exception('The keyring is locked');
bloc.add(const SessionEventSignOutRequested());
await expectLater(
bloc.stream,
emitsInOrder([
const SessionStateActive(stored, busy: SessionAction.signOut),
const SessionStateActive(stored, problem: SessionProblem.signOutFailed),
]),
);
expect(gateway.status, stored);
expect(mark.signedOut, isFalse);
});
}