Skip to content

Testing Updates #1134

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 8 commits into
base: dev
Choose a base branch
from
Open

Testing Updates #1134

wants to merge 8 commits into from

Conversation

memisrose
Copy link
Contributor

@memisrose memisrose commented May 14, 2025

Description

Updates to the vitesting suite.

Changes Made

  • Moving the testing folder in renderer out of the src folder
  • Cleaning imports inside each test file
  • Removing unused packages
  • Fixing/clearing out vitest warnings
  • Adding additional information to the ReadMe
  • Fix Radio Test
  • Temp remove part of UploadBlock test
  • Fixing lint errors in client that prevented committing

How to Test

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

Notes

@memisrose memisrose requested a review from a team as a code owner May 14, 2025 00:34
Copy link

@CodiumAI-Agent /describe

Copy link

@CodiumAI-Agent /review

@CodiumAI-Agent
Copy link

Title

Testing Updates


User description

Description

Updates to the vitesting suite.

Changes Made

  • Moving the testing folder in renderer out of the src folder
  • Cleaning imports inside each test file
  • Removing unused packages
  • Fixing/clearing out vitest warnings
  • Adding additional information to the ReadMe
  • Fixing lint errors in client that prevented committing

How to Test

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

Notes


PR Type

Tests, Enhancement


Description

  • Migrate and restructure block tests folder

  • Update test utils and add preProcess listeners

  • Adjust tsconfig and Vite configs for new testing path

  • Minor client code style and logic fixes


Changes walkthrough 📝

Relevant files
Configuration changes
3 files
index.tsx
Update testing utils MockProvider wrapper                               
+9/-9     
tsconfig.json
Include `testing` directory in TypeScript config                 
+2/-2     
vite.config.mts
Migrate Vite config to .mts with Vitest setup                       
+51/-0   
Documentation
1 files
README.md
Add new testing suite README documentation                             
+75/-0   
Tests
15 files
AccordionBlock.spec.tsx
Update Accordion tests and add `preProcess` listener         
+20/-16 
AudioBlock.spec.tsx
Migrate AudioBlock tests with `preProcess` listener           
+133/-0 
CheckboxBlock.spec.tsx
Enhance CheckboxBlock tests and listeners                               
+155/-0 
ChipBlock.spec.tsx
Add `preProcess` listener to ChipBlock tests                         
+36/-11 
ContainerBlock.spec.tsx
Update ContainerBlock tests and props data                             
+35/-16 
DividerBlock.spec.tsx
Refine DividerBlock tests styling assertions                         
+24/-18 
HTMLBlock.spec.tsx
Fix import path in HTMLBlock tests                                             
+1/-2     
IconBlock.spec.tsx
Correct IconBlock imports and debug comment                           
+8/-7     
LinkBlock.spec.tsx
Add `preProcess` listener to LinkBlock tests                         
+8/-2     
LogsBlock.spec.tsx
Insert `preProcess` listener and fix imports                         
+9/-5     
MarkdownBlock.spec.tsx
Rearrange imports in MarkdownBlock tests                                 
+2/-3     
ProgressBlock.spec.tsx
Add `preProcess` listener to ProgressBlock tests                 
+163/-0 
RadioBlock.spec.tsx
Rewrite RadioBlock tests with new props                                   
+191/-0 
RatingsBlock.spec.tsx
Enable RatingsBlock interaction tests                                       
+95/-0   
SidebarBlock.spec.tsx
Migrate SidebarBlock tests and imports                                     
+78/-0   
Bug fix
1 files
MembersTable.tsx
Fix API condition logic and JSX formatting                             
+31/-21 
Additional files
21 files
README.md +0/-26   
AudioBlock.spec.tsx +0/-126 
CheckboxBlock.spec.tsx +0/-135 
ProgressBlock.spec.tsx +0/-174 
RadioBlock.spec.tsx +0/-147 
RatingsBlock.spec.tsx +0/-73   
SidebarBlock.spec.tsx +0/-80   
SwitchBlock.spec.tsx +0/-69   
ToggleButtonBlock.spec.tsx +0/-250 
UploadBlock.spec.tsx +0/-121 
test.spec.ts +0/-9     
SliderBlock.spec.tsx +17/-4   
SwitchBlock.spec.tsx +88/-0   
ToggleButtonBlock.spec.tsx +258/-0 
UploadBlock.spec.tsx +129/-0 
vite.config.ts +0/-52   
vitest.setup.ts +1/-1     
UserPopover.tsx +16/-4   
UserTable.tsx +24/-18 
test.spec.ts +0/-9     
vite.config.mts +7/-7     

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 /improve

    @CodiumAI-Agent
    Copy link

    PR Reviewer Guide 🔍

    Here are some key observations to aid the review process:

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

    Missing children

    The MockProvider no longer accepts or renders any children, so components passed to customRender may not actually be rendered. Ensure the provider forwards and renders its children.

    const MockProvider: React.FC<MockProviderProps> = ({
        blocks,
        renderEngineId,
        queryConfig,
    }) => {
        const store = new StateStore({
            state: {
                executionOrder: [],
                queries: queryConfig || {},
                variables: {},
                version: "",
                blocks: blocks,
            },
        });
    
        return (
            <Blocks state={store} registry={DefaultBlocks}>
                <RendererEngine id={renderEngineId} />
            </Blocks>
    Assertion syntax

    The test uses .toBeTruthy without invoking it. It should be called as .toBeTruthy() to perform the assertion.

    expect(onElement.classList.contains("Mui-disabled")).toBeTruthy;
    expect(offElement.classList.contains("Mui-disabled")).toBeTruthy;
    Async describe

    Using async on the describe callback is unconventional and may not work as expected. Keep describe synchronous and mark individual it blocks as async instead.

    describe("ratings block", async () => {
        it("should render ratings block", async () => {

    @memisrose memisrose requested a review from johbaxter May 14, 2025 00:37
    @CodiumAI-Agent
    Copy link

    PR Code Suggestions ✨

    CategorySuggestion                                                                                                                                    Impact
    Possible issue
    Render children in MockProvider

    The MockProvider drops the child component passed by customRender, so none of your
    tests actually render the UI under test. Re‐introduce children in the provider
    interface and render {children} inside .

    libs/renderer/testing/utils/index.tsx [29-33]

     return (
         <Blocks state={store} registry={DefaultBlocks}>
             <RendererEngine id={renderEngineId} />
    +        {children}
         </Blocks>
     );
    Suggestion importance[1-10]: 10

    __

    Why: The MockProvider no longer renders its children, so the UI under test is never mounted; adding {children} is critical to actually render test components.

    High
    Invoke toBeTruthy matcher

    You're calling the matcher property instead of invoking it, so these assertions
    never execute. Append () to actually call toBeTruthy.

    libs/renderer/testing/block-defaults/ToggleButtonBlock.spec.tsx [234-235]

    -expect(onElement.classList.contains("Mui-disabled")).toBeTruthy;
    -expect(offElement.classList.contains("Mui-disabled")).toBeTruthy;
    +expect(onElement.classList.contains("Mui-disabled")).toBeTruthy();
    +expect(offElement.classList.contains("Mui-disabled")).toBeTruthy();
    Suggestion importance[1-10]: 8

    __

    Why: Without calling toBeTruthy() the matcher is not executed, leaving assertions inert; adding () fixes the broken test logic.

    Medium

    @memisrose memisrose self-assigned this May 16, 2025
    @memisrose memisrose added the Test Used for tickets related to FE testing label May 16, 2025
    memisrose added 5 commits May 28, 2025 16:16

    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.
    This reverts commit 24bdc8b.

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    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.

    None yet

    2 participants