Files
ersatztv/ErsatzTV.Tests/Application/Health/HealthMapperTests.cs
T
timothyandClaude Opus 4.8 ed6c43065f
Build ErsatzTV Image / CI image pin matches docker/ci (pull_request) Successful in 5s
Build ErsatzTV Image / Docs update reminder (pull_request) Successful in 8s
Build ErsatzTV Image / decisions.md append-only (pull_request) Successful in 54s
Build ErsatzTV Image / EF migration integrity (SQLite + MySql) (pull_request) Successful in 5m48s
Build ErsatzTV Image / API docs in sync (OpenAPI + endpoint index) (pull_request) Successful in 12m49s
Build ErsatzTV Image / Functional E2E (curl contracts) (pull_request) Successful in 14m35s
Build ErsatzTV Image / Build & test (.NET) (pull_request) Successful in 18m11s
Build ErsatzTV Image / Build & push image (amd64) (pull_request) Has been skipped
Build ErsatzTV Image / Formatting (changed .cs conform to .editorconfig) (pull_request) Successful in 13m23s
feat(164): guided remediation for health checks (server-declared {Kind, Target})
Make the ~14 health checks actionable: each check that has a fix now declares
where to go, and the SPA acts on it.

Backend:
- Widen domain HealthCheckLink (string Link) -> (string Target, HealthCheckLinkKind
  Kind) with ExternalDoc|AppRoute + factories; only the 4 link-building checks and
  the API mapper touched .Link.
- Evolve HealthCheckResponseModel additively (/api/v1 frozen-additive): keep
  deprecated string? Link (still populated), add Brief (the BriefMessage the mapper
  was silently dropping) and nested Remediation {Kind, Target}. Kind is a mapped
  string, not a wire enum.
- Make Mapper.GetStatus total: NotApplicable no longer throws (defensive; handler
  still filters it). InternalsVisibleTo(ErsatzTV.Tests) added to unit-test totality.
- Fix 2 stale Blazor route links (media/trash -> /app/trash, search?query ->
  /app/search); add AppRoute remediation to actionable checks that had none
  (libraries / schedules / ffmpeg-profiles / settings).

SPA:
- DashboardScreen health panel renders remediation: AppRoute -> client-side nav
  button, ExternalDoc -> new-tab anchor; detail text truncates with title-hover.
- Remove the dead "Open Classic UI" -> /system/health row from SettingsScreen
  (a #91b leftover that just 302'd to /app); update its regression test.

Docs: decisions.md (#164), api-conventions.md (deprecate-in-place DTO evolution),
blazor-route-parity.md (Section 4 correction); v1.json/v1.d.ts/endpoint-index
regenerated.

fixes #164

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-18 00:51:40 +02:00

43 lines
1.4 KiB
C#

using ErsatzTV.Application.Health;
using ErsatzTV.Core.Api.Health;
using ErsatzTV.Core.Health;
using LanguageExt;
using NUnit.Framework;
using Shouldly;
namespace ErsatzTV.Tests.Application.Health;
[TestFixture]
public class HealthMapperTests
{
[Test]
public void ProjectToResponseModel_Should_Map_NotApplicable_Without_Throwing()
{
// The handler filters NotApplicable before mapping today, but the mapper must be
// total so a future caller that skips the filter can't 500 the endpoint (#164).
var result = new HealthCheckResult(
"NA Check",
HealthCheckStatus.NotApplicable,
"skip",
"skip",
Option<HealthCheckLink>.None);
HealthCheckResponseModel model = Should.NotThrow(() => Mapper.ProjectToResponseModel(result));
model.Status.ShouldBe("notApplicable");
}
[Test]
[TestCase(HealthCheckStatus.Pass, "pass")]
[TestCase(HealthCheckStatus.Fail, "fail")]
[TestCase(HealthCheckStatus.Warning, "warn")]
[TestCase(HealthCheckStatus.Info, "info")]
[TestCase(HealthCheckStatus.NotApplicable, "notApplicable")]
public void ProjectToResponseModel_Should_Map_Every_Status(HealthCheckStatus status, string expected)
{
var result = new HealthCheckResult("Check", status, "m", "b", Option<HealthCheckLink>.None);
Mapper.ProjectToResponseModel(result).Status.ShouldBe(expected);
}
}