Skip to content

Conversation

@myieye
Copy link
Collaborator

@myieye myieye commented Oct 28, 2025

CanSyncRandomEntries() now:

  • Runs against FwApi as well
  • Includes moves and positional creates for components (already had deletes and creates)
  • Includes moves, positional creates and deletes for example-sentences (only had creates as part of a new sense)
  • Includes moves and positional creates for complex-forms even though those don't have any effect (already had deletes and creates)
  • Round-trips data through each api first, so that we actually sync realistic data (Not doing this has let bugs slip through. Fix sync issue due to reading component Id from FLEx components #1972 was a thorough fix and yet still missed things that were handled in 93cfc05 (#2072). The changes in this PR would have picked those all up).
  • Covers different headword handling (implicitly by both running against and round-tripping through both APIs.)

LcmHelpers.LexEntryHeadword needed to be made "stable" by using BestVernacularAlternative instead of the first string, which is not strictly related to the configured order of Writing-Systems.
This only made the test consistently green, because the WSs created by the fixture are explicitly ordered alphabetically. fwdata respects the actual order while crdts depend on alphabetical order. Yeah, not so good.
We should probably be using HeadWord instead of BestVernacularAlternative, but null handling in the case of empty ws-values should be uniform across fwdata and crdt. So, BestVernacularAlternative seemed like a slightly more uniform choice for the time being.

This PR exposed the fact that there are big holes in our current handling of headwords. So, I at least added a link to an issue in comments here and here.

- Runs against FwApi as well
- Include moves and positional creates (components, example, complex-forms)
- Round-trip data through each api so it's realistic
@github-actions github-actions bot added the 💻 FW Lite issues related to the fw lite application, not miniLcm or crdt related label Oct 28, 2025
@coderabbitai
Copy link

coderabbitai bot commented Oct 28, 2025

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

📝 Walkthrough

Walkthrough

The PR refactors test infrastructure by introducing ExtraWritingSystemsSyncFixture for multi-system writing support, updates string retrieval in LcmHelpers to use BestVernacularAlternative, changes LexEntryHeadwordOrUnknown return type from nullable to non-nullable, and enhances test helpers for entry creation and multi-string generation across writing systems.

Changes

Cohort / File(s) Summary
Test Fixture Infrastructure
backend/FwLite/FwLiteProjectSync.Tests/Fixtures/SyncFixture.cs, backend/FwLite/FwLiteProjectSync.Tests/EntrySyncTests.cs
Added new ExtraWritingSystemsSyncFixture class extending SyncFixture with support for multiple vernacular writing systems; updated EntrySyncTestsBase to use new fixture; changed CrdtEntrySyncTests and FwDataEntrySyncTests constructors to accept ExtraWritingSystemsSyncFixture; added ApiType enum; introduced comprehensive CanSyncRandomEntries test with round-trip validation logic; added FwDataApiDoesNotUpdateMorphType test.
String Retrieval & Return Types
backend/FwLite/FwDataMiniLcmBridge/Api/LcmHelpers.cs
Replaced GetStringFromIndex(0, out var _) fallbacks with BestVernacularAlternative for citation and lexeme form retrieval; updated LexEntryHeadwordOrUnknown method signature to return non-nullable string instead of string?.
Test Data Generation Helpers
backend/FwLite/MiniLcm.Tests/AutoFakerHelpers/EntryFakerHelper.cs
Added public PrepareToCreateEntry helper method for entry creation workflow; added ExampleSentence helper; explicitly marked CreateComplexFormComponentEntry, CreateComplexFormTypes, and CreatePublications as private; enhanced complex form/component creation with deterministic headword assignment and sense population.
Multi-String Override Logic
backend/FwLite/MiniLcm.Tests/AutoFakerHelpers/MultiStringOverride.cs
Refactored null initialization using pattern matching; replaced per-call loops with writing-system-centric generation; added validation for non-empty writing systems and randomized writing system selection based on available count.
Documentation & Cleanup
backend/FwLite/MiniLcm/Models/Entry.cs, backend/FwLite/LcmCrdt/CrdtMiniLcmApi.cs
Added inline comment referencing external issue in Entry.Headword() calculation; removed test-related comment from DeleteComplexFormComponent.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

  • Areas requiring extra attention:
    • CanSyncRandomEntries test logic including cross-API round-trip mutations and CRDT/FwData equivalence assertions
    • ExtraWritingSystemsSyncFixture initialization and writing system setup to ensure test isolation and repeatability
    • PrepareToCreateEntry helper refactoring and its integration with sense/component/form creation workflows
    • LexEntryHeadwordOrUnknown return type change from nullable to non-nullable and its impact on existing call sites throughout the codebase
    • Writing-system selection logic changes in MultiStringOverride to verify randomization and coverage correctness

Possibly related PRs

Suggested reviewers

  • hahn-kev
  • rmunn

Poem

🐰 Whiskers twitching with delight,
Through sync fixtures, writing systems bright,
Headwords hop from string to form,
Multi-writes in every norm,
Tests now dance cross-API free,
Better than carrots—these changes glee! 🥕✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 12.50% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Title Check ✅ Passed The PR title "Make CanSyncRandomEntries more robust" directly references the primary change in the pull request—the enhancement of the CanSyncRandomEntries test method. According to the raw_summary, the main modifications include adding a new comprehensive test with the ApiType enum, round-trip capability through the roundTripApiType parameter, and expanded mutation logic for components, example sentences, and complex forms. The title is concise (4 words), specific (mentions the exact test name), and accurately captures the intent of making the test more comprehensive and resilient. It aligns well with the PR objectives which emphasize running the test against more APIs and testing more operations to catch realistic sync issues.
Description Check ✅ Passed The pull request description is clearly related to the changeset and provides meaningful information about the modifications. It specifically addresses the major changes including the enhanced CanSyncRandomEntries() test with expanded functionality (moves, positional creates/deletes for components, example-sentences, and complex-forms), the round-tripping of data through APIs, and the changes to headword handling in LcmHelpers.cs using BestVernacularAlternative. The description explains the rationale for these changes, references related issues and commits, and discusses the fixture modifications needed to support the new test behavior. This aligns well with the file-level changes shown in the raw summary across multiple test and helper files.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@argos-ci
Copy link

argos-ci bot commented Oct 28, 2025

The latest updates on your projects. Learn more about Argos notifications ↗︎

Build Status Details Updated (UTC)
default (Inspect) ✅ No changes detected - Nov 3, 2025, 3:52 PM

@github-actions
Copy link

github-actions bot commented Oct 28, 2025

UI unit Tests

  1 files   45 suites   18s ⏱️
111 tests 111 ✅ 0 💤 0 ❌
160 runs  160 ✅ 0 💤 0 ❌

Results for commit 21d0695.

♻️ This comment has been updated with latest results.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
backend/FwLite/MiniLcm.Tests/AutoFakerHelpers/MultiStringOverride.cs (1)

42-67: Fix invariant: ensure all RichSpans use the key writing system.

Some spans come from AutoFaker and may have Ws ≠ writingSystemId, producing inconsistent RichMultiString states. This can leak cross‑WS spans into a single alternative and cause round‑trip surprises. Force Ws to writingSystemId for every span.

-                else
-                {
-                    spans.Add(context.AutoFaker.Generate<RichSpan>());
-                }
+                else
+                {
+                    var span = context.AutoFaker.Generate<RichSpan>();
+                    span.Ws = writingSystemId; // keep spans consistent with the key
+                    spans.Add(span);
+                }

Optionally also de‑dupe WS picks here as in MultiStringOverride.

🧹 Nitpick comments (4)
backend/FwLite/MiniLcm/Models/Entry.cs (1)

36-41: Consider aligning headword selection and trimming with LCM helpers.

MiniLcm Entry.Headword() picks the first string ordered by Ws code and uses default Trim, while LcmHelpers prefers BestVernacularAlternative and trims with an extended whitespace set. For cross-API consistency, consider mirroring the selection/trim semantics here (or centralize in a shared helper).

backend/FwLite/FwDataMiniLcmBridge/Api/LcmHelpers.cs (1)

24-31: Lexeme form path mirrors citation fix — LGTM.

Null-safe access and trimming look right. Minor: consider caching entry.LexemeFormOA?.Form into a local to avoid double property access.

backend/FwLite/MiniLcm.Tests/AutoFakerHelpers/MultiStringOverride.cs (1)

18-24: Deduplicate selected writing systems to avoid silent overwrites.

Random.ListItems may return duplicates; duplicates just overwrite in the dictionary and reduce variability. Apply Distinct() when selecting WS.

-        var writingSystems = context.Faker.Random.ListItems(validWritingSystems, count);
+        var writingSystems = context.Faker.Random.ListItems(validWritingSystems, count)
+            .Distinct()
+            .ToArray();
backend/FwLite/FwLiteProjectSync.Tests/EntrySyncTests.cs (1)

77-216: CanSyncRandomEntries: strong, realistic coverage; a couple of nits.

  • Round-trip path first prepares both before/after — smart to avoid duplicate-related creation conflicts.
  • Assertions account for current API gaps (headwords in CRDT; MorphType in FWData). Good.

Nits:

  • When shuffling and ListItems’ing, duplicates can slip in; consider Distinct() to reduce flakiness.
  • If headword semantics change (e.g., aligning MiniLcm with LCM helpers), revisit the exclusions around ComponentHeadword/ComplexFormHeadword for CRDT.
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 23a672a and f14514a.

📒 Files selected for processing (7)
  • backend/FwLite/FwDataMiniLcmBridge/Api/LcmHelpers.cs (1 hunks)
  • backend/FwLite/FwLiteProjectSync.Tests/EntrySyncTests.cs (3 hunks)
  • backend/FwLite/FwLiteProjectSync.Tests/Fixtures/SyncFixture.cs (3 hunks)
  • backend/FwLite/LcmCrdt/CrdtMiniLcmApi.cs (0 hunks)
  • backend/FwLite/MiniLcm.Tests/AutoFakerHelpers/EntryFakerHelper.cs (2 hunks)
  • backend/FwLite/MiniLcm.Tests/AutoFakerHelpers/MultiStringOverride.cs (2 hunks)
  • backend/FwLite/MiniLcm/Models/Entry.cs (1 hunks)
💤 Files with no reviewable changes (1)
  • backend/FwLite/LcmCrdt/CrdtMiniLcmApi.cs
🧰 Additional context used
🧬 Code graph analysis (5)
backend/FwLite/FwDataMiniLcmBridge/Api/LcmHelpers.cs (1)
backend/FwLite/LcmCrdt/FullTextSearch/EntrySearchService.cs (1)
  • CitationForm (84-90)
backend/FwLite/FwLiteProjectSync.Tests/Fixtures/SyncFixture.cs (2)
backend/FwLite/LcmCrdt/CrdtMiniLcmApi.cs (12)
  • Task (48-53)
  • Task (55-59)
  • Task (67-76)
  • Task (78-89)
  • Task (91-99)
  • Task (101-105)
  • Task (107-115)
  • Task (117-121)
  • Task (132-136)
  • Task (138-143)
  • Task (145-152)
  • Task (154-158)
backend/FwLite/LcmCrdt/LcmCrdtKernel.cs (1)
  • Task (309-313)
backend/FwLite/MiniLcm.Tests/AutoFakerHelpers/MultiStringOverride.cs (4)
backend/FwLite/FwDataMiniLcmBridge/Api/FwDataMiniLcmApi.cs (2)
  • MultiString (796-818)
  • RichMultiString (820-839)
backend/LfClassicData/LfClassicMiniLcmApi.cs (2)
  • MultiString (347-357)
  • RichMultiString (359-369)
backend/FwLite/MiniLcm.Tests/WritingSystemCodes.cs (1)
  • WritingSystemCodes (5-8)
backend/FwLite/MiniLcm/Models/RichMultiString.cs (4)
  • RichMultiString (13-15)
  • RichMultiString (17-19)
  • RichMultiString (27-37)
  • RichMultiString (171-184)
backend/FwLite/MiniLcm.Tests/AutoFakerHelpers/EntryFakerHelper.cs (3)
backend/FwLite/MiniLcm/Models/Entry.cs (2)
  • Entry (44-70)
  • Headword (34-42)
backend/FwLite/FwDataMiniLcmBridge/Api/FwDataMiniLcmApi.cs (9)
  • Entry (643-672)
  • ExampleSentence (780-794)
  • Sense (763-778)
  • IList (1204-1214)
  • ComplexFormComponent (716-726)
  • ComplexFormComponent (730-741)
  • Order (743-761)
  • ComplexFormType (489-492)
  • Publication (352-361)
backend/FwLite/MiniLcm/Models/Sense.cs (2)
  • Sense (7-54)
  • Sense (38-53)
backend/FwLite/FwLiteProjectSync.Tests/EntrySyncTests.cs (4)
backend/FwLite/FwLiteProjectSync.Tests/Fixtures/SyncFixture.cs (8)
  • ExtraWritingSystemsSyncFixture (13-44)
  • SyncFixture (46-121)
  • SyncFixture (60-60)
  • SyncFixture (62-71)
  • SyncFixture (73-75)
  • Task (21-43)
  • Task (77-105)
  • Task (107-111)
backend/FwLite/FwDataMiniLcmBridge/Api/LcmHelpers.cs (1)
  • MorphType (88-117)
backend/FwLite/MiniLcm/SyncHelpers/EntrySync.cs (1)
  • EntrySync (8-327)
backend/FwLite/MiniLcm.Tests/AutoFakerHelpers/AutoFakerDefault.cs (4)
  • AutoFakerDefault (10-82)
  • Generate (72-80)
  • Generate (88-91)
  • Generate (103-106)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
  • GitHub Check: Build FwHeadless / publish-fw-headless
  • GitHub Check: frontend
  • GitHub Check: frontend-component-unit-tests
  • GitHub Check: Build FW Lite and run tests
  • GitHub Check: Analyze (csharp)
🔇 Additional comments (9)
backend/FwLite/FwDataMiniLcmBridge/Api/LcmHelpers.cs (2)

16-21: Good switch to BestVernacularAlternative for citation form.

This is safer than GetStringFromIndex(0) and matches user WS intent. Ensure BestVernacularAlternative is non-null when only non‑vernacular strings exist; current null‑aware handling looks correct.


33-37: Non-null return for LexEntryHeadwordOrUnknown — good API tightening.

Returning UnknownHeadword eliminates nullable churn at call sites. Confirm all usages compiled cleanly after the signature change.

backend/FwLite/MiniLcm.Tests/AutoFakerHelpers/MultiStringOverride.cs (1)

11-17: Preinit pattern and WS guard look good.

Nice use of pattern matching and explicit check against empty WS arrays.

backend/FwLite/MiniLcm.Tests/AutoFakerHelpers/EntryFakerHelper.cs (1)

21-61: Helper extraction reads well.

Centralizing entry preparation reduces duplication and makes the tests clearer.

backend/FwLite/FwLiteProjectSync.Tests/Fixtures/SyncFixture.cs (2)

13-44: Extra writing systems fixture — nice enhancement.

Creating ES/FR in FW and ensuring a default vernacular exists in CRDT unblocks entry queries and broadens coverage.


53-54: Minor fixture polish.

DefaultVernacularWritingSystem constant and making InitializeAsync virtual improve reuse. Using DefaultVernacularWritingSystem in NewProject keeps setup consistent.

Also applies to: 77-97

backend/FwLite/FwLiteProjectSync.Tests/EntrySyncTests.cs (3)

13-27: Fixture swap to ExtraWritingSystemsSyncFixture — LGTM.

Keeps CRDT and FWData cases aligned and simplifies setup.


28-49: FwDataApiDoesNotUpdateMorphType test is clear and valuable.

Good sentinel to catch future behavior changes.


68-76: Enum ApiType for round-trips — good clarity.

Simple and self-documenting.

@myieye myieye merged commit 0bacb18 into develop Nov 4, 2025
19 checks passed
@myieye myieye deleted the test-syncing-random-lcm-entries-into-crdt branch November 4, 2025 09:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

💻 FW Lite issues related to the fw lite application, not miniLcm or crdt related

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants