Skip to content

Commit 62b303e

Browse files
committed
Apply write normalization wrapper to tests, remove manual NFD workarounds
Now that we have proper normalization wrappers, the test base applies both: - MiniLcmWriteApiNormalizationWrapperFactory (normalizes writes to NFD) - MiniLcmApiStringNormalizationWrapperFactory (normalizes search queries to NFD) This removes the manual NFD normalization workarounds in QueryEntryTestsBase that were marked with "remove next line in #2065" comments. https://claude.ai/code/session_01MYAMRqK5NJmFkQ7a7tVkTd
1 parent b5cb3d0 commit 62b303e

2 files changed

Lines changed: 11 additions & 8 deletions

File tree

backend/FwLite/MiniLcm.Tests/MiniLcmTestBase.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,13 @@ public virtual async Task InitializeAsync()
1717
{
1818
BaseApi = await NewApi();
1919
BaseApi.Should().NotBeNull();
20-
Api = BaseApi.WrapWith([new MiniLcmApiStringNormalizationWrapperFactory()], null!);
20+
// Apply both normalization wrappers:
21+
// - Write wrapper normalizes user input to NFD on create/update
22+
// - String wrapper normalizes search queries and filter options to NFD
23+
Api = BaseApi.WrapWith([
24+
new MiniLcmWriteApiNormalizationWrapperFactory(),
25+
new MiniLcmApiStringNormalizationWrapperFactory()
26+
], null!);
2127
Api.Should().NotBeNull();
2228
}
2329

backend/FwLite/MiniLcm.Tests/QueryEntryTestsBase.cs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -353,12 +353,11 @@ public async Task SuccessfulMatches(string searchTerm, string word, bool identic
353353
{
354354
// identical is to make the test cases more readable when they only differ in their normalization
355355
(searchTerm == word).Should().Be(identical);
356-
// remove next line in https://github.com/sillsdev/languageforge-lexbox/issues/2065
357-
word = word.Normalize(NormalizationForm.FormD);
356+
// Word is stored as-is; the write normalization wrapper converts it to NFD
358357
await Api.CreateEntry(new Entry { LexemeForm = { ["en"] = word } });
359358
var words = await Api.SearchEntries(searchTerm).Select(e => e.LexemeForm["en"]).ToArrayAsync();
360359
words.Should().NotBeEmpty();
361-
// Like LicLCM the MiniLcm API should normalize to NFD
360+
// The API normalizes to NFD on write, so results should be NFD regardless of input
362361
words.Should().Contain(word.Normalize(NormalizationForm.FormD));
363362
}
364363

@@ -370,12 +369,10 @@ public async Task SuccessfulMatches(string searchTerm, string word, bool identic
370369
[InlineData("É", "È")] // Different accents
371370
public async Task NegativeMatches(string searchTerm, string word)
372371
{
373-
word = word.Normalize(NormalizationForm.FormD);
374-
//should we be normalizing the search term internally?
375-
searchTerm = searchTerm.Normalize(NormalizationForm.FormD);
372+
// Both writes and searches are normalized to NFD by the API wrappers
376373
await Api.CreateEntry(new Entry { LexemeForm = { ["en"] = word } });
377374
var words = await Api.SearchEntries(searchTerm).Select(e => e.LexemeForm["en"]).ToArrayAsync();
378-
words.Should().NotContain(word);
375+
words.Should().NotContain(word.Normalize(NormalizationForm.FormD));
379376
}
380377

381378
[Theory]

0 commit comments

Comments
 (0)