fix(app): a way out when this device's data can't be opened
The screen that says "Couldn't open this device's data." had no button, so the person was stuck until they restarted the app. It now offers "Try again", which opens the person's data anew; a test covers a first attempt that fails and a second that works. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Tizian 「ティツィアーン」 <raisondetredev@pm.me>
This commit is contained in:
parent
ec246e552d
commit
231369900b
2 changed files with 40 additions and 2 deletions
|
|
@ -56,8 +56,24 @@ class _PersonScopeState() extends State<PersonScope> {
|
|||
dependencies: data,
|
||||
child: widget.child,
|
||||
),
|
||||
AsyncSnapshot(hasError: true) => const Scaffold(
|
||||
body: Center(child: Text("Couldn't open this device's data.")),
|
||||
AsyncSnapshot(hasError: true) => Scaffold(
|
||||
body: Center(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
const Text("Couldn't open this device's data."),
|
||||
const SizedBox(height: 16),
|
||||
FilledButton(
|
||||
onPressed: () => setState(() {
|
||||
_opening = DependenciesScope.of(
|
||||
context,
|
||||
).openPerson(widget.person);
|
||||
}),
|
||||
child: const Text('Try again'),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
_ => const Scaffold(body: Center(child: CircularProgressIndicator())),
|
||||
},
|
||||
|
|
|
|||
|
|
@ -56,6 +56,28 @@ void main() {
|
|||
await tester.pump();
|
||||
});
|
||||
|
||||
testWidgets('offers to try again; an attempt that works shows the app', (
|
||||
tester,
|
||||
) async {
|
||||
var attempts = 0;
|
||||
await showScope(tester, () async {
|
||||
if (++attempts == 1) {
|
||||
throw Exception('Disk busy');
|
||||
}
|
||||
return PersonDependencies(
|
||||
studysets: StudysetRepository(FakeStudysetGateway()),
|
||||
cards: CardRepository(FakeCardGateway()),
|
||||
);
|
||||
});
|
||||
expect(find.text("Couldn't open this device's data."), findsOneWidget);
|
||||
|
||||
await tester.tap(find.text('Try again'));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.text('Home'), findsOneWidget);
|
||||
expect(attempts, 2);
|
||||
});
|
||||
|
||||
testWidgets("closes the person's data when it goes away", (tester) async {
|
||||
var closed = false;
|
||||
await showScope(
|
||||
|
|
|
|||
Loading…
Reference in a new issue