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.
This commit is contained in:
Javier Bautista Fernández
2026-04-27 17:34:04 +02:00
parent 922b3b4859
commit d579a0e107
21 changed files with 1902 additions and 156 deletions

View File

@@ -0,0 +1,39 @@
# Tasks: Startup retry, custom stations, and equalizer persistence
## Phase 1: Test seams and RED tests
- [x] 1.1 RED: Add `test/servicios/servicio_radio_test.dart` proving a transient HTTP failure retries with another host and succeeds.
- [x] 1.2 RED: Add `test/servicios/servicio_radio_test.dart` proving exhausted retries surface an error after the configured attempt cap.
- [x] 1.3 RED: Add `test/estado/estado_radio_test.dart` proving a saved custom station is included in the main listing getter.
- [x] 1.4 RED: Add `test/estado/estado_radio_test.dart` proving main EQ loads from persistence before playback EQ selection.
- [x] 1.5 RED: Add station EQ tests proving own EQ overrides main and disabled own EQ falls back to main.
- [x] 1.6 RED: Add/update a widget test proving `PantallaInicio` renders custom stations and favorite tap calls the favorite flow.
## Phase 2: Foundation / services
- [x] 2.1 GREEN: Modify `ServicioRadio` to accept injectable `http.Client`, host list, max attempts, and retry delay while preserving default constructor behavior.
- [x] 2.2 GREEN: Implement bounded retry/host rotation in `ServicioRadio._get()` without adding unbounded startup waits.
- [x] 2.3 GREEN: Create `lib/servicios/servicio_ecualizador.dart` with SharedPreferences JSON load/save for main EQ and per-station EQ map.
- [x] 2.4 GREEN: Add equality/copy helpers to `PresetEcualizador` only if required by tests.
## Phase 3: State integration
- [x] 3.1 GREEN: Update `EstadoRadio` constructor for optional service injection and load EQ config during `_init()`.
- [x] 3.2 GREEN: Add a combined main listing getter (`emisorasInicio` or equivalent) that includes custom stations plus API stations without duplicates.
- [x] 3.3 GREEN: Persist main EQ changes when no station-own EQ scope is active.
- [x] 3.4 GREEN: Add methods to enable/update/disable EQ per favorite station and persist the map.
- [x] 3.5 GREEN: Change playback EQ selection to apply station EQ when present, otherwise main EQ.
## Phase 4: UI wiring
- [x] 4.1 GREEN: Update `PantallaInicio` to render the combined main listing when no genre filter is selected.
- [x] 4.2 GREEN: Reuse `TarjetaEmisora` favorite controls for custom stations; do not introduce a parallel favorite path.
- [x] 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.
- [x] 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
- [x] 5.1 REFACTOR: Remove duplicated JSON/persistence logic from `EstadoRadio` where the new service owns it.
- [x] 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`.