import 'dart:io'; import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:pluriwave/estado/estado_radio.dart'; import 'package:pluriwave/l10n/gen/app_localizations.dart'; import 'package:pluriwave/pantallas/ajustes/pantalla_ajustes_info.dart'; import 'package:pluriwave/pantallas/pantalla_tutorial_ayuda.dart'; import 'package:pluriwave/widgets/pluri_push_scaffold.dart'; import 'package:provider/provider.dart'; import 'package:shared_preferences/shared_preferences.dart'; import '../../helpers/fakes.dart'; import '../../helpers/fakes_alarmas.dart'; /// Pre-existing project constraint (see `pantalla_ajustes_test.dart`): /// PluriGlassSurface paints a background over ListTile's ink layer, which /// Flutter flags as a warning-level assertion, not a correctness bug. void _suppressListTileInkAssertion() { final original = FlutterError.onError; FlutterError.onError = (details) { if (details.exceptionAsString().contains( 'ListTile background color or ink splashes may be invisible', )) { return; } original?.call(details); }; addTearDown(() => FlutterError.onError = original); } /// WU3b task 3b.1: the APLICACIÓN detail screen for "Info" renders inside a /// [PluriPushScaffold] and its moved controls (saved-favorites count, help /// row) still respond exactly as they did inside the old `_SeccionInfo`. /// Unlike the other four WU3b screens, this one never had its own header /// icon+title row to strip (see `pantalla_ajustes_info.dart`'s doc comment). void main() { setUp(() { SharedPreferences.setMockInitialValues({}); }); Future archivoCustomVacio() async => File( '${Directory.current.path}/test/fixtures/emisoras_custom_vacio.json', ); Future crearEstado() async { return EstadoRadio( audio: FakeServicioAudio(), favoritos: FakeServicioFavoritos(), radio: FakeServicioRadio(), servicioEcualizador: FakeServicioEcualizador(), servicioGrabacion: FakeServicioGrabacionRadioInactiva(), resolverArchivoCustom: archivoCustomVacio, iniciarAutomaticamente: false, ); } Widget buildScreen(EstadoRadio estado) { return ChangeNotifierProvider.value( value: estado, child: MaterialApp( locale: const Locale('en'), localizationsDelegates: AppLocalizations.localizationsDelegates, supportedLocales: AppLocalizations.supportedLocales, home: const PantallaAjustesInfo(), ), ); } testWidgets('renders inside a PluriPushScaffold titled "Info"', ( tester, ) async { _suppressListTileInkAssertion(); final estado = await crearEstado(); addTearDown(estado.dispose); await tester.pumpWidget(buildScreen(estado)); await tester.pump(); await tester.pump(const Duration(milliseconds: 100)); expect(find.byType(PluriPushScaffold), findsOneWidget); expect(find.text('Info'), findsOneWidget); }); testWidgets( 'moved control still responds: saved favorites count reflects the ' 'favorites list', (tester) async { _suppressListTileInkAssertion(); final estado = await crearEstado(); addTearDown(estado.dispose); await tester.pumpWidget(buildScreen(estado)); await tester.pump(); await tester.pump(const Duration(milliseconds: 100)); expect(find.text('Saved favorites'), findsOneWidget); expect(find.text('0'), findsOneWidget); expect(find.text('Help and tutorial'), findsOneWidget); }, ); testWidgets('tapping "Help and tutorial" opens the tutorial carousel with ' 'primerArranque: false (so its last page reads "Close", not ' '"Start listening")', (tester) async { _suppressListTileInkAssertion(); final estado = await crearEstado(); addTearDown(estado.dispose); await tester.pumpWidget(buildScreen(estado)); await tester.pump(); await tester.pump(const Duration(milliseconds: 100)); await tester.tap(find.text('Help and tutorial')); await tester.pumpAndSettle(); final pantalla = tester.widget( find.byType(PantallaTutorialAyuda), ); expect(pantalla.primerArranque, isFalse); }); }