import 'package:flutter_test/flutter_test.dart'; import 'package:pluriwave/servicios/servicio_tutorial_ayuda.dart'; import 'package:shared_preferences/shared_preferences.dart'; /// `ServicioTutorialAyuda` decides whether the 9-screen help/tutorial /// carousel (`PantallaTutorialAyuda`) is still due on this launch. Same /// injectable-prefs, versioned-key convention as `ServicioBienvenida`: a /// plain one-time boolean flag, since this tutorial shows once (to both /// fresh installs and existing installs upgrading to this version) and is /// otherwise only reachable manually from Ajustes. void main() { TestWidgetsFlutterBinding.ensureInitialized(); group('ServicioTutorialAyuda', () { test( 'debeMostrarTutorial is true before it has ever been marked seen', () async { SharedPreferences.setMockInitialValues({}); final servicio = ServicioTutorialAyuda(); expect(await servicio.debeMostrarTutorial(), isTrue); }, ); test('debeMostrarTutorial is false after marcarTutorialVisto', () async { SharedPreferences.setMockInitialValues({}); final servicio = ServicioTutorialAyuda(); await servicio.marcarTutorialVisto(); expect(await servicio.debeMostrarTutorial(), isFalse); }); test('respects a seen flag already persisted by a prior launch', () async { SharedPreferences.setMockInitialValues({'pluri_tutorial_visto_v1': true}); final servicio = ServicioTutorialAyuda(); expect(await servicio.debeMostrarTutorial(), isFalse); }); test( 'is still due on an existing install that has other unrelated flags ' 'set but never this one (e.g. the welcome screen already seen)', () async { SharedPreferences.setMockInitialValues({ 'pluri_bienvenida_vista_v1': true, }); final servicio = ServicioTutorialAyuda(); expect(await servicio.debeMostrarTutorial(), isTrue); }, ); }); }