Skip to content

Conversation

@eschutho
Copy link
Member

@eschutho eschutho commented Oct 3, 2025

SUMMARY

Refactors modal test files to follow the "avoid nesting when testing" pattern by removing nested describe()/it() blocks in favor of flat test() calls.

Changes:

  • Flatten test structure in EmbeddedModal.test.tsx - remove nested describe blocks, use top-level test() calls
  • Flatten test structure in ThemeList.test.tsx - remove nested describe blocks, use top-level test() calls
  • Improve test readability and maintainability following Kent C. Dodds' testing principles

Benefits:

  • Clearer test isolation and independence
  • Easier to scan and understand test suite
  • Follows modern React Testing Library best practices
  • Aligns with Superset's ongoing testing strategy migration

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

N/A - Test structure refactoring only, no functional changes

TESTING INSTRUCTIONS

npm test -- ThemeList.test.tsx --testPathIgnorePatterns=cypress
npm test -- EmbeddedModal.test.tsx --testPathIgnorePatterns=cypress

Both test suites should pass with all tests (13 tests for ThemeList, 14 tests for EmbeddedModal).

ADDITIONAL INFORMATION

  • Changes follow "avoid nesting when testing" principles from CLAUDE.md
  • All existing tests pass without modification to assertions
  • No functional changes to test coverage or behavior

🤖 Generated with Claude Code

- Remove nested describe/it blocks in favor of flat test() calls
- Follow "avoid nesting when testing" best practices
- Improves test readability and maintainability

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Copy link

@korbit-ai korbit-ai bot left a comment

Choose a reason for hiding this comment

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

I've completed my review and didn't find any issues.

Check out our docs on how you can make Korbit work best for you and your team.

Loving Korbit!? Share us on LinkedIn Reddit and X

Copy link
Contributor

@bito-code-review bito-code-review bot left a comment

Choose a reason for hiding this comment

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

Code Review Agent Run #f2afaf

Actionable Suggestions - 2
  • superset-frontend/src/dashboard/components/EmbeddedModal/EmbeddedModal.test.tsx - 1
  • superset-frontend/src/pages/ThemeList/ThemeList.test.tsx - 1
Review Details
  • Files reviewed - 2 · Commit Range: 5e324c3..5e324c3
    • superset-frontend/src/dashboard/components/EmbeddedModal/EmbeddedModal.test.tsx
    • superset-frontend/src/pages/ThemeList/ThemeList.test.tsx
  • Files skipped - 0
  • Tools
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers a full AI review.

  • /pause - Pauses automatic reviews on this pull request.

  • /resume - Resumes automatic reviews.

  • /resolve - Marks all Bito-posted review comments as resolved.

  • /abort - Cancels all in-progress reviews.

Refer to the documentation for additional commands.

Configuration

This repository uses Default Agent You can customize the agent settings here or contact your Bito workspace admin at evan@preset.io.

Documentation & Help

AI Code Review powered by Bito Logo

Comment on lines 175 to +177
});

describe('Modal.useModal integration', () => {
beforeEach(() => {
jest.clearAllMocks();
});
test('uses Modal.useModal hook for confirmation dialogs', () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Missing test isolation

The test refactoring removes the beforeEach hook that clears mocks between tests, which could lead to test pollution and unreliable test results. The jest.clearAllMocks() call was removed from the test setup, but multiple tests use spies (jest.spyOn(Modal, 'useModal') and jest.spyOn(Modal, 'confirm')) that need to be reset between test runs. This could cause spies to retain call counts and mock implementations from previous tests, leading to false positives or negatives in test assertions.

Code suggestion
Check the AI-generated fix before applying
Suggested change
});
describe('Modal.useModal integration', () => {
beforeEach(() => {
jest.clearAllMocks();
});
test('uses Modal.useModal hook for confirmation dialogs', () => {
});
beforeEach(() => {
jest.clearAllMocks();
});
test('uses Modal.useModal hook for confirmation dialogs', () => {

Code Review Run #f2afaf


Should Bito avoid suggestions like this for future reviews? (Manage Rules)

  • Yes, avoid them

Comment on lines +103 to +105
beforeEach(() => {
fetchMock.resetHistory();
});
Copy link
Contributor

Choose a reason for hiding this comment

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

Test isolation issue

The removal of the nested describe('Modal.useModal integration') block also removed the jest.clearAllMocks() call from its beforeEach. This could cause test pollution where spies and mocks from Modal-related tests (useModalSpy, confirmSpy) could affect other tests. Add jest.clearAllMocks() to the global beforeEach to maintain proper test isolation.

Code suggestion
Check the AI-generated fix before applying
Suggested change
beforeEach(() => {
fetchMock.resetHistory();
});
beforeEach(() => {
fetchMock.resetHistory();
jest.clearAllMocks();
});

Code Review Run #f2afaf


Should Bito avoid suggestions like this for future reviews? (Manage Rules)

  • Yes, avoid them

@sadpandajoe
Copy link
Member

@eschutho I think i already have a pr here that will fix all of this: #35497

@eschutho
Copy link
Member Author

eschutho commented Oct 4, 2025

@eschutho I think i already have a pr here that will fix all of this: #35497

Sure, let's go with yours.

@eschutho eschutho closed this Oct 4, 2025
@eschutho eschutho deleted the fix/modal-confirm-dark-mode-theming branch October 4, 2025 00:10
@dosubot dosubot bot added the change:frontend Requires changing the frontend label Oct 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

change:frontend Requires changing the frontend size/L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants