test: widget test per il layer di presentazione

Prima era esercitato solo dall'integration test su emulatore:

- converter_page: ricerca, stati vuoti, selezione, calcolo, swap, reset
- shopping_list_page: aggiunta, contatore, sezione completati, dialog svuota
- meal_planner_page: 7 card, giorno espanso, genera lista, dialog svuota,
  stato del pulsante Condividi
- qr_share_sheet: QR per piano valido, errore oltre il limite, chiusura
- app (BitePlanApp): navigazione fra i tab, bottom sheet informazioni
- guide_page e info_bottom_sheet: contenuti e navigazione alla guida
- empty_state: icona, titolo, sottotitolo opzionale
- coverage_helper: importa tutta lib/ così lcov include anche i file
  non toccati da alcun test

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
2026-07-12 20:08:49 +02:00
parent 9384bd6117
commit d94bd5fdf7
9 changed files with 623 additions and 0 deletions
+34
View File
@@ -0,0 +1,34 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:biteplan/shared/widgets/empty_state.dart';
import '../../helpers/pump_app.dart';
void main() {
group('EmptyState', () {
testWidgets('mostra icona e titolo', (tester) async {
await tester.pumpApp(const Scaffold(
body: EmptyState(icon: Icons.search, title: 'Nessun elemento'),
));
expect(find.byIcon(Icons.search), findsOneWidget);
expect(find.text('Nessun elemento'), findsOneWidget);
});
testWidgets('mostra il sottotitolo quando presente', (tester) async {
await tester.pumpApp(const Scaffold(
body: EmptyState(
icon: Icons.search,
title: 'Titolo',
subtitle: 'Sottotitolo di prova',
),
));
expect(find.text('Sottotitolo di prova'), findsOneWidget);
});
testWidgets('nessun sottotitolo quando assente', (tester) async {
await tester.pumpApp(const Scaffold(
body: EmptyState(icon: Icons.search, title: 'Titolo'),
));
expect(find.byType(Text), findsOneWidget);
});
});
}