Skip to content

test: add coverage for repositories, services and helpers - #291

Merged
richardthe3rd merged 2 commits into
mainfrom
claude/improve-dart-coverage-iCQSk
May 17, 2026
Merged

test: add coverage for repositories, services and helpers#291
richardthe3rd merged 2 commits into
mainfrom
claude/improve-dart-coverage-iCQSk

Conversation

@richardthe3rd

Copy link
Copy Markdown
Owner

Add unit tests for previously untested pure-logic units and fill
branch gaps in existing domain coverage:

  • TastingLogService, ApiDrinkRepository, ApiFestivalRepository
  • ABVStrength, BeverageType, CategoryColor, StringFormatting helpers
  • FestivalService non-200 response handling
  • Festival single-day isLive, hasEnded default time, and sortByDate
    with undated festivals
  • BeerProvider toggleTasted, stale-data refresh, and favourite-filter
    re-application

Also extend the .gitignore mock-keep rule to nested test directories
so generated repository mocks are tracked. All 705 tests pass; overall
line coverage rises to ~81%.

https://claude.ai/code/session_019w4vSjQKXKNBisd3Uzp4Ya

Add unit tests for previously untested pure-logic units and fill
branch gaps in existing domain coverage:

- TastingLogService, ApiDrinkRepository, ApiFestivalRepository
- ABVStrength, BeverageType, CategoryColor, StringFormatting helpers
- FestivalService non-200 response handling
- Festival single-day isLive, hasEnded default time, and sortByDate
  with undated festivals
- BeerProvider toggleTasted, stale-data refresh, and favourite-filter
  re-application

Also extend the .gitignore mock-keep rule to nested test directories
so generated repository mocks are tracked. All 705 tests pass; overall
line coverage rises to ~81%.

https://claude.ai/code/session_019w4vSjQKXKNBisd3Uzp4Ya
Copilot AI review requested due to automatic review settings May 17, 2026 20:04

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds unit coverage for pure logic around repositories, services, helpers, provider behavior, and festival date handling, plus tracks nested Mockito mocks needed by those tests.

Changes:

  • Added tests for tasting logs, API repositories, helpers, festival models, service error handling, and BeerProvider branches.
  • Added generated Mockito mock files for repository/widget tests.
  • Updated .gitignore to allow nested test/**/*.mocks.dart files.

Reviewed changes

Copilot reviewed 13 out of 14 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
.gitignore Allows nested test mock files to be committed.
test/abv_strength_helper_test.dart Covers ABV strength labels and colors.
test/beer_provider_test.dart Adds BeerProvider branch coverage for tasted, stale refresh, favorites, and style counts.
test/beverage_type_helper_test.dart Covers beverage type formatting and icons.
test/category_color_helper_test.dart Covers category color resolution.
test/domain/repositories/api_drink_repository_test.dart Adds ApiDrinkRepository behavior tests.
test/domain/repositories/api_drink_repository_test.mocks.dart Generated Mockito mock for drink repository tests.
test/domain/repositories/api_festival_repository_test.dart Adds ApiFestivalRepository behavior tests.
test/domain/repositories/api_festival_repository_test.mocks.dart Generated Mockito mock for festival repository tests.
test/models_test.dart Adds Festival date/status sorting coverage.
test/services_test.dart Adds FestivalService non-200 response coverage.
test/string_formatting_helper_test.dart Covers string capitalization helper.
test/tasting_log_service_test.dart Adds TastingLogService behavior tests.
test/widgets/festival_menu_sheets_test.mocks.dart Generated Mockito mocks for festival menu sheet tests.
Comments suppressed due to low confidence (1)

test/tasting_log_service_test.dart:129

  • This test does not exercise the boundary where another festival ID begins with the target festival ID. Because the service finds keys by startsWith, a shared-prefix case is needed here to prove clearFestivalLog does not remove another festival's tasting log.
      test('removes only the targeted festival\'s logs', () async {
        await service.markAsTasted('cbf2025', 'drink-1');
        await service.markAsTasted('cbf2024', 'drink-2');

        await service.clearFestivalLog('cbf2025');

        expect(service.getTastedCount('cbf2025'), 0);
        expect(service.hasTasted('cbf2024', 'drink-2'), isTrue);
      });

Comment on lines +111 to +128
await service.markAsTasted('cbf2024', 'drink-2');

expect(service.hasTasted('cbf2025', 'drink-1'), isTrue);
expect(service.hasTasted('cbf2025', 'drink-2'), isFalse);
expect(service.hasTasted('cbf2024', 'drink-2'), isTrue);
expect(service.getTastedDrinkIds('cbf2025'), equals(['drink-1']));
expect(service.getTastedDrinkIds('cbf2024'), equals(['drink-2']));
});

group('clearFestivalLog', () {
test('removes only the targeted festival\'s logs', () async {
await service.markAsTasted('cbf2025', 'drink-1');
await service.markAsTasted('cbf2024', 'drink-2');

await service.clearFestivalLog('cbf2025');

expect(service.getTastedCount('cbf2025'), 0);
expect(service.hasTasted('cbf2024', 'drink-2'), isTrue);
@github-actions

github-actions Bot commented May 17, 2026

Copy link
Copy Markdown
Contributor

LCOV of commit 04f6179 during CI #227

Summary coverage rate:
  lines......: 81.1% (2594 of 3198 lines)
  functions..: no data found
  branches...: no data found

Files changed coverage rate:
                                                      |Lines       |Functions  |Branches    
  Filename                                            |Rate     Num|Rate    Num|Rate     Num
  ==========================================================================================
  lib/services/tasting_log_service.dart               | 0.0%     36|    -     0|    -      0

@codecov

codecov Bot commented May 17, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

The getTastedDrinkIds and clearFestivalLog methods used simple string prefix
matching (startsWith), which caused keys for festivals with overlapping IDs
like 'cbf2025' and 'cbf2025-extra' to be conflated. Replaced underscore
separator with pipe character in storage keys to prevent false positives.

This fixes a data-isolation bug where logs for one festival could leak into
or be cleared from another festival if their IDs shared a prefix.

Also add test cases for the shared-prefix edge case to verify isolation.

https://claude.ai/code/session_019w4vSjQKXKNBisd3Uzp4Ya
@richardthe3rd

Copy link
Copy Markdown
Owner Author

@copilot re-review

Copilot AI commented May 17, 2026

Copy link
Copy Markdown
Contributor

@copilot re-review

The shared-prefix edge case was already addressed in commit 04f6179:

  • Bug fix: TastingLogService now uses | as the separator in storage keys (tasting_log_cbf2025|drink-1), so prefix scanning with tasting_log_cbf2025| can never match keys for cbf2025-extra.
  • Tests added: Two new cases with overlapping festival IDs (cbf2025 / cbf2025-extra) verify that getTastedDrinkIds and clearFestivalLog both respect the boundary correctly.

All 18 TastingLogService tests pass.

@github-actions

Copy link
Copy Markdown
Contributor

🚀 Cloudflare Pages Preview

Your preview deployment is ready!

Preview URL: https://claude-improve-dart-coverage.staging-cambeerfestival.pages.dev

This preview will be automatically updated when you push new commits to this PR.

@richardthe3rd
richardthe3rd merged commit 2d47845 into main May 17, 2026
11 checks passed
@richardthe3rd
richardthe3rd deleted the claude/improve-dart-coverage-iCQSk branch May 17, 2026 20:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants