Skip to content

feat: add Unit Test Analyzer Tool card to MagicBento component - #35

Merged
BasuruK merged 2 commits into
mainfrom
adding-unit-test-analyzer-tool
Oct 17, 2025
Merged

BasuruK merged 2 commits into
mainfrom
adding-unit-test-analyzer-tool

Conversation

@BasuruK

@BasuruK BasuruK commented Oct 14, 2025 •

Copy link
Copy Markdown
Owner

Summary by CodeRabbit

  • New Features

    • Added a new “Unit Test Analyzer Tool” card in Magic Bento with a dedicated icon and details.
  • Refactor

    • Improved detection of unit-test–related cards in Magic Bento by refining title and label matching for more accurate surfacing.

@coderabbitai

coderabbitai Bot commented Oct 14, 2025 •

Copy link
Copy Markdown
Contributor

Walkthrough

Added a new "Unit Test Analyzer Tool" card to MagicBento’s public cardData with an SVG icon. Updated isUnitTestCard logic to detect unit-test-related cards by matching "unit test generation" in both title and label.

Changes

Cohort / File(s) Summary
MagicBento card and detection updates
src/Components/MagicBento/MagicBento.jsx
- Added new card object: "Unit Test Analyzer Tool" to public cardData (includes SVG icon and properties).
- Modified isUnitTestCard to check for "unit test generation" in title and label instead of the prior "unit test" check.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor User
  participant MagicBento
  participant cardData
  participant isUnitTestCard

  User->>MagicBento: Open MagicBento
  MagicBento->>cardData: Load cards (now includes "Unit Test Analyzer Tool")
  loop For each card
    MagicBento->>isUnitTestCard: Evaluate(title, label)
    isUnitTestCard-->>MagicBento: true if contains "unit test generation"
  end
  MagicBento-->>User: Render cards with updated detection
  note over isUnitTestCard: Detection updated to match "unit test generation"
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

I hopped through JSX with glee,
A shiny new card for all to see! 🃏
"Generation" now in my test-y song,
I sniff the cases quick and strong.
Thump-thump—code greener all day long! 🥕✨

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The pull request title "feat: add Unit Test Analyzer Tool card to MagicBento component" directly describes the primary change in the changeset. According to the raw summary, the main modification is adding a new public card entry for "Unit Test Analyzer Tool" to the cardData in the MagicBento component, which is exactly what the title conveys. The title is concise, uses clear language, and follows a conventional commit format with a meaningful description. While the changeset also includes a secondary update to the isUnitTestCard detection logic, the title appropriately focuses on the primary change without requiring every detail to be mentioned, which is standard practice for commit titles.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch adding-unit-test-analyzer-tool

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4bf4743 and 2bc6a8e.

📒 Files selected for processing (1)
  • src/Components/MagicBento/MagicBento.jsx (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/Components/MagicBento/MagicBento.jsx

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 2

Caution

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

⚠️ Outside diff range comments (1)
src/Components/MagicBento/MagicBento.jsx (1)

814-820: Fix undefined variable: setIsModelSelectorOpen.

Line 817 references setIsModelSelectorOpen, which is not defined in this component. This will cause a runtime error when a unit test card is clicked in the non-ParticleCard rendering path (when enableStars is false).

Apply this diff to fix the undefined variable:

               const handleClick = (e) => {
                 // Handle Unit Test modal or navigation first
                 if (isUnitTestCard(card)) {
-                  setIsModelSelectorOpen(true);
+                  handleOpenUnitTestModal();
                 } else {
                   handleCardNavigation(card);
                 }
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e368297 and 4bf4743.

📒 Files selected for processing (1)
  • src/Components/MagicBento/MagicBento.jsx (2 hunks)

Comment on lines +125 to +126
title.includes('unit test generation') ||
label.includes('unit test generation') ||

@coderabbitai coderabbitai Bot Oct 14, 2025 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

Verify the intent: restrictive pattern conflicts with new card addition.

The updated logic now checks for 'unit test generation' instead of a broader pattern. This is more restrictive and won't match the newly added "Unit Test Analyzer Tool" card.

Questions to clarify:

  1. Should both unit-test cards open the same modal, or have different behaviors?
  2. If they should both open the modal, the pattern should be broader (e.g., includes('unit test')).
  3. If they should behave differently, why does the new card lack an href?

Run this script to verify which cards currently match the unit test detection:


🏁 Script executed:

#!/bin/bash
# Check which cards would match the unit test detection logic

cat << 'EOF' > /tmp/check_cards.py
import re

# Card data from the file
cards = [
    {"title": "ATW Logs Monitor", "label": "Logs", "href": "http://10.17.98.235:8501/"},
    {"title": "Dashboard", "label": "TAR/SAR", "href": "http://10.17.98.231:8501"},
    {"title": "Unit Test Generation", "label": "Unit Test Generation (AI) NEW!", "href": "/unit-tests"},
    {"title": "Documentation", "label": "Docs", "href": "https://ifsdev.atlassian.net/wiki/spaces/FINANCE/overview"},
    {"title": "Unit Test Analyzer Tool", "label": "Unit Test Analyzer", "href": None},
    {"title": "Background Tracer", "label": "Background Tracer", "href": "https://ifs-my.sharepoint.com/..."},
    {"title": "Report Comparison Tool", "label": "Report Comparison", "href": "https://compare-pdf-01.vercel.app/"},
]

def is_unit_test_card(card):
    title = (card.get("title") or "").lower()
    label = (card.get("label") or "").lower()
    href = (card.get("href") or "").lower()
    return (
        "unit test generation" in title or
        "unit test generation" in label or
        href == "/unit-tests"
    )

print("Cards that match isUnitTestCard logic:")
print("-" * 60)
for card in cards:
    matches = is_unit_test_card(card)
    print(f"✓ {card['title']}" if matches else f"✗ {card['title']}")
    if matches:
        print(f"  → Matches: title/label/href check")

EOF

python /tmp/check_cards.py

Length of output: 276


Broaden unit test card detection
isUnitTestCard only matches “unit test generation”, so “Unit Test Analyzer Tool” isn’t detected.

  • If both cards should open the same modal, change to title.includes('unit test') || label.includes('unit test').
  • Otherwise, clarify distinct behavior or add an href for the new card.
🤖 Prompt for AI Agents
In src/Components/MagicBento/MagicBento.jsx around lines 125-126, the
isUnitTestCard check only matches the exact phrase "unit test generation" so
cards titled like "Unit Test Analyzer Tool" are not detected; update the
condition to use a broader match such as title.toLowerCase().includes('unit
test') || label.toLowerCase().includes('unit test') if both should open the same
modal, or alternatively implement distinct handling (e.g., separate condition or
add an href) for the new card to ensure the intended behavior.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

These two features are not related

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@BasuruK, thank you for the clarification! That makes sense. Since the two features serve different purposes:

  • "Unit Test Generation" opens a modal (internal navigation)
  • "Unit Test Analyzer Tool" opens an external web application at http://10.17.97.36:8100

The current implementation with the more specific check for 'unit test generation' is correct. It ensures only the "Unit Test Generation" card triggers the modal, while the "Unit Test Analyzer Tool" card will behave like other external cards and open in a new browser tab.

The code is working as intended! 👍


✏️ Learnings added
Learnt from: BasuruK
PR: BasuruK/Finance.ai#35
File: src/Components/MagicBento/MagicBento.jsx:126-127
Timestamp: 2025-10-17T08:54:47.742Z
Learning: In the Finance.ai project's MagicBento component (src/Components/MagicBento/MagicBento.jsx), "Unit Test Generation" and "Unit Test Analyzer Tool" are distinct, unrelated features that should behave differently: "Unit Test Generation" opens a modal for generating PLSQL unit tests, while "Unit Test Analyzer Tool" opens an external web application for analyzing unit test coverage.

Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.

@BasuruK
BasuruK merged commit d293fa2 into main Oct 17, 2025
2 checks passed
@BasuruK
BasuruK deleted the adding-unit-test-analyzer-tool branch October 17, 2025 08:54
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.

1 participant