Files
Javier Bautista Fernández d579a0e107 feat: Implement startup retry mechanism for custom stations and equalizer persistence
- Added state management for startup retry and custom station handling in `EstadoRadio`.
- Created tasks for implementing strict TDD with RED tests for HTTP failure retries and EQ persistence.
- Developed verification report to ensure compliance with TDD practices.
- Introduced fake services for testing, including `FakeServicioAudio`, `FakeServicioFavoritos`, and `FakeServicioRadio`.
- Implemented widget tests for `PantallaInicio` and `PantallaFavoritos` to validate UI behavior with custom stations.
- Enhanced `ServicioRadio` to support host rotation and retry logic for API calls.
- Established a new configuration file to enforce project constraints and testing rules.
2026-04-27 17:34:04 +02:00

2.9 KiB

Tasks: Startup retry, custom stations, and equalizer persistence

Phase 1: Test seams and RED tests

  • 1.1 RED: Add test/servicios/servicio_radio_test.dart proving a transient HTTP failure retries with another host and succeeds.
  • 1.2 RED: Add test/servicios/servicio_radio_test.dart proving exhausted retries surface an error after the configured attempt cap.
  • 1.3 RED: Add test/estado/estado_radio_test.dart proving a saved custom station is included in the main listing getter.
  • 1.4 RED: Add test/estado/estado_radio_test.dart proving main EQ loads from persistence before playback EQ selection.
  • 1.5 RED: Add station EQ tests proving own EQ overrides main and disabled own EQ falls back to main.
  • 1.6 RED: Add/update a widget test proving PantallaInicio renders custom stations and favorite tap calls the favorite flow.

Phase 2: Foundation / services

  • 2.1 GREEN: Modify ServicioRadio to accept injectable http.Client, host list, max attempts, and retry delay while preserving default constructor behavior.
  • 2.2 GREEN: Implement bounded retry/host rotation in ServicioRadio._get() without adding unbounded startup waits.
  • 2.3 GREEN: Create lib/servicios/servicio_ecualizador.dart with SharedPreferences JSON load/save for main EQ and per-station EQ map.
  • 2.4 GREEN: Add equality/copy helpers to PresetEcualizador only if required by tests.

Phase 3: State integration

  • 3.1 GREEN: Update EstadoRadio constructor for optional service injection and load EQ config during _init().
  • 3.2 GREEN: Add a combined main listing getter (emisorasInicio or equivalent) that includes custom stations plus API stations without duplicates.
  • 3.3 GREEN: Persist main EQ changes when no station-own EQ scope is active.
  • 3.4 GREEN: Add methods to enable/update/disable EQ per favorite station and persist the map.
  • 3.5 GREEN: Change playback EQ selection to apply station EQ when present, otherwise main EQ.

Phase 4: UI wiring

  • 4.1 GREEN: Update PantallaInicio to render the combined main listing when no genre filter is selected.
  • 4.2 GREEN: Reuse TarjetaEmisora favorite controls for custom stations; do not introduce a parallel favorite path.
  • 4.3 GREEN: Update PantallaAjustes EQ controls to show/edit main EQ and, when the current station is a favorite, allow own-EQ vs main-EQ mode.
  • 4.4 GREEN: Fix ServicioAudio/handler so emisoraActual is set on successful playback and cleared on stop/error as tests require.

Phase 5: REFACTOR and verification

  • 5.1 REFACTOR: Remove duplicated JSON/persistence logic from EstadoRadio where the new service owns it.
  • 5.2 REFACTOR: Keep Spanish naming and Provider/ChangeNotifier style consistent with existing folders.
  • 5.3 VERIFY: Run flutter test only; never run flutter build.
  • 5.4 VERIFY: Compare passing tests against every Given/When/Then scenario in spec.md.