Skip to content

test(renderer): add iframe block tests #1221

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

Merged
merged 1 commit into from
May 30, 2025
Merged

test(renderer): add iframe block tests #1221

merged 1 commit into from
May 30, 2025

Conversation

stelbailey
Copy link
Contributor

@stelbailey stelbailey commented May 27, 2025

Description

added tests for the iframe block

Changes Made

How to Test

  1. Steps to reproduce/test the behavior
  2. Expected outcomes

Notes

@stelbailey stelbailey requested a review from a team as a code owner May 27, 2025 16:28
@stelbailey stelbailey linked an issue May 27, 2025 that may be closed by this pull request
Copy link

@CodiumAI-Agent /describe

@stelbailey stelbailey requested review from johbaxter and memisrose May 27, 2025 16:29
@CodiumAI-Agent
Copy link

Title

test(renderer): add iframe block tests


User description

Description

added tests for the iframe block

Changes Made

How to Test

  1. Steps to reproduce/test the behavior
  2. Expected outcomes

Notes


PR Type

Tests


Description

  • Add tests for IframeBlock rendering and attributes

  • Verify pointer event toggling behavior

  • Ensure visibility toggles on show flag

  • Check custom and default style application


Changes walkthrough 📝

Relevant files
Tests
IframeBlock.spec.tsx`
IframeBlock rendering and styling tests                                   

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

  • Introduce tests for default rendering attributes
  • Test disabling pointer interactions
  • Validate show/hide block behavior
  • Assess custom and fallback styling logic
  • Additional files
    IframeBlock.spec.tsx +118/-0 

    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

    @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

    Fragile Selector

    The test "applies default styles when data.style is not provided" selects the wrapper by a generic "span" tag, which can be brittle. Consider querying by the component's data attribute for more reliable selection.

        const wrapper = container.querySelector("span");
        expect(wrapper).toHaveStyle({ width: "100%", height: "400px" });
    });
    Type Mismatch

    The show property is handled as a string ("true"/"false") in the test data. Verify that the component expects string values and not booleans to avoid potential flaky behavior.

        show: "true",
    },

    Copy link

    @CodiumAI-Agent /improve

    @CodiumAI-Agent
    Copy link

    PR Code Suggestions ✨

    CategorySuggestion                                                                                                                                    Impact
    General
    Use boolean for show flag

    Replace the string values for show with booleans to match expected API usage. Update
    both "true" and "false" cases in the tests to use true/false. This aligns the test
    setup with how the component likely interprets the show flag.

    libs/renderer/src/testing/block-defaults/IframeBlock.spec.tsx [14]

    -show: "true",
    +show: true,
    Suggestion importance[1-10]: 7

    __

    Why: Changing show to a boolean aligns the test setup with expected component props and prevents the test from passing incorrect string values.

    Medium
    Use consistent wrapper selector

    Select the wrapper consistently by its data-block attribute instead of a tag name.
    This makes the test more resilient to markup changes and matches how other tests
    locate the block root.

    libs/renderer/src/testing/block-defaults/IframeBlock.spec.tsx [115]

    -const wrapper = container.querySelector("span");
    +const wrapper = container.querySelector("[data-block='iframe']");
    Suggestion importance[1-10]: 5

    __

    Why: Selecting the wrapper by [data-block='iframe'] makes the test more robust against markup changes and matches other selectors.

    Low
    Use string style assertion

    Use a style string in toHaveStyle for consistency with other tests. This makes the
    assertion clearer and avoids potential object-to-string matching issues.

    libs/renderer/src/testing/block-defaults/IframeBlock.spec.tsx [98]

    -expect(iframe).toHaveStyle({ width: "100%", height: "100%" });
    +expect(iframe).toHaveStyle("width: 100%; height: 100%;");
    Suggestion importance[1-10]: 4

    __

    Why: Using a style string for toHaveStyle matches other tests and avoids potential mismatches with object syntax.

    Low
    Possible issue
    Assert iframe absence when hidden

    Add an assertion to confirm that no <iframe> is rendered when show is false. This directly
    verifies the component hides the frame rather than just clearing the wrapper
    content.

    libs/renderer/src/testing/block-defaults/IframeBlock.spec.tsx [76]

     expect(block).toBeEmptyDOMElement();
    +expect(container.querySelector("iframe")).toBeNull();
    Suggestion importance[1-10]: 5

    __

    Why: Adding a check that no <iframe> is in the DOM directly verifies the component hides the iframe, improving test coverage.

    Low

    @johbaxter johbaxter merged commit 1da2c20 into dev May 30, 2025
    4 checks passed
    @johbaxter johbaxter deleted the 854-iframe-block branch May 30, 2025 16:58
    Copy link

    @CodiumAI-Agent /update_changelog

    @CodiumAI-Agent
    Copy link

    Changelog updates: 🔄

    2025-05-30 *

    Added

    • Tests for the iframe block in the renderer suite

    to commit the new content to the CHANGELOG.md file, please type:
    '/update_changelog --pr_update_changelog.push_changelog_changes=true'

    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.

    Iframe Block
    3 participants