Skip to content

Update audio tests#4153

Merged
imnasnainaec merged 11 commits intomasterfrom
backend-audio-tests
Feb 20, 2026
Merged

Update audio tests#4153
imnasnainaec merged 11 commits intomasterfrom
backend-audio-tests

Conversation

@imnasnainaec
Copy link
Copy Markdown
Collaborator

@imnasnainaec imnasnainaec commented Feb 16, 2026

This change is Reviewable

Summary by CodeRabbit

  • Tests
    • Strengthened audio upload/download/delete tests: now assert returned result instances, verify creation of replacement words when audio is removed, ensure new IDs differ from originals, and confirm frontier contains the expected single entry with correct audio/state.
    • General test improvements: switched to explicit synchronization, added null/not-null and history/metadata assertions, and added repository cleanup to reset test state.

@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 2 minutes and 40 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

Tests updated to reflect upload/delete flows that return a new frontier word (new ID) instead of mutating the original; assertions changed from strict type checks to instance checks; service tests switch some async .Result usages to .Wait() and add explicit null/history/EditedBy/UsingCitationForm assertions.

Changes

Cohort / File(s) Summary
Audio Controller Tests
Backend.Tests/Controllers/AudioControllerTests.cs
Replaced Is.TypeOf assertions with Is.InstanceOf; cast controller responses to OkObjectResult and extract newId; verify newId != original wordId, fetch word by newId, assert non-empty Audio on upload and frontier contains single entry with matching Id and empty Audio after delete; added repository cleanup Wait() calls.
Word Service Tests
Backend.Tests/Services/WordServiceTests.cs
Replaced .Result with .Wait() for repository creates; updated tests to expect creation of a new word on audio deletion/update (new Id), assert EditedBy, History.Last() == oldId, frontier count == 1, UsingCitationForm flags, and explicit null checks; minor formatting/null-check adjustments.

Sequence Diagram(s)

mermaid
sequenceDiagram
participant Test
participant AudioController
participant WordService
participant Repository
Test->>AudioController: Send Upload/Delete audio (userId, wordId)
AudioController->>WordService: Call Upload/Delete (userId, wordId)
WordService->>Repository: Create new word / update frontier (persist)
Repository-->>WordService: return newWord / newId
WordService-->>AudioController: return OkObjectResult(newId)
AudioController-->>Test: 200 OK with newId
Test->>Repository: Fetch word by newId / GetFrontier
Repository-->>Test: Word / Frontier (Id == newId, Audio empty for frontier)

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • jasonleenaylor

Poem

🐇 I hopped through tests with a thump and a grin,

Old audio removed — a new id tucked in.
Frontier now holds the freshest seed,
History kept, and edits proceed.
🥕 Hooray — I danced a tiny rabbit spin!

🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

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.
Title check ❓ Inconclusive The title "Update audio tests" is vague and generic. It describes the general category of change (updating tests related to audio) but lacks specificity about what was actually updated or why. Consider a more specific title that describes the primary change, such as "Refactor audio controller and service tests to use instance-based assertions" or "Update audio tests with improved result handling and frontier validation".
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ 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-audio-tests

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.

@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 (30b5b90) to head (2d810f5).
⚠️ Report is 6 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff             @@
##           master    #4153       +/-   ##
===========================================
+ Coverage   74.76%   86.07%   +11.30%     
===========================================
  Files         302       56      -246     
  Lines       11087     4839     -6248     
  Branches     1394      603      -791     
===========================================
- Hits         8289     4165     -4124     
+ Misses       2394      528     -1866     
+ Partials      404      146      -258     
Flag Coverage Δ
backend 86.07% <ø> (-0.02%) ⬇️
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.

coderabbitai[bot]

This comment was marked as resolved.

@imnasnainaec imnasnainaec marked this pull request as draft February 17, 2026 17:50
@imnasnainaec imnasnainaec marked this pull request as ready for review February 17, 2026 17:50
@jasonleenaylor
Copy link
Copy Markdown
Contributor

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

            // New word is correct
            Assert.That(newWord, Is.Not.Null);
            Assert.That(newWord!.Id, Is.Not.EqualTo(oldId));

See if we can avoid this, as this is clearly impossible given the line above.

@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 18:53
coderabbitai[bot]

This comment was marked as resolved.

@imnasnainaec imnasnainaec marked this pull request as draft February 18, 2026 19:24
@imnasnainaec imnasnainaec marked this pull request as draft February 18, 2026 19:24
@imnasnainaec imnasnainaec marked this pull request as ready for review February 18, 2026 20:26
coderabbitai[bot]

This comment was marked as resolved.

@imnasnainaec imnasnainaec marked this pull request as draft February 18, 2026 21:11
@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:15
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.

Actionable comments posted: 1

🧹 Nitpick comments (2)
Backend.Tests/Services/WordServiceTests.cs (1)

75-97: Consider asserting newWord.Audio is empty — the primary effect of DeleteAudio is untested.

The test verifies all the side-effects (frontier state, history, EditedBy, word count, old-word preservation) but never directly asserts that the audio entry was actually removed from the returned word. A single assertion would close this gap:

🛠️ Proposed addition
     Assert.That(newWord, Is.Not.Null);
     Assert.That(newWord.Id, Is.Not.EqualTo(oldId));
+    Assert.That(newWord.Audio, Is.Empty);
     Assert.That(newWord.EditedBy.Last(), Is.EqualTo(UserId));
     Assert.That(newWord.History.Last(), Is.EqualTo(oldId));
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@Backend.Tests/Services/WordServiceTests.cs` around lines 75 - 97, Add an
assertion that the returned newWord has no audio entries to verify DeleteAudio's
primary effect: update the test in WordServiceTests (the DeleteAudio scenario)
to assert newWord.Audio is empty (e.g., Assert.That(newWord.Audio, Is.Empty) or
Assert.That(newWord.Audio.Count, Is.EqualTo(0)); keep the existing assertions
about frontier, history, and oldWord intact.
Backend.Tests/Controllers/AudioControllerTests.cs (1)

177-198: Consider adding a history assertion for the superseded word (oldId).

The test now validates frontier state well. However, since DeleteAudioFile creates a new word entry (newId), the old word (oldId) should be present in history. The removed history assertion left a small coverage gap — a follow-up check like Assert.That(await _wordRepo.GetWord(_projId, oldId), Is.Not.Null) or checking the history collection would guard against regressions in the historical record.

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

In `@Backend.Tests/Controllers/AudioControllerTests.cs` around lines 177 - 198,
Add an assertion to verify the superseded/original word (oldId) was preserved in
history after DeleteAudioFile; call the repository method that retrieves
historical entries (e.g., _wordRepo.GetWord(_projId, oldId) or the history
collection getter) and assert the result is not null (or that history contains
an entry with Id == oldId) so the test ensures the original word remains in
history while newId is returned and placed in the frontier.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@Backend.Tests/Controllers/AudioControllerTests.cs`:
- Around line 116-120: The test passes a nullable string (newId from
result.Value as string) into _wordRepo.GetWord which expects a non-nullable
string causing CS8604; fix by either asserting non-null and using the
null-forgiving operator when calling _wordRepo.GetWord (e.g., pass newId! to
GetWord) or by adding a specific compiler suppression for CS8604 in the
project/ruleset so the single Assert.That(newId, Is.Not.Null) is respected;
locate newId and the _wordRepo.GetWord(...) call to apply the chosen change.

---

Duplicate comments:
In `@Backend.Tests/Controllers/AudioControllerTests.cs`:
- Around line 120-122: The test assertion was updated correctly: keep the
assertion using foundWord (from GetWord) and assert Assert.That(foundWord,
Is.Not.Null) followed by Assert.That(foundWord.Audio, Is.Not.Empty) (do not add
a null-forgiving operator); this properly verifies Audio content given Word
initializes Audio in its constructor and adheres to the NUnit3001 suppressor
convention in the AudioControllerTests / GetWord usage.

---

Nitpick comments:
In `@Backend.Tests/Controllers/AudioControllerTests.cs`:
- Around line 177-198: Add an assertion to verify the superseded/original word
(oldId) was preserved in history after DeleteAudioFile; call the repository
method that retrieves historical entries (e.g., _wordRepo.GetWord(_projId,
oldId) or the history collection getter) and assert the result is not null (or
that history contains an entry with Id == oldId) so the test ensures the
original word remains in history while newId is returned and placed in the
frontier.

In `@Backend.Tests/Services/WordServiceTests.cs`:
- Around line 75-97: Add an assertion that the returned newWord has no audio
entries to verify DeleteAudio's primary effect: update the test in
WordServiceTests (the DeleteAudio scenario) to assert newWord.Audio is empty
(e.g., Assert.That(newWord.Audio, Is.Empty) or Assert.That(newWord.Audio.Count,
Is.EqualTo(0)); keep the existing assertions about frontier, history, and
oldWord intact.

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

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants