Skip to content

827 popover block test #1177

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 9 commits into
base: dev
Choose a base branch
from
Open

827 popover block test #1177

wants to merge 9 commits into from

Conversation

Mezzet
Copy link
Contributor

@Mezzet Mezzet commented May 20, 2025

Description

Adding Popover block tests

Changes Made

Added popover test file

How to Test

Create mock data
Run tests

Notes

mezzet_deloitte added 7 commits April 28, 2025 20:04

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
@Mezzet Mezzet linked an issue May 20, 2025 that may be closed by this pull request
Copy link

@CodiumAI-Agent /describe

@CodiumAI-Agent
Copy link

Title

827 popover block test


User description

Description

Adding Popover block tests

Changes Made

Added popover test file

How to Test

Create mock data
Run tests

Notes


PR Type

Tests


Description

  • Add unit tests for PopoverBlock

  • Verify popover opens on click trigger

  • Check default placeholder content

  • Ensure styled popover applies custom styles


Changes walkthrough 📝

Relevant files
Tests
Popover.spec.tsx
Add unit tests for PopoverBlock                                                   

libs/renderer/src/testing/block-defaults/Popover.spec.tsx

  • Create mock block definitions for popover scenarios
  • Render ContainerBlock as popover target
  • Test default popover open and placeholder text
  • Validate styled popover dimensions and content
  • +182/-0 
    Additional files
    pnpm-lock.yaml [link]   

    Need help?
  • Type /help how to ... in the comments thread for any questions about PR-Agent usage.
  • Check out the documentation for more information.
  • Copy link

    @CodiumAI-Agent /review

    Copy link

    @CodiumAI-Agent /improve

    @CodiumAI-Agent
    Copy link

    PR Reviewer Guide 🔍

    Here are some key observations to aid the review process:

    ⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
    🧪 PR contains tests
    🔒 No security concerns identified
    ⚡ Recommended focus areas for review

    Isolated render

    The test’s click target is obtained from a separate render of ContainerBlock in beforeEach and not part of the PopoverBlock render under test. As a result, fireEvent.click on that target will not open the popover instance being rendered in each individual test. Consider rendering ContainerBlock and PopoverBlock together or querying the correct element within the same render scope.

    fireEvent.click(target);
    Style assertion

    The tests mix object-style and string-style assertions and include spaces in the rgb value, which may cause false negatives. Standardize to one assertion style (e.g., object with exact values) and ensure the rgb formatting matches the actual computed style.

    expect(element).toHaveStyle({ width: "200px", height: "100px" });
    
    expect(element).toHaveStyle("backgroundColor: rgb(108, 71, 71)");
    expect(element).toHaveStyle("border: 1px solid #000000");

    @CodiumAI-Agent
    Copy link

    PR Code Suggestions ✨

    CategorySuggestion                                                                                                                                    Impact
    Possible issue
    Render popover with its container

    Render the popover inside the container block so the click target exists in the same
    DOM tree and query it from the same container. This ensures the click actually
    triggers the popover open logic.

    libs/renderer/src/testing/block-defaults/Popover.spec.tsx [142-151]

    -const { container } = render(<PopoverBlock id="popover" />, {
    +const { container } = render(<ContainerBlock id="target-container" />, {
         blocks: {
    -        popover: {
    -            ...blocks["popover"],
    +        "target-container": {
    +            ...blocks["target-container"],
    +            slots: {
    +                children: { children: ["popover"], name: "children" }
    +            }
             },
    +        popover: { ...blocks["popover"] }
         },
     });
    -// click to trigger popover
    +const target = container.querySelector("[data-block='target-container']");
     fireEvent.click(target);
    Suggestion importance[1-10]: 9

    __

    Why: The test currently renders the PopoverBlock separately from the container, causing the click on target to not be in the same DOM; wrapping in ContainerBlock fixes the click trigger context and corrects the test.

    High
    Render styled popover inside container

    Include the styled popover within the same container rendering so the click target
    is present, and query it from the returned container. This aligns the DOM contexts
    for trigger and popover.

    libs/renderer/src/testing/block-defaults/Popover.spec.tsx [160-171]

    -const { container } = render(<PopoverBlock id="styledPopover" />, {
    +const { container } = render(<ContainerBlock id="target-container" />, {
         blocks: {
    -        styledPopover: {
    -            ...blocks["styledPopover"],
    +        "target-container": {
    +            ...blocks["target-container"],
    +            slots: {
    +                children: { children: ["styledPopover"], name: "children" }
    +            }
             },
    -        helloText: {
    -            ...blocks["helloText"],
    -        },
    +        styledPopover: { ...blocks["styledPopover"] },
    +        helloText: { ...blocks["helloText"] }
         },
     });
    +const target = container.querySelector("[data-block='target-container']");
     fireEvent.click(target);
    Suggestion importance[1-10]: 9

    __

    Why: Similar to the first test, the styled popover is rendered outside its container, so including it in the ContainerBlock ensures the click correctly triggers popover display.

    High

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    @Mezzet Mezzet marked this pull request as ready for review May 20, 2025 02:37
    @Mezzet Mezzet requested a review from a team as a code owner May 20, 2025 02:37
    @memisrose memisrose self-assigned this Jun 17, 2025
    @memisrose memisrose added the Test Used for tickets related to FE testing label Jun 17, 2025
    @memisrose memisrose self-requested a review June 17, 2025 20:14
    @memisrose memisrose removed their assignment Jun 17, 2025
    …pover-block-test
    Copy link
    Contributor

    @memisrose memisrose left a comment

    Choose a reason for hiding this comment

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

    image
    image

    The tests pass here, but there are errors.

    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    Test Used for tickets related to FE testing
    Projects
    None yet
    Development

    Successfully merging this pull request may close these issues.

    Popover Block
    3 participants