test(668): red-first pin for accented values on EF-sourced facet fields

Stored 'Édith' is unreachable from q=é and q=É on SQLite, because SQL
LOWER() folds ASCII only. The stored-LOWERCASE pair is pinned alongside
it and passes today, so the fix must supplement that path, not replace it.

Red: both uppercase cases return []. Refs #668
This commit is contained in:
2026-07-27 20:08:39 +02:00
parent aa1f504e02
commit 61aa8a902a
@@ -653,4 +653,57 @@ public class GetSearchFieldValuesHandlerTests
result.IsSome.ShouldBeTrue();
result.IfSome(r => r.Values.ShouldBe(new List<string> { "Action" }));
}
/// <summary>
/// ersatztv#668. The EF-sourced fields prefix-match through SQL <c>LOWER()</c>, which on SQLite folds
/// ASCII only: <c>lower('Édith')</c> returns <c>'Édith'</c> unchanged, so a stored value whose
/// prefix carries an uppercase non-ASCII character is unreachable from any query long enough to reach it.
/// The stored-LOWERCASE case already worked (the handler lowercases the query before it reaches SQL, so
/// both casings of the query fold to the same pattern) and is pinned alongside it, because the fix must
/// SUPPLEMENT that path rather than replace it.
/// </summary>
[TestCase("genre", "é")]
[TestCase("genre", "É")]
public async Task Ef_Sourced_Stored_Uppercase_Accent_Is_Reachable(string field, string query)
{
await using (TvContext context = _db.CreateContext())
{
context.Set<Genre>().AddRange(
new Genre { Name = "Édith" },
new Genre { Name = "Zulu" });
await context.SaveChangesAsync();
}
var handler = new GetSearchFieldValuesHandler(_db.Factory);
Option<SearchFieldValuesResponseModel> result = await handler.Handle(
new GetSearchFieldValues(field, query, 50),
CancellationToken.None);
result.IsSome.ShouldBeTrue();
result.IfSome(r => r.Values.ShouldBe(new List<string> { "Édith" }));
}
/// <inheritdoc cref="Ef_Sourced_Stored_Uppercase_Accent_Is_Reachable" />
[TestCase("genre", "é")]
[TestCase("genre", "É")]
public async Task Ef_Sourced_Stored_Lowercase_Accent_Stays_Reachable(string field, string query)
{
await using (TvContext context = _db.CreateContext())
{
context.Set<Genre>().AddRange(
new Genre { Name = "édith" },
new Genre { Name = "Zulu" });
await context.SaveChangesAsync();
}
var handler = new GetSearchFieldValuesHandler(_db.Factory);
Option<SearchFieldValuesResponseModel> result = await handler.Handle(
new GetSearchFieldValues(field, query, 50),
CancellationToken.None);
result.IsSome.ShouldBeTrue();
result.IfSome(r => r.Values.ShouldBe(new List<string> { "édith" }));
}
}