Skip to content

Add regression tests for image language fallback selection - #2

Open
devin-ai-integration[bot] wants to merge 1 commit into
masterfrom
devin/1780087410-regression-tests
Open

Add regression tests for image language fallback selection#2
devin-ai-integration[bot] wants to merge 1 commit into
masterfrom
devin/1780087410-regression-tests

Conversation

@devin-ai-integration

Copy link
Copy Markdown

Summary

Adds an xUnit test project (EmbyImageLanguageFallback.Tests) with 74 regression tests that verify the core image language fallback selection logic. Tests use reflection to invoke private methods on FallbackRemoteImageProvider without modifying the production API surface.

Test coverage includes:

  • BuildFallbackSelection — the core fallback chain (primary → fallback → neutral):
    • Primary language images selected first
    • Fallback language images used when primary is missing
    • Language-neutral images used when both primary and fallback are missing
    • Neutral images excluded when the option is disabled
    • Correct ordering across all three tiers
    • URL deduplication across tiers
    • Multiple primary/fallback languages
    • Fallback languages that overlap with primary are excluded from fallback tier
    • Empty language lists, no images, unrelated languages
  • Language alias matching — zh-CN/zh_CN/zho/chi/chinese all match "zh", ja-JP/jpn/japanese match "ja", en-US/eng/english match "en"
  • IsLanguageNeutral — null, empty, whitespace, "null", and "00" are neutral; real language codes are not
  • NormalizeLanguage — maps aliases to canonical forms (e.g., "chinese" → "zh-Hans", "jpn" → "ja")
  • LanguageMatches — case-insensitive matching, display language fallback behavior
  • RewriteSelectedFallbackImages — fallback images rewritten to English, primary images preserved
  • PluginOptions.GetCanonicalLanguageValue / GetLanguageAliases — canonical resolution and alias expansion

Changes to main project:

  • Added DefaultItemExcludes to EmbyImageLanguageFallback.csproj to prevent the test directory from being compiled into the main project (standard SDK-style project layout fix)

Review & Testing Checklist for Human

  • Run dotnet test EmbyImageLanguageFallback.Tests/ and verify all 74 tests pass
  • Verify the main project still builds cleanly: dotnet build EmbyImageLanguageFallback.csproj
  • Spot-check that the DefaultItemExcludes change doesn't affect the main project's compiled output

Notes

  • Tests use FormatterServices.GetUninitializedObject to create FallbackRemoteImageProvider instances without calling the constructor (avoids Emby DI dependencies). The SYSLIB0050 warning for this obsolete API is suppressed in the test project only.
  • No production code logic was changed — only the .csproj exclude and the solution file were updated.

Link to Devin session: https://app.devin.ai/sessions/2e10bf48b0e649a6a2667d1359b78c49
Requested by: @JustDreemurr

- Add xUnit test project (EmbyImageLanguageFallback.Tests)
- 74 tests covering BuildFallbackSelection, NormalizeLanguage,
  IsLanguageNeutral, LanguageMatches, RewriteSelectedFallbackImages,
  and PluginOptions language canonicalization
- Tests verify fallback chain: primary -> fallback -> neutral
- Tests cover missing primary/fallback scenarios, language alias
  matching (zh/ja/en variants), deduplication, and rewrite behavior
- Exclude test directory from main project compilation

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@devin-ai-integration

Copy link
Copy Markdown
Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

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.

1 participant