feat(buscar): add discovery landing state, filter pills, counter, and sort
This commit is contained in:
@@ -1,15 +1,26 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pluriwave/estado/estado_busqueda.dart';
|
||||
import 'package:pluriwave/estado/estado_ecualizador.dart';
|
||||
import 'package:pluriwave/estado/estado_grabacion.dart';
|
||||
import 'package:pluriwave/estado/estado_radio.dart';
|
||||
import 'package:pluriwave/l10n/gen/app_localizations.dart';
|
||||
import 'package:pluriwave/pantallas/pantalla_buscar.dart';
|
||||
import 'package:pluriwave/widgets/tarjeta_emisora.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
import '../helpers/fakes.dart';
|
||||
|
||||
/// S5-R6: the search loading state uses shimmer placeholders, not a bare
|
||||
/// spinner, to stay consistent with the rest of the app.
|
||||
///
|
||||
/// WU6 correction: `PantallaBuscar` now also renders a discovery LANDING
|
||||
/// state (task 6.5) that reads `EstadoRadio` directly, so any widget test
|
||||
/// mounting it — this one included — must provide a full `EstadoRadio`
|
||||
/// provider from the start, not just `EstadoBusqueda`. A non-empty query is
|
||||
/// entered first so the screen leaves the landing state and reaches the
|
||||
/// search-results branch this test actually targets.
|
||||
class _BusquedaCargando extends EstadoBusqueda {
|
||||
_BusquedaCargando() : super(radio: FakeServicioRadio());
|
||||
|
||||
@@ -18,13 +29,36 @@ class _BusquedaCargando extends EstadoBusqueda {
|
||||
}
|
||||
|
||||
void main() {
|
||||
setUp(() {
|
||||
SharedPreferences.setMockInitialValues({});
|
||||
});
|
||||
|
||||
testWidgets('PantallaBuscar muestra shimmer mientras carga', (tester) async {
|
||||
final busqueda = _BusquedaCargando();
|
||||
addTearDown(busqueda.dispose);
|
||||
final estado = EstadoRadio(
|
||||
audio: FakeServicioAudio(),
|
||||
favoritos: FakeServicioFavoritos(),
|
||||
radio: FakeServicioRadio(),
|
||||
servicioEcualizador: FakeServicioEcualizador(),
|
||||
servicioGrabacion: FakeServicioGrabacionRadio(),
|
||||
resolverArchivoCustom: () async => throw UnimplementedError(),
|
||||
iniciarAutomaticamente: false,
|
||||
);
|
||||
addTearDown(estado.dispose);
|
||||
|
||||
await tester.pumpWidget(
|
||||
ListenableProvider<EstadoBusqueda>.value(
|
||||
value: busqueda,
|
||||
MultiProvider(
|
||||
providers: [
|
||||
ChangeNotifierProvider<EstadoRadio>.value(value: estado),
|
||||
ListenableProvider<EstadoEcualizador>.value(
|
||||
value: estado.ecualizador,
|
||||
),
|
||||
ListenableProvider<EstadoGrabacion>.value(value: estado.grabacion),
|
||||
// Overrides EstadoRadio's own (unused here) EstadoBusqueda with a
|
||||
// fake pinned to cargando: true.
|
||||
ListenableProvider<EstadoBusqueda>.value(value: busqueda),
|
||||
],
|
||||
child: MaterialApp(
|
||||
locale: const Locale('es'),
|
||||
localizationsDelegates: AppLocalizations.localizationsDelegates,
|
||||
@@ -35,6 +69,12 @@ void main() {
|
||||
);
|
||||
await tester.pump();
|
||||
|
||||
// Still the landing state — no query entered yet.
|
||||
expect(find.byType(TarjetaEmisoraShimmer), findsNothing);
|
||||
|
||||
await tester.enterText(find.byType(SearchBar), 'jazz');
|
||||
await tester.pump();
|
||||
|
||||
expect(find.byType(TarjetaEmisoraShimmer), findsWidgets);
|
||||
expect(find.byType(CircularProgressIndicator), findsNothing);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user