fix(app): a sign-out or deletion that failed says so, its tile showing it under way

The account's tiles show a spinner on Sign out or Delete account while it
runs, start neither again meanwhile, and say once, in a snack bar, why one
failed ("Couldn't delete your account: the instance wasn't reached. Try
again."; "Couldn't sign out on this device. Try again."), in English and
German. The session gate no longer builds the person's app anew for that:
only the tiles follow it.

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:49:18 +02:00
commit f5d8a3ca1f
Signed by: raisondetredev
GPG key ID: 07F6FCF405488B64
2 changed files with 192 additions and 6 deletions

View file

@ -1,7 +1,10 @@
import 'dart:async';
import 'package:clock/clock.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:halkyon_app/halkyon_app.dart';
import 'package:halkyon_app/testing.dart';
import 'package:halkyon_ui/halkyon_ui.dart';
import 'package:material_ui/material_ui.dart';
/// A signed-in person's app as a test makes one: whose it is, and the
@ -344,6 +347,75 @@ void main() {
expect(find.text('Signed out'), findsOneWidget);
});
testWidgets('while the account is deleted, the person stays in their app, '
'Delete account showing it is under way', (tester) async {
await start(tester);
gateway.deletionWaits = Completer();
await tester.tap(find.text('Delete account'));
await tester.pumpAndSettle();
await tester.tap(find.text('Delete account').last);
// The spinner never settles while it runs.
await tester.pump();
await tester.pump(const Duration(milliseconds: 100));
expect(
find.text('App of anonymous-1'),
findsOneWidget,
reason: 'never the launch screen in between',
);
expect(
find.descendant(
of: find.widgetWithText(ListTile, 'Delete account'),
matching: find.byType(ButtonLoadingIndicator),
),
findsOneWidget,
);
gateway.deletionWaits!.complete();
await tester.pumpAndSettle();
expect(find.text('Signed out'), findsOneWidget);
});
testWidgets('a deletion the instance never got keeps the person in their '
'app, and says so once', (tester) async {
await start(tester);
gateway.deletionError = Exception('No connection');
await tester.tap(find.text('Delete account'));
await tester.pumpAndSettle();
await tester.tap(find.text('Delete account').last);
await tester.pumpAndSettle();
expect(
find.text(
"Couldn't delete your account: the instance wasn't reached. "
'Try again.',
),
findsOneWidget,
);
expect(find.text('App of anonymous-1'), findsOneWidget);
expect(gateway.status, isA<SignedIn>());
expect(find.byType(ButtonLoadingIndicator), findsNothing);
});
testWidgets("a sign-out the device's storage failed keeps the person in "
'their app, and says so', (tester) async {
gateway = FakeAuthGateway(
status: const SignedIn(authUserId: 'github-1', isIdentified: true),
)..signOutError = Exception('The keyring is locked');
await start(tester);
await tester.tap(find.text('Sign out'));
await tester.pumpAndSettle();
expect(
find.text("Couldn't sign out on this device. Try again."),
findsOneWidget,
);
expect(find.text('App of github-1'), findsOneWidget);
});
testWidgets('speaks German', (tester) async {
await start(tester);
final german = lookupHalkyonAppLocalizations(const Locale('de'));
@ -358,5 +430,14 @@ void main() {
expect(german.accountSignOutTitle, 'Abmelden?');
expect(german.accountDelete, 'Konto löschen');
expect(german.accountDeleteTitle, 'Dein Konto löschen?');
expect(
german.accountSignOutFailed,
'Abmelden auf diesem Gerät hat nicht geklappt. Versuch es noch einmal.',
);
expect(
german.accountDeleteFailed,
'Dein Konto wurde nicht gelöscht: Die Instanz war nicht erreichbar. '
'Versuch es noch einmal.',
);
});
}

View file

@ -225,4 +225,36 @@ void main() {
await tester.pumpAndSettle();
expect(find.text('Signed out'), findsOneWidget);
});
testWidgets("a sign-out under way or failed leaves the person's app as it "
'is, built once', (tester) async {
gateway = FakeAuthGateway(
status: const SignedIn(authUserId: 'ada', isIdentified: true),
)..signOutError = Exception('The keyring is locked');
dependencies = TestAppDependencies(gateway: gateway);
var builds = 0;
await tester.pumpWidget(
AppFrameScope(
frame: testFrame(),
child: AppScope(
dependencies: dependencies,
child: SessionGate(
look: (context) => (themeMode: ThemeMode.light, locale: null),
app: (person) {
builds++;
return _PersonApp(person);
},
),
),
),
);
await tester.pumpAndSettle();
expect(builds, 1);
await tester.tap(find.text('Sign out'));
await tester.pumpAndSettle();
expect(find.text('App of ada'), findsOneWidget);
expect(builds, 1, reason: "busy and its problem are the account tiles'");
});
}