fix(inventory): recover from a stuck loading spinner
The inventory stream subscription had no onError handler, so a transient failure at startup (e.g. the encrypted DB not yet ready) went unhandled and left loading=true forever — the spinner that only a restart cleared. Handle stream errors: drop out of loading, surface an error state, and offer a retry that re-opens the stream. Add a _LoadError view (i18n en/ es/ast/pt) and cover both the failure and the retry-recovers paths.
This commit is contained in:
parent
b9492cb65a
commit
1666f5b31f
12 changed files with 158 additions and 17 deletions
|
|
@ -132,7 +132,9 @@
|
||||||
"noMatches": "Nenguna simiente concasa colos filtros.",
|
"noMatches": "Nenguna simiente concasa colos filtros.",
|
||||||
"clearFilters": "Quitar filtros",
|
"clearFilters": "Quitar filtros",
|
||||||
"uncategorized": "Ensin categoría",
|
"uncategorized": "Ensin categoría",
|
||||||
"needsReproductionFilter": "Por reproducir"
|
"needsReproductionFilter": "Por reproducir",
|
||||||
|
"loadError": "Nun se pudo abrir el to bancu de granes. Seique taba ocupáu: prueba otra vuelta.",
|
||||||
|
"retry": "Volver probar"
|
||||||
},
|
},
|
||||||
"draft": {
|
"draft": {
|
||||||
"capture": "Capturar semeyes",
|
"capture": "Capturar semeyes",
|
||||||
|
|
|
||||||
|
|
@ -133,7 +133,9 @@
|
||||||
"noMatches": "No seeds match your filters.",
|
"noMatches": "No seeds match your filters.",
|
||||||
"clearFilters": "Clear filters",
|
"clearFilters": "Clear filters",
|
||||||
"uncategorized": "Uncategorized",
|
"uncategorized": "Uncategorized",
|
||||||
"needsReproductionFilter": "To regrow"
|
"needsReproductionFilter": "To regrow",
|
||||||
|
"loadError": "Couldn't open your seed bank. It may just have been busy — try again.",
|
||||||
|
"retry": "Try again"
|
||||||
},
|
},
|
||||||
"draft": {
|
"draft": {
|
||||||
"capture": "Capture photos",
|
"capture": "Capture photos",
|
||||||
|
|
|
||||||
|
|
@ -132,7 +132,9 @@
|
||||||
"noMatches": "Ninguna semilla coincide con los filtros.",
|
"noMatches": "Ninguna semilla coincide con los filtros.",
|
||||||
"clearFilters": "Quitar filtros",
|
"clearFilters": "Quitar filtros",
|
||||||
"uncategorized": "Sin categoría",
|
"uncategorized": "Sin categoría",
|
||||||
"needsReproductionFilter": "Por reproducir"
|
"needsReproductionFilter": "Por reproducir",
|
||||||
|
"loadError": "No se pudo abrir tu banco de semillas. Quizá estaba ocupado: inténtalo de nuevo.",
|
||||||
|
"retry": "Reintentar"
|
||||||
},
|
},
|
||||||
"draft": {
|
"draft": {
|
||||||
"capture": "Capturar fotos",
|
"capture": "Capturar fotos",
|
||||||
|
|
|
||||||
|
|
@ -133,7 +133,9 @@
|
||||||
"noMatches": "Nenhuma semente corresponde aos teus filtros.",
|
"noMatches": "Nenhuma semente corresponde aos teus filtros.",
|
||||||
"clearFilters": "Limpar filtros",
|
"clearFilters": "Limpar filtros",
|
||||||
"uncategorized": "Sem categoria",
|
"uncategorized": "Sem categoria",
|
||||||
"needsReproductionFilter": "Para reproduzir"
|
"needsReproductionFilter": "Para reproduzir",
|
||||||
|
"loadError": "Não foi possível abrir o teu banco de sementes. Talvez estivesse ocupado — tenta de novo.",
|
||||||
|
"retry": "Tentar de novo"
|
||||||
},
|
},
|
||||||
"draft": {
|
"draft": {
|
||||||
"capture": "Capturar fotos",
|
"capture": "Capturar fotos",
|
||||||
|
|
|
||||||
|
|
@ -4,9 +4,9 @@
|
||||||
/// To regenerate, run: `dart run slang`
|
/// To regenerate, run: `dart run slang`
|
||||||
///
|
///
|
||||||
/// Locales: 4
|
/// Locales: 4
|
||||||
/// Strings: 1668 (417 per locale)
|
/// Strings: 1676 (419 per locale)
|
||||||
///
|
///
|
||||||
/// Built on 2026-07-10 at 19:42 UTC
|
/// Built on 2026-07-10 at 20:10 UTC
|
||||||
|
|
||||||
// coverage:ignore-file
|
// coverage:ignore-file
|
||||||
// ignore_for_file: type=lint, unused_import
|
// ignore_for_file: type=lint, unused_import
|
||||||
|
|
|
||||||
|
|
@ -268,6 +268,8 @@ class _Translations$inventory$ast extends Translations$inventory$en {
|
||||||
@override String get clearFilters => 'Quitar filtros';
|
@override String get clearFilters => 'Quitar filtros';
|
||||||
@override String get uncategorized => 'Ensin categoría';
|
@override String get uncategorized => 'Ensin categoría';
|
||||||
@override String get needsReproductionFilter => 'Por reproducir';
|
@override String get needsReproductionFilter => 'Por reproducir';
|
||||||
|
@override String get loadError => 'Nun se pudo abrir el to bancu de granes. Seique taba ocupáu: prueba otra vuelta.';
|
||||||
|
@override String get retry => 'Volver probar';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Path: draft
|
// Path: draft
|
||||||
|
|
@ -1248,6 +1250,8 @@ extension on TranslationsAst {
|
||||||
'inventory.clearFilters' => 'Quitar filtros',
|
'inventory.clearFilters' => 'Quitar filtros',
|
||||||
'inventory.uncategorized' => 'Ensin categoría',
|
'inventory.uncategorized' => 'Ensin categoría',
|
||||||
'inventory.needsReproductionFilter' => 'Por reproducir',
|
'inventory.needsReproductionFilter' => 'Por reproducir',
|
||||||
|
'inventory.loadError' => 'Nun se pudo abrir el to bancu de granes. Seique taba ocupáu: prueba otra vuelta.',
|
||||||
|
'inventory.retry' => 'Volver probar',
|
||||||
'draft.capture' => 'Capturar semeyes',
|
'draft.capture' => 'Capturar semeyes',
|
||||||
'draft.captured' => ({required Object n}) => '${n} capturaes por catalogar',
|
'draft.captured' => ({required Object n}) => '${n} capturaes por catalogar',
|
||||||
'draft.triageTitle' => 'Por catalogar',
|
'draft.triageTitle' => 'Por catalogar',
|
||||||
|
|
|
||||||
|
|
@ -455,6 +455,12 @@ class Translations$inventory$en {
|
||||||
|
|
||||||
/// en: 'To regrow'
|
/// en: 'To regrow'
|
||||||
String get needsReproductionFilter => 'To regrow';
|
String get needsReproductionFilter => 'To regrow';
|
||||||
|
|
||||||
|
/// en: 'Couldn't open your seed bank. It may just have been busy — try again.'
|
||||||
|
String get loadError => 'Couldn\'t open your seed bank. It may just have been busy — try again.';
|
||||||
|
|
||||||
|
/// en: 'Try again'
|
||||||
|
String get retry => 'Try again';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Path: draft
|
// Path: draft
|
||||||
|
|
@ -2070,6 +2076,8 @@ extension on Translations {
|
||||||
'inventory.clearFilters' => 'Clear filters',
|
'inventory.clearFilters' => 'Clear filters',
|
||||||
'inventory.uncategorized' => 'Uncategorized',
|
'inventory.uncategorized' => 'Uncategorized',
|
||||||
'inventory.needsReproductionFilter' => 'To regrow',
|
'inventory.needsReproductionFilter' => 'To regrow',
|
||||||
|
'inventory.loadError' => 'Couldn\'t open your seed bank. It may just have been busy — try again.',
|
||||||
|
'inventory.retry' => 'Try again',
|
||||||
'draft.capture' => 'Capture photos',
|
'draft.capture' => 'Capture photos',
|
||||||
'draft.captured' => ({required Object n}) => '${n} captured to catalogue',
|
'draft.captured' => ({required Object n}) => '${n} captured to catalogue',
|
||||||
'draft.triageTitle' => 'To catalogue',
|
'draft.triageTitle' => 'To catalogue',
|
||||||
|
|
|
||||||
|
|
@ -268,6 +268,8 @@ class _Translations$inventory$es extends Translations$inventory$en {
|
||||||
@override String get clearFilters => 'Quitar filtros';
|
@override String get clearFilters => 'Quitar filtros';
|
||||||
@override String get uncategorized => 'Sin categoría';
|
@override String get uncategorized => 'Sin categoría';
|
||||||
@override String get needsReproductionFilter => 'Por reproducir';
|
@override String get needsReproductionFilter => 'Por reproducir';
|
||||||
|
@override String get loadError => 'No se pudo abrir tu banco de semillas. Quizá estaba ocupado: inténtalo de nuevo.';
|
||||||
|
@override String get retry => 'Reintentar';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Path: draft
|
// Path: draft
|
||||||
|
|
@ -1250,6 +1252,8 @@ extension on TranslationsEs {
|
||||||
'inventory.clearFilters' => 'Quitar filtros',
|
'inventory.clearFilters' => 'Quitar filtros',
|
||||||
'inventory.uncategorized' => 'Sin categoría',
|
'inventory.uncategorized' => 'Sin categoría',
|
||||||
'inventory.needsReproductionFilter' => 'Por reproducir',
|
'inventory.needsReproductionFilter' => 'Por reproducir',
|
||||||
|
'inventory.loadError' => 'No se pudo abrir tu banco de semillas. Quizá estaba ocupado: inténtalo de nuevo.',
|
||||||
|
'inventory.retry' => 'Reintentar',
|
||||||
'draft.capture' => 'Capturar fotos',
|
'draft.capture' => 'Capturar fotos',
|
||||||
'draft.captured' => ({required Object n}) => '${n} capturadas por catalogar',
|
'draft.captured' => ({required Object n}) => '${n} capturadas por catalogar',
|
||||||
'draft.triageTitle' => 'Por catalogar',
|
'draft.triageTitle' => 'Por catalogar',
|
||||||
|
|
|
||||||
|
|
@ -269,6 +269,8 @@ class _Translations$inventory$pt extends Translations$inventory$en {
|
||||||
@override String get clearFilters => 'Limpar filtros';
|
@override String get clearFilters => 'Limpar filtros';
|
||||||
@override String get uncategorized => 'Sem categoria';
|
@override String get uncategorized => 'Sem categoria';
|
||||||
@override String get needsReproductionFilter => 'Para reproduzir';
|
@override String get needsReproductionFilter => 'Para reproduzir';
|
||||||
|
@override String get loadError => 'Não foi possível abrir o teu banco de sementes. Talvez estivesse ocupado — tenta de novo.';
|
||||||
|
@override String get retry => 'Tentar de novo';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Path: draft
|
// Path: draft
|
||||||
|
|
@ -1248,6 +1250,8 @@ extension on TranslationsPt {
|
||||||
'inventory.clearFilters' => 'Limpar filtros',
|
'inventory.clearFilters' => 'Limpar filtros',
|
||||||
'inventory.uncategorized' => 'Sem categoria',
|
'inventory.uncategorized' => 'Sem categoria',
|
||||||
'inventory.needsReproductionFilter' => 'Para reproduzir',
|
'inventory.needsReproductionFilter' => 'Para reproduzir',
|
||||||
|
'inventory.loadError' => 'Não foi possível abrir o teu banco de sementes. Talvez estivesse ocupado — tenta de novo.',
|
||||||
|
'inventory.retry' => 'Tentar de novo',
|
||||||
'draft.capture' => 'Capturar fotos',
|
'draft.capture' => 'Capturar fotos',
|
||||||
'draft.captured' => ({required Object n}) => '${n} capturadas para catalogar',
|
'draft.captured' => ({required Object n}) => '${n} capturadas para catalogar',
|
||||||
'draft.triageTitle' => 'Para catalogar',
|
'draft.triageTitle' => 'Para catalogar',
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,7 @@ class InventoryState extends Equatable {
|
||||||
this.needsReproductionOnly = false,
|
this.needsReproductionOnly = false,
|
||||||
this.sharingOnly = false,
|
this.sharingOnly = false,
|
||||||
this.loading = true,
|
this.loading = true,
|
||||||
|
this.error,
|
||||||
this.selectionMode = false,
|
this.selectionMode = false,
|
||||||
this.selectedIds = const {},
|
this.selectedIds = const {},
|
||||||
});
|
});
|
||||||
|
|
@ -51,6 +52,11 @@ class InventoryState extends Equatable {
|
||||||
|
|
||||||
final bool loading;
|
final bool loading;
|
||||||
|
|
||||||
|
/// Set when the inventory stream fails (e.g. the encrypted DB wasn't ready).
|
||||||
|
/// The UI shows a retry affordance instead of an endless spinner; null when
|
||||||
|
/// fine. See [InventoryCubit.retry].
|
||||||
|
final String? error;
|
||||||
|
|
||||||
/// Whether the list is in multi-select mode — used to pick a subset of the
|
/// Whether the list is in multi-select mode — used to pick a subset of the
|
||||||
/// inventory to print labels for.
|
/// inventory to print labels for.
|
||||||
final bool selectionMode;
|
final bool selectionMode;
|
||||||
|
|
@ -110,6 +116,7 @@ class InventoryState extends Equatable {
|
||||||
bool? needsReproductionOnly,
|
bool? needsReproductionOnly,
|
||||||
bool? sharingOnly,
|
bool? sharingOnly,
|
||||||
bool? loading,
|
bool? loading,
|
||||||
|
String? Function()? error,
|
||||||
bool? selectionMode,
|
bool? selectionMode,
|
||||||
Set<String>? selectedIds,
|
Set<String>? selectedIds,
|
||||||
}) {
|
}) {
|
||||||
|
|
@ -124,6 +131,7 @@ class InventoryState extends Equatable {
|
||||||
needsReproductionOnly ?? this.needsReproductionOnly,
|
needsReproductionOnly ?? this.needsReproductionOnly,
|
||||||
sharingOnly: sharingOnly ?? this.sharingOnly,
|
sharingOnly: sharingOnly ?? this.sharingOnly,
|
||||||
loading: loading ?? this.loading,
|
loading: loading ?? this.loading,
|
||||||
|
error: error != null ? error() : this.error,
|
||||||
selectionMode: selectionMode ?? this.selectionMode,
|
selectionMode: selectionMode ?? this.selectionMode,
|
||||||
selectedIds: selectedIds ?? this.selectedIds,
|
selectedIds: selectedIds ?? this.selectedIds,
|
||||||
);
|
);
|
||||||
|
|
@ -140,6 +148,7 @@ class InventoryState extends Equatable {
|
||||||
needsReproductionOnly,
|
needsReproductionOnly,
|
||||||
sharingOnly,
|
sharingOnly,
|
||||||
loading,
|
loading,
|
||||||
|
error,
|
||||||
selectionMode,
|
selectionMode,
|
||||||
selectedIds,
|
selectedIds,
|
||||||
];
|
];
|
||||||
|
|
@ -149,21 +158,46 @@ class InventoryState extends Equatable {
|
||||||
/// automatically after a quick-add — no manual refresh.
|
/// automatically after a quick-add — no manual refresh.
|
||||||
class InventoryCubit extends Cubit<InventoryState> {
|
class InventoryCubit extends Cubit<InventoryState> {
|
||||||
InventoryCubit(this._repo) : super(const InventoryState()) {
|
InventoryCubit(this._repo) : super(const InventoryState()) {
|
||||||
// One combined subscription (list + draft tray). Two separate StreamGroups
|
_subscribe();
|
||||||
// here re-emit in a loop that hangs widget tests — see watchInventoryView.
|
|
||||||
_sub = _repo.watchInventoryView().listen(
|
|
||||||
(view) => emit(
|
|
||||||
state.copyWith(items: view.items, drafts: view.drafts, loading: false),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
final VarietyRepository _repo;
|
final VarietyRepository _repo;
|
||||||
late final StreamSubscription<
|
StreamSubscription<
|
||||||
({List<VarietyListItem> items, List<VarietyListItem> drafts})
|
({List<VarietyListItem> items, List<VarietyListItem> drafts})
|
||||||
>
|
>?
|
||||||
_sub;
|
_sub;
|
||||||
|
|
||||||
|
/// (Re)opens the combined inventory subscription (list + draft tray). One
|
||||||
|
/// subscription only: two separate StreamGroups here re-emit in a loop that
|
||||||
|
/// hangs widget tests — see watchInventoryView.
|
||||||
|
///
|
||||||
|
/// The onError handler is load-bearing: without it a transient stream failure
|
||||||
|
/// (e.g. the encrypted DB not yet ready at startup) would go unhandled and
|
||||||
|
/// leave [InventoryState.loading] true forever — the "stuck spinner" that a
|
||||||
|
/// restart clears. On error we drop out of loading and surface [error] so the
|
||||||
|
/// UI can offer [retry].
|
||||||
|
void _subscribe() {
|
||||||
|
_sub?.cancel();
|
||||||
|
_sub = _repo.watchInventoryView().listen(
|
||||||
|
(view) => emit(
|
||||||
|
state.copyWith(
|
||||||
|
items: view.items,
|
||||||
|
drafts: view.drafts,
|
||||||
|
loading: false,
|
||||||
|
error: () => null,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
onError: (Object e) =>
|
||||||
|
emit(state.copyWith(loading: false, error: () => '$e')),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Re-opens the inventory stream after a failure, back to the loading state.
|
||||||
|
void retry() {
|
||||||
|
emit(state.copyWith(loading: true, error: () => null));
|
||||||
|
_subscribe();
|
||||||
|
}
|
||||||
|
|
||||||
void search(String query) => emit(state.copyWith(query: query));
|
void search(String query) => emit(state.copyWith(query: query));
|
||||||
|
|
||||||
/// Toggles a category in the filter (add if absent, remove if present).
|
/// Toggles a category in the filter (add if absent, remove if present).
|
||||||
|
|
@ -235,7 +269,7 @@ class InventoryCubit extends Cubit<InventoryState> {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<void> close() async {
|
Future<void> close() async {
|
||||||
await _sub.cancel();
|
await _sub?.cancel();
|
||||||
return super.close();
|
return super.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,9 @@ class InventoryListScreen extends StatelessWidget {
|
||||||
),
|
),
|
||||||
child: const Icon(Icons.add),
|
child: const Icon(Icons.add),
|
||||||
),
|
),
|
||||||
body: state.loading
|
body: state.error != null
|
||||||
|
? _LoadError(onRetry: context.read<InventoryCubit>().retry)
|
||||||
|
: state.loading
|
||||||
? const Center(child: CircularProgressIndicator())
|
? const Center(child: CircularProgressIndicator())
|
||||||
: Column(
|
: Column(
|
||||||
children: [
|
children: [
|
||||||
|
|
@ -237,6 +239,38 @@ class InventoryListScreen extends StatelessWidget {
|
||||||
|
|
||||||
/// A tappable banner announcing how many photo-first captures are waiting to be
|
/// A tappable banner announcing how many photo-first captures are waiting to be
|
||||||
/// named. Opens the "to catalogue" tray.
|
/// named. Opens the "to catalogue" tray.
|
||||||
|
/// Shown when the inventory stream fails to open — instead of an endless
|
||||||
|
/// spinner, offer a clear message and a way to try again.
|
||||||
|
class _LoadError extends StatelessWidget {
|
||||||
|
const _LoadError({required this.onRetry});
|
||||||
|
|
||||||
|
final VoidCallback onRetry;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final t = context.t;
|
||||||
|
return Center(
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.all(24),
|
||||||
|
child: Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
const Icon(Icons.cloud_off_outlined, size: 48, color: seedGreen),
|
||||||
|
const SizedBox(height: 16),
|
||||||
|
Text(t.inventory.loadError, textAlign: TextAlign.center),
|
||||||
|
const SizedBox(height: 16),
|
||||||
|
FilledButton(
|
||||||
|
key: const Key('inventory.retry'),
|
||||||
|
onPressed: onRetry,
|
||||||
|
child: Text(t.inventory.retry),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
class _TriageBanner extends StatelessWidget {
|
class _TriageBanner extends StatelessWidget {
|
||||||
const _TriageBanner({required this.count});
|
const _TriageBanner({required this.count});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
import 'dart:typed_data';
|
import 'dart:typed_data';
|
||||||
|
|
||||||
|
import 'package:commons_core/commons_core.dart';
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
import 'package:tane/data/variety_repository.dart';
|
import 'package:tane/data/variety_repository.dart';
|
||||||
import 'package:tane/db/database.dart';
|
import 'package:tane/db/database.dart';
|
||||||
|
|
@ -8,6 +9,22 @@ import 'package:tane/state/inventory_cubit.dart';
|
||||||
|
|
||||||
import '../support/test_support.dart';
|
import '../support/test_support.dart';
|
||||||
|
|
||||||
|
/// A repository whose inventory stream errors until [healthy] is flipped —
|
||||||
|
/// mimics the transient DB-not-ready failure that used to leave the spinner
|
||||||
|
/// stuck forever.
|
||||||
|
class _FailingRepository extends VarietyRepository {
|
||||||
|
// ignore: use_super_parameters
|
||||||
|
_FailingRepository(AppDatabase db)
|
||||||
|
: super(db, idGen: IdGen(), nodeId: 'test-node');
|
||||||
|
|
||||||
|
bool healthy = false;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Stream<({List<VarietyListItem> items, List<VarietyListItem> drafts})>
|
||||||
|
watchInventoryView() =>
|
||||||
|
healthy ? super.watchInventoryView() : Stream.error(StateError('boom'));
|
||||||
|
}
|
||||||
|
|
||||||
/// Waits until the cubit's state satisfies [predicate], whether it already
|
/// Waits until the cubit's state satisfies [predicate], whether it already
|
||||||
/// does or a later stream emission gets it there.
|
/// does or a later stream emission gets it there.
|
||||||
Future<InventoryState> waitFor(
|
Future<InventoryState> waitFor(
|
||||||
|
|
@ -39,6 +56,34 @@ void main() {
|
||||||
expect(state.items.single.label, 'Maize');
|
expect(state.items.single.label, 'Maize');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
group('stream failure', () {
|
||||||
|
test('a failing stream drops loading and surfaces an error, not a '
|
||||||
|
'forever-spinner', () async {
|
||||||
|
final failing = _FailingRepository(db);
|
||||||
|
final failCubit = InventoryCubit(failing);
|
||||||
|
addTearDown(failCubit.close);
|
||||||
|
|
||||||
|
final state = await waitFor(failCubit, (s) => s.error != null);
|
||||||
|
expect(state.loading, isFalse);
|
||||||
|
expect(state.error, contains('boom'));
|
||||||
|
});
|
||||||
|
|
||||||
|
test('retry re-opens the stream and recovers once the DB is healthy',
|
||||||
|
() async {
|
||||||
|
final failing = _FailingRepository(db);
|
||||||
|
final failCubit = InventoryCubit(failing);
|
||||||
|
addTearDown(failCubit.close);
|
||||||
|
await waitFor(failCubit, (s) => s.error != null);
|
||||||
|
|
||||||
|
await failing.addQuickVariety(label: 'Maize');
|
||||||
|
failing.healthy = true;
|
||||||
|
failCubit.retry();
|
||||||
|
|
||||||
|
final state = await waitFor(failCubit, (s) => s.error == null && !s.loading);
|
||||||
|
expect(state.items.single.label, 'Maize');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
test('drafts stay in the tray and never mix into the list', () async {
|
test('drafts stay in the tray and never mix into the list', () async {
|
||||||
await repo.addDraftVariety(Uint8List.fromList([1, 2, 3]));
|
await repo.addDraftVariety(Uint8List.fromList([1, 2, 3]));
|
||||||
var state = await waitFor(cubit, (s) => s.drafts.isNotEmpty);
|
var state = await waitFor(cubit, (s) => s.drafts.isNotEmpty);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue