Skip to content

Add missing Word Controller/Service tests#4151

Merged
imnasnainaec merged 9 commits intomasterfrom
backend-tests-more
Feb 20, 2026
Merged

Add missing Word Controller/Service tests#4151
imnasnainaec merged 9 commits intomasterfrom
backend-tests-more

Conversation

@imnasnainaec
Copy link
Copy Markdown
Collaborator

@imnasnainaec imnasnainaec commented Feb 16, 2026

This change is Reviewable

Summary by CodeRabbit

  • Tests
    • Expanded coverage for word restore and frontier workflows, including restoring a word already present.
    • Added frontier-deletion scenarios: deletion that moves an entry into the main list and clears the frontier, and no-op when not present.
    • Standardized positive-path assertions to explicit OK results and added nullability/value checks.
    • Split frontier/is-in-frontier checks into separate true/false tests and clarified test names for expected outcomes.

@imnasnainaec imnasnainaec self-assigned this Feb 16, 2026
@imnasnainaec imnasnainaec added the 🟩Low Low-priority PR label Feb 16, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Feb 16, 2026

Warning

Rate limit exceeded

@imnasnainaec has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 18 minutes and 38 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📝 Walkthrough

Walkthrough

Refactors controller tests to consistently unwrap OkObjectResult and assert on Value; splits boolean test cases into true/false variants; adds a restore-in-frontier test. Renames and adds service tests covering DeleteFrontierWord behaviors and null/true return paths.

Changes

Cohort / File(s) Summary
Controller Tests
Backend.Tests/Controllers/WordControllerTests.cs
Converted many assertions to explicitly use OkObjectResult and validate Value; split TestHasFrontierWords and TestIsInFrontier into separate true/false tests; added TestRestoreWordAlreadyInFrontier; adjusted history, frontier, ID, and collection assertions.
Service Tests
Backend.Tests/Services/WordServiceTests.cs
Renamed several tests for clearer return expectations and added tests for DeleteFrontierWord behavior (...CopiesToWordsAndRemovesFrontier, ...NotInFrontierReturnsNull); updated assertions for IDs, history, and frontier/list consistency.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • jasonleenaylor

Poem

🐇 I hopped through tests both old and new,

Unwrapped each result to find what's true;
Frontier crumbs I counted twice,
Copied, removed — assertions nice,
A little hop, a passing chew.

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding missing test cases for Word Controller and Word Service components.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch backend-tests-more

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.

imnasnainaec added a commit that referenced this pull request Feb 16, 2026
@codecov
Copy link
Copy Markdown

codecov bot commented Feb 16, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 86.07%. Comparing base (06ea69d) to head (1e607c1).
⚠️ Report is 4 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff             @@
##           master    #4151       +/-   ##
===========================================
+ Coverage   74.75%   86.07%   +11.31%     
===========================================
  Files         302       56      -246     
  Lines       11083     4839     -6244     
  Branches     1394      603      -791     
===========================================
- Hits         8285     4165     -4120     
+ Misses       2394      528     -1866     
+ Partials      404      146      -258     
Flag Coverage Δ
backend 86.07% <ø> (ø)
frontend ?

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@jasonleenaylor
Copy link
Copy Markdown
Contributor

Backend.Tests/Services/WordServiceTests.cs line 101 at r1 (raw file):

            var deletedWord = _wordRepo.GetWord(ProjId, deletedId!).Result;
            Assert.That(deletedWord, Is.Not.Null);
            Assert.That(deletedWord!.Accessibility, Is.EqualTo(Status.Deleted));

If fixable (same as other recent review) please fix

@imnasnainaec imnasnainaec marked this pull request as draft February 17, 2026 21:48
@imnasnainaec imnasnainaec marked this pull request as ready for review February 18, 2026 19:02
@imnasnainaec imnasnainaec marked this pull request as draft February 18, 2026 21:11
@imnasnainaec imnasnainaec marked this pull request as ready for review February 19, 2026 20:39
@imnasnainaec imnasnainaec marked this pull request as draft February 19, 2026 22:05
@imnasnainaec imnasnainaec marked this pull request as ready for review February 19, 2026 22:05
Copy link
Copy Markdown
Contributor

@jasonleenaylor jasonleenaylor left a comment

Choose a reason for hiding this comment

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

:lgtm:

@jasonleenaylor reviewed 2 files and all commit messages, and made 1 comment.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on imnasnainaec).

Copy link
Copy Markdown

@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.

🧹 Nitpick comments (1)
Backend.Tests/Controllers/WordControllerTests.cs (1)

104-106: Apply null-forgiving ! after null assertions — pervasive CS8602 pattern

Every changed test follows the pattern:

var result = await _wordController.Xxx(...) as OkObjectResult;   // OkObjectResult?
Assert.That(result, Is.Not.Null);                                // compiler flow unaffected
Assert.That(result.Value, Is.True);                              // CS8602: result is still OkObjectResult?

The compiler does not narrow the type through NUnit assertion calls, so every .Value, .Count, or indexer access on the un-suffixed nullable produces CS8602/CS8604 warnings. The service-test file's existing lines 76–77 already use the correct result!. convention.

Affected variables (representative, not exhaustive): result, countResult, frontier, reverted, id, updatedWord.

🛠️ Representative fix pattern (apply to all similar occurrences)
-            var result = await _wordController.HasFrontierWords(ProjId) as OkObjectResult;
+            var result = await _wordController.HasFrontierWords(ProjId) as OkObjectResult;
             Assert.That(result, Is.Not.Null);
-            Assert.That(result.Value, Is.False);
+            Assert.That(result!.Value, Is.False);

For intermediate typed variables:

-            var frontier = result.Value as List<Word>;
+            var frontier = result!.Value as List<Word>;
             Assert.That(frontier, Is.Not.Null);
-            Assert.That(frontier, Has.Count.EqualTo(2));
+            Assert.That(frontier!, Has.Count.EqualTo(2));

Also applies to: 114-116, 131-133, 140-142, 161-163, 183-185, 233-235, 242-244, 272-274, 302-304, 344-346, 375-377, 421-422, 436-438

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@Backend.Tests/Controllers/WordControllerTests.cs` around lines 104 - 106, The
tests assign controller responses to nullable locals (e.g., result, countResult,
frontier, reverted, id, updatedWord) using "as OkObjectResult" and then
Assert.That(..., Is.Not.Null) but the compiler doesn't recognize NUnit's
assertion, so add the null-forgiving operator when dereferencing these variables
(e.g., change result.Value to result!.Value) throughout the file; update all
occurrences where properties or indexers are accessed after an Assert.That(...,
Is.Not.Null) for methods like _wordController.HasFrontierWords, Count/Index
assertions, GetFrontier, RevertWord, UpdateWord, etc., to use the pattern
variable! before .Value, .Count or index access to silence CS8602/CS8604
warnings.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@Backend.Tests/Controllers/WordControllerTests.cs`:
- Around line 104-106: The tests assign controller responses to nullable locals
(e.g., result, countResult, frontier, reverted, id, updatedWord) using "as
OkObjectResult" and then Assert.That(..., Is.Not.Null) but the compiler doesn't
recognize NUnit's assertion, so add the null-forgiving operator when
dereferencing these variables (e.g., change result.Value to result!.Value)
throughout the file; update all occurrences where properties or indexers are
accessed after an Assert.That(..., Is.Not.Null) for methods like
_wordController.HasFrontierWords, Count/Index assertions, GetFrontier,
RevertWord, UpdateWord, etc., to use the pattern variable! before .Value, .Count
or index access to silence CS8602/CS8604 warnings.

Copy link
Copy Markdown
Contributor

@jasonleenaylor jasonleenaylor left a comment

Choose a reason for hiding this comment

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

:lgtm:

@jasonleenaylor reviewed 1 file and all commit messages, and made 1 comment.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on imnasnainaec).

@imnasnainaec imnasnainaec merged commit ea93cbd into master Feb 20, 2026
16 checks passed
@imnasnainaec imnasnainaec deleted the backend-tests-more branch February 20, 2026 19:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants