Skip to content

test(ui): isolate OldTeams delete-warning tests from leaked mock#30871

Merged
yuneng-berri merged 1 commit into
litellm_internal_stagingfrom
litellm_fix_oldteams_delete_warning_test_isolation
Jun 20, 2026
Merged

test(ui): isolate OldTeams delete-warning tests from leaked mock#30871
yuneng-berri merged 1 commit into
litellm_internal_stagingfrom
litellm_fix_oldteams_delete_warning_test_isolation

Conversation

@mateo-berri

@mateo-berri mateo-berri commented Jun 20, 2026

Copy link
Copy Markdown
Collaborator

Relevant issues

ui_unit_tests is red on litellm_internal_staging because of one deterministic failure in OldTeams.test.tsx ("still warns about model deletion in the confirmation message when the team has no keys"). This fixes that

Linear ticket

N/A

Pre-Submission checklist

  • I have added meaningful tests
  • My PR passes all unit tests on make test-unit
  • My PR's scope is as isolated as possible; it only solves 1 specific problem
  • I have requested a Greptile review by commenting @greptileai and received a Confidence Score of at least 4/5 before requesting a maintainer review (Greptile returned 5/5, safe to merge)

Root cause

The deprecated OldTeams component accepts only accessToken, userID, userRole and premiumUser. It ignores the teams prop that the delete-warning tests were passing and instead populates its table from the mocked teamListCall. That block never set teamListCall, and vi.clearAllMocks() clears call history but not implementations, so the table rendered the "Legacy Team" (keys.length 2) left behind by the previous block's last test ("falls back to keys.length when keys_count is absent").

Both delete tests therefore ran against that leaked team. The keys-present case passed only because the leaked count happened to be 2, and the no-keys case rendered the very "Warning: This team has 2 keys" message it asserted should be absent, so it failed

Fix

Seed the team through the channel the component actually reads (teamListCall) and drop the props it never consumes, so each test renders exactly the team it declares. The keys-present case now uses a distinctive count (5) so it can no longer pass on a coincidental leak

Screenshots / Proof of Fix

This is a frontend test-isolation fix, so the meaningful proof is the suite going from red to green on the clean litellm_internal_staging base, run from ui/litellm-dashboard:

# Before (pristine staging HEAD)
$ npx vitest run src/components/OldTeams.test.tsx
   × OldTeams - delete team warning copy > still warns about model deletion in the confirmation message when the team has no keys
 Tests  1 failed | 33 passed (34)

# After (this branch)
$ npx vitest run src/components/OldTeams.test.tsx
 Tests  34 passed (34)

Mutation checks confirming the tests still bite: forcing the component to always render the warning makes the no-keys test fail, and reverting the harness seeding (while keeping count 5) makes both delete tests fail because they render the leaked count-2 team

Type

✅ Test

Changes

ui/litellm-dashboard/src/components/OldTeams.test.tsx: drive the team data via the teamListCall mock that OldTeams reads, stop passing props the component ignores, and use a distinctive key count in the keys-present case


Generated by Claude Code


Note

Low Risk
Test-only changes in OldTeams.test.tsx with no production code impact.

Overview
Fixes flaky/failing OldTeams delete-modal tests by seeding team data through the teamListCall mock the component actually uses, instead of a teams prop it ignores.

The openDeleteModal helper now mocks teamListCall per test and renders OldTeams with only accessToken, userID, and userRole. The keys-present case asserts keys_count: 5 so a leaked “2 keys” team from an earlier test can’t make the assertion pass by accident.

Reviewed by Cursor Bugbot for commit 245660d. Bugbot is set up for automated code reviews on this repo. Configure here.

The deprecated OldTeams component takes only accessToken, userID, userRole
and premiumUser; it ignores the teams prop these tests passed and instead
populates its table from the mocked teamListCall. The delete-warning block
never set teamListCall, and vi.clearAllMocks clears call history but not
implementations, so the table rendered the "Legacy Team" (keys.length 2)
left behind by the previous block's last test. Both delete tests therefore
ran against that leaked team: the keys-present case passed only because the
leaked count happened to be 2, and the no-keys case rendered the same warning
it asserted should be absent, so it failed.

Seed the team through the channel the component actually reads (teamListCall)
and drop the props it never consumes, so each test renders exactly the team
it declares. The keys-present case now uses a distinctive count so it can no
longer pass on a coincidental leak
@mateo-berri

Copy link
Copy Markdown
Collaborator Author

@greptileai

@greptile-apps

greptile-apps Bot commented Jun 20, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

Fixes a deterministic test failure in the OldTeams delete-warning suite caused by mock state leaking from an earlier test into the two delete-modal tests.

  • openDeleteModal now mocks teamListCall before each render — the actual data channel the component uses — and strips the teams, setTeams, organizations, and searchParams props that OldTeams never reads.
  • The keys-present case asserts keys_count: 5 instead of 2, making it impossible for the leaked "Legacy Team" (2 keys) from the previous describe block to produce a false pass.

Confidence Score: 5/5

Test-only change with no production code touched; corrects mock isolation so both delete-warning tests accurately exercise the component's real data path.

The fix addresses the root cause precisely: the component reads its team list from teamListCall, not from props, so seeding via that mock is the correct approach. Using a distinctive count (5) rather than 2 closes the coincidental-pass loophole. No assertions are weakened and no production behaviour is altered.

No files require special attention.

Important Files Changed

Filename Overview
ui/litellm-dashboard/src/components/OldTeams.test.tsx Test isolation fix: openDeleteModal now seeds via teamListCall mock instead of a teams prop the component ignores; keys-present assertion upgraded to count 5 to rule out coincidental matches from prior test state.

Reviews (2): Last reviewed commit: "test(ui): isolate OldTeams delete-warnin..." | Re-trigger Greptile

@mateo-berri

Copy link
Copy Markdown
Collaborator Author

bugbot run

@codecov

codecov Bot commented Jun 20, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 245660d. Configure here.

@mateo-berri mateo-berri marked this pull request as ready for review June 20, 2026 15:16
@mateo-berri mateo-berri requested a review from yuneng-berri June 20, 2026 15:16
@yuneng-berri yuneng-berri merged commit 15aa40b into litellm_internal_staging Jun 20, 2026
125 checks passed
@yuneng-berri yuneng-berri deleted the litellm_fix_oldteams_delete_warning_test_isolation branch June 20, 2026 16:10
fzowl pushed a commit to fzowl/litellm that referenced this pull request Jun 24, 2026
…riAI#30871)

The deprecated OldTeams component takes only accessToken, userID, userRole
and premiumUser; it ignores the teams prop these tests passed and instead
populates its table from the mocked teamListCall. The delete-warning block
never set teamListCall, and vi.clearAllMocks clears call history but not
implementations, so the table rendered the "Legacy Team" (keys.length 2)
left behind by the previous block's last test. Both delete tests therefore
ran against that leaked team: the keys-present case passed only because the
leaked count happened to be 2, and the no-keys case rendered the same warning
it asserted should be absent, so it failed.

Seed the team through the channel the component actually reads (teamListCall)
and drop the props it never consumes, so each test renders exactly the team
it declares. The keys-present case now uses a distinctive count so it can no
longer pass on a coincidental leak
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants