73 lines
2.6 KiB
Dart
73 lines
2.6 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:pluriwave/estado/estado_idioma.dart';
|
|
import 'package:pluriwave/l10n/gen/app_localizations.dart';
|
|
import 'package:pluriwave/pantallas/ajustes/pantalla_ajustes_idioma.dart';
|
|
import 'package:pluriwave/widgets/pluri_push_scaffold.dart';
|
|
import 'package:provider/provider.dart';
|
|
import 'package:shared_preferences/shared_preferences.dart';
|
|
|
|
/// WU3b task 3b.1: the APLICACIÓN detail screen for "Idioma" renders inside
|
|
/// a [PluriPushScaffold] and its moved control (the language dropdown)
|
|
/// still responds exactly as it did inside the old `_SeccionIdioma`.
|
|
void main() {
|
|
setUp(() {
|
|
SharedPreferences.setMockInitialValues({});
|
|
});
|
|
|
|
Widget buildScreen(EstadoIdioma estado) {
|
|
return ChangeNotifierProvider<EstadoIdioma>.value(
|
|
value: estado,
|
|
child: MaterialApp(
|
|
locale: const Locale('en'),
|
|
localizationsDelegates: AppLocalizations.localizationsDelegates,
|
|
supportedLocales: AppLocalizations.supportedLocales,
|
|
home: const PantallaAjustesIdioma(),
|
|
),
|
|
);
|
|
}
|
|
|
|
testWidgets('renders inside a PluriPushScaffold titled "Language"', (
|
|
tester,
|
|
) async {
|
|
final estado = EstadoIdioma(
|
|
sharedPreferences: await SharedPreferences.getInstance(),
|
|
);
|
|
addTearDown(estado.dispose);
|
|
|
|
await tester.pumpWidget(buildScreen(estado));
|
|
await tester.pumpAndSettle();
|
|
|
|
expect(find.byType(PluriPushScaffold), findsOneWidget);
|
|
// "Language" legitimately renders twice here too (pre-existing,
|
|
// unmodified by this move): the pushed screen's title AND the
|
|
// dropdown's own floating label share the same l10n string.
|
|
expect(find.text('Language'), findsWidgets);
|
|
});
|
|
|
|
testWidgets('moved control still responds: selecting a language persists '
|
|
'it', (tester) async {
|
|
final estado = EstadoIdioma(
|
|
sharedPreferences: await SharedPreferences.getInstance(),
|
|
);
|
|
addTearDown(estado.dispose);
|
|
|
|
await tester.pumpWidget(buildScreen(estado));
|
|
await tester.pumpAndSettle();
|
|
|
|
await tester.tap(find.byType(DropdownButtonFormField<String>));
|
|
await tester.pumpAndSettle();
|
|
await tester.tap(find.text('Español').last);
|
|
await tester.pumpAndSettle();
|
|
|
|
expect(estado.localeSeleccionado, const Locale('es'));
|
|
expect(find.text('Language updated: Español'), findsOneWidget);
|
|
|
|
// SnackBar's own dismiss Timer is not frame-scheduled — let it resolve
|
|
// before teardown (WU3a batch discovery) instead of leaving a pending
|
|
// Timer behind.
|
|
await tester.pump(const Duration(seconds: 5));
|
|
await tester.pumpAndSettle();
|
|
});
|
|
}
|