Add testing coverage backlog tasks

This commit is contained in:
Claudio Ortolina
2026-05-20 18:22:08 +01:00
parent 23960b5b23
commit ab48d4b13a
3 changed files with 162 additions and 0 deletions
@@ -0,0 +1,53 @@
---
id: ML-192
title: Add high-value behavioral test coverage
status: To Do
assignee: []
created_date: "2026-05-20 17:19"
updated_date: "2026-05-20 17:20"
labels:
- testing
- coverage
dependencies: []
documentation:
- docs/architecture.md
- docs/project-conventions.md
- .agents/skills/testing/SKILL.md
- .agents/skills/ui-framework/SKILL.md
- .agents/skills/sqlite-optimization/SKILL.md
priority: high
ordinal: 35000
---
## Description
<!-- SECTION:DESCRIPTION:BEGIN -->
Increase coverage where current tests would catch meaningful regressions in user-facing workflows and core data transformations. Focus on the high-value gaps identified from the coverage triage: RecordForm genre and cover-search behavior, BarcodeScanner component state and import branches, Notes component create/update/read-edit behavior, ScrobbleRules subset application, and Assets.Image conversion/error handling. Avoid tests that only assert markup exists without exercising behavior.
<!-- SECTION:DESCRIPTION:END -->
## Acceptance Criteria
<!-- AC:BEGIN -->
- [ ] #1 Record editing tests cover genre search suggestions, adding a new normalized genre, preventing duplicate/blank genres, and removing an existing genre through the LiveComponent path.
- [ ] #2 Record editing tests cover Brave cover search success, search failure with a friendly message, selecting a search result, and persisting the downloaded cover hash on the record.
- [ ] #3 Barcode scanner tests cover a scan failure toast, removing one scanned result, clearing all scanned results, and the 2+ new-release async import branch including expected enqueued import jobs.
- [ ] #4 Notes component tests cover creating a new record or artist note, rendering an existing note in read mode, updating note content, and persisting the result through the Notes context.
- [ ] #5 Scrobble rules tests prove apply_all_rules/1 only updates the supplied track subset and leaves non-supplied matching tracks unchanged.
- [ ] #6 Assets image tests cover convert/3 same-format passthrough, successful JPEG/WebP conversion as supported by the app, and invalid image data returning an error tuple.
<!-- AC:END -->
## Implementation Plan
<!-- SECTION:PLAN:BEGIN -->
1. Read docs/architecture.md, docs/project-conventions.md, .agents/skills/testing/SKILL.md, and relevant UI/SQLite guidance before changing tests.
2. Add focused PhoenixTest/LiveView tests around existing record edit flows for genre events and cover search/download, stubbing BraveSearch.API and asserting persisted record state through MusicLibrary.Records.
3. Add BarcodeScanner tests through the collection scan LiveView or component harness, using Req.Test/Oban assertions to verify scan failure, remove/clear behavior, and async import enqueues.
4. Add Notes component coverage through record or artist show pages, asserting persisted notes through MusicLibrary.Notes rather than UI text alone.
5. Add ScrobbleRules subset tests with explicit scrobbled_at_uts values so only supplied tracks are updated.
6. Add Assets.Image tests for convert/3 and invalid data using existing image fixtures or fallback data.
7. Run targeted test files first, then run the relevant project test command if scope/time permits.
<!-- SECTION:PLAN:END -->
@@ -0,0 +1,55 @@
---
id: ML-193
title: Add secondary parser search and API coverage
status: To Do
assignee: []
created_date: "2026-05-20 17:19"
updated_date: "2026-05-20 17:20"
labels:
- testing
- coverage
dependencies: []
documentation:
- docs/architecture.md
- docs/project-conventions.md
- .agents/skills/testing/SKILL.md
- .agents/skills/ui-framework/SKILL.md
- .agents/skills/external-api-integration/SKILL.md
priority: medium
ordinal: 36000
---
## Description
<!-- SECTION:DESCRIPTION:BEGIN -->
Add focused tests for low-coverage modules where direct tests would be more diagnostic than broad end-to-end coverage. Focus on universal search record-set/navigation behavior, MusicBrainz parser helpers, Last.fm session XML edge cases, HTTP/API error classification, the Wikipedia worker cancel path, and StatsComponents on-this-day rendering branches.
<!-- SECTION:DESCRIPTION:END -->
## Acceptance Criteria
<!-- AC:BEGIN -->
- [ ] #1 Universal search tests cover record-set results and counts when record sets match by name, description, contained record title, or artist name.
- [ ] #2 Universal search tests cover navigation events for collection records, wishlist records, artists, record sets, navigation links, and view-all collection/wishlist/record-set actions.
- [ ] #3 MusicBrainz parser tests cover ReleaseGroup artist credits with joinphrases, included release-group filtering, release ID extraction, parse_record_type precedence for live and compilation albums, and ReleaseSearchResult handling of missing release groups or unknown media formats.
- [ ] #4 LastFm.Session tests cover non-subscriber XML, missing subscriber, and missing name/key nodes with explicit expected struct values.
- [ ] #5 HTTP/API error tests cover MusicLibrary.HttpError default status-kind mapping and Discogs.API.ErrorResponse fallback message and retry-delay behavior.
- [ ] #6 ArtistRefreshWikipediaData worker tests cover the {:cancel, :no_english_wikipedia} branch when Wikipedia reports no English article.
- [ ] #7 StatsComponents or page-level tests cover grouped on-this-day records and anniversary labels for Today, normal years, 5-year, and 10-year milestones.
<!-- AC:END -->
## Implementation Plan
<!-- SECTION:PLAN:BEGIN -->
1. Read docs/architecture.md, docs/project-conventions.md, .agents/skills/testing/SKILL.md, and the UI/external API skill guidance before editing tests.
2. Extend universal search tests with record set fixtures and navigation assertions; prefer PhoenixTest and unwrap only where direct LiveView event interaction is needed.
3. Add direct parser tests for MusicBrainz.ReleaseGroup and MusicBrainz.ReleaseSearchResult using small explicit maps plus existing fixtures where helpful.
4. Expand LastFm.Session tests beyond doctests with explicit XML examples for non-subscriber and missing-node cases.
5. Add table-style tests for MusicLibrary.HttpError and Discogs.API.ErrorResponse that assert concrete kinds, messages, retryability, and retry delays.
6. Add the ArtistRefreshWikipediaData no-English-Wikipedia worker branch using a Wikipedia stub or context setup that produces {:error, :no_english_wikipedia}.
7. Cover StatsComponents on-this-day grouped and anniversary rendering through the page if practical, otherwise use focused component rendering consistent with local patterns.
8. Run the new/modified targeted tests and any broader affected test files.
<!-- SECTION:PLAN:END -->
@@ -0,0 +1,54 @@
---
id: ML-194
title: Add selective low-priority smoke coverage
status: To Do
assignee: []
created_date: "2026-05-20 17:19"
updated_date: "2026-05-20 17:20"
labels:
- testing
- coverage
dependencies: []
documentation:
- docs/architecture.md
- docs/project-conventions.md
- docs/production-infrastructure.md
- .agents/skills/testing/SKILL.md
- .agents/skills/oban-worker/SKILL.md
- .agents/skills/ui-framework/SKILL.md
priority: low
ordinal: 37000
---
## Description
<!-- SECTION:DESCRIPTION:BEGIN -->
Add only low-cost tests for low-coverage wiring where there is a real regression signal. This task should not chase percentages with brittle route enumeration, supervision-shape assertions, or Phoenix framework behavior. Focus on thin bulk worker delegation, timezone/static-asset hook assignment if practical, and browser CSP/header behavior.
<!-- SECTION:DESCRIPTION:END -->
## Acceptance Criteria
<!-- AC:BEGIN -->
- [ ] #1 Bulk cron worker smoke tests verify each all-record/all-artist worker delegates to the corresponding batch flow and enqueues the expected downstream jobs for representative records or artist infos.
- [ ] #2 The bulk worker tests avoid duplicating full single-item worker API refresh behavior that is already covered elsewhere.
- [ ] #3 A browser pipeline test asserts the Content-Security-Policy header includes the app-specific image, worker, connect, frame-ancestor, and base-uri directives that matter for current features.
- [ ] #4 GetTimezone hook coverage verifies a provided connect-param timezone is assigned and missing connect params fall back to MusicLibrary.default_timezone/0, if this can be tested without brittle framework setup.
- [ ] #5 StaticAssets hook coverage is added only if it can assert the assigned value through an existing LiveView request without coupling to Phoenix internals.
- [ ] #6 No tests are added for Application child ordering, exhaustive route enumeration, or framework-generated static_changed?/1 behavior unless a concrete project regression is identified.
<!-- AC:END -->
## Implementation Plan
<!-- SECTION:PLAN:BEGIN -->
1. Read docs/architecture.md, docs/project-conventions.md, docs/production-infrastructure.md, .agents/skills/testing/SKILL.md, and .agents/skills/oban-worker/SKILL.md before editing tests.
2. Add a small parameterized worker smoke test file for the all-record/all-artist workers, asserting the expected downstream enqueue behavior through existing batch flows.
3. Keep worker tests shallow: do not stub or exercise external API refresh behavior already covered by single-item worker tests.
4. Add a browser pipeline/controller test for the CSP header on a representative HTML route, asserting only directives that are project-specific and important to current features.
5. Investigate GetTimezone/StaticAssets hook coverage; add tests only if they can be expressed through stable public LiveView behavior without coupling to Phoenix internals.
6. Explicitly avoid Application child ordering, exhaustive route list, and framework static_changed?/1 tests.
7. Run the targeted worker/controller/hook tests and any affected web test file.
<!-- SECTION:PLAN:END -->