import 'dart:async'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:nuvolari/core/region/region_config.dart'; import 'package:nuvolari/core/region/region_repository.dart'; import 'package:nuvolari/l10n/app_localizations.dart'; import 'package:nuvolari/main.dart'; void main() { // The region stays unresolved so the map screen holds its loading state. A // resolved config would instantiate the native map, which has no // implementation in the test harness. testWidgets('starts up in Italian with no app bar', (tester) async { await tester.pumpWidget( ProviderScope( overrides: [ regionConfigProvider.overrideWith( (ref) => Completer().future, ), ], child: const NuvolariApp(), ), ); await tester.pump(); expect(find.text('Caricamento…'), findsOneWidget); // The title bar is gone: the launcher already names the app, and the map // uses the height instead. expect(find.byType(AppBar), findsNothing); }); group('AppLocalizations', () { test('supports Italian', () { expect( AppLocalizations.supportedLocales.map((locale) => locale.languageCode), contains('it'), ); }); test('resolves Italian strings', () async { final l10n = await AppLocalizations.delegate.load(const Locale('it')); expect(l10n.appTitle, 'Nuvolari'); expect(l10n.navRadar, 'Radar'); expect(l10n.navAlerts, 'Allerte'); }); // The disclaimer is a compliance requirement, not copy: it must state both // that the app is independent and that official channels take precedence. test( 'the disclaimer states independence and defers to official channels', () async { final l10n = await AppLocalizations.delegate.load(const Locale('it')); expect(l10n.sourcesDisclaimerBody, contains('indipendente')); expect(l10n.sourcesDisclaimerBody, contains('Arpa Piemonte')); expect(l10n.sourcesDisclaimerBody, contains('Protezione Civile')); expect(l10n.sourcesDisclaimerBody, contains('ufficiali')); }, ); test('pluralises the data age message', () async { final l10n = await AppLocalizations.delegate.load(const Locale('it')); expect(l10n.dataAgeMinutes(0), 'Aggiornato ora'); expect(l10n.dataAgeMinutes(1), 'Aggiornato 1 minuto fa'); expect(l10n.dataAgeMinutes(12), 'Aggiornato 12 minuti fa'); }); }); }