Skip to content

🧪 QA: Add tests for common utilities#387

Open
daggerstuff wants to merge 4 commits intostagingfrom
test/common-utils-3634795303099416474
Open

🧪 QA: Add tests for common utilities#387
daggerstuff wants to merge 4 commits intostagingfrom
test/common-utils-3634795303099416474

Conversation

@daggerstuff
Copy link
Copy Markdown
Owner

@daggerstuff daggerstuff commented Apr 4, 2026

💡 What: Added tests for common utilities\n🎯 Why: Covers missing edge cases / improves coverage\n✅ Verification: Runs successfully in Vitest


PR created automatically by Jules for task 3634795303099416474 started by @daggerstuff

Summary by Sourcery

Tests:

  • Introduce a new Vitest test suite for common utility functions covering additional edge cases.

Summary by cubic

Add a vitest test suite in src/utils/common.test.ts for unescapeHTML. Verifies HTML entities in VNode children are unescaped (e.g., '<b>bold</b> & beautiful' -> 'bold & beautiful').

Written for commit 30738df. Summary will update on new commits.

Summary by CodeRabbit

  • Tests
    • Enhanced test coverage with a new test suite for HTML entity unescaping functionality.

Co-authored-by: daggerstuff <261005129+daggerstuff@users.noreply.github.com>
@google-labs-jules
Copy link
Copy Markdown
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@vercel
Copy link
Copy Markdown

vercel bot commented Apr 4, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
pixelated Ready Ready Preview, Comment Apr 4, 2026 1:47am

Copilot AI review requested due to automatic review settings April 4, 2026 01:44
@chatgpt-codex-connector
Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@sourcery-ai
Copy link
Copy Markdown

sourcery-ai bot commented Apr 4, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Adds a new Vitest test suite for common utility functions in src/utils/common.test.ts to improve coverage and validate edge cases.

File-Level Changes

Change Details Files
Introduce a new Vitest test suite for common utilities to improve test coverage and edge-case validation.
  • Add a new common.test.ts file that imports shared utility functions and defines Vitest describe/it blocks for them
  • Cover typical usage paths and selected edge cases for common utilities, aligned with existing utility behavior
  • Ensure the new tests run successfully under the existing Vitest configuration and integrate with the current test suite
src/utils/common.test.ts

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 4, 2026

📝 Walkthrough

Walkthrough

A new Vitest test file was added to verify the unescapeHTML utility function correctly converts escaped HTML entities (&lt;, &gt;, &amp;) into their unescaped representations (<, >, &).

Changes

Cohort / File(s) Summary
Test Suite
src/utils/common.test.ts
Added Vitest test suite for the unescapeHTML function with a single test case validating the transformation of HTML entities within a VNode-like object's children string.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Suggested reviewers

  • CharlieHelps

Poem

🐰 A test for HTML so neat,
Unescaping entities sweet,
Ampersands dance, angle brackets gleam,
The rabbit's testing dream! ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: adding tests for common utilities, which aligns with the new test file for common utilities.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch test/common-utils-3634795303099416474

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.

Copy link
Copy Markdown

@sourcery-ai sourcery-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.

Hey - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Copy link
Copy Markdown

@charliecreates charliecreates bot left a comment

Choose a reason for hiding this comment

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

Test coverage is currently narrow (single happy-path case), which leaves common input shapes and edge cases unprotected. The test also doesn’t specify whether unescapeHTML should mutate its input or return a new value, which can lead to subtle regressions.

Summary of changes

Added test coverage for unescapeHTML

  • Introduced a new Vitest suite in src/utils/common.test.ts.
  • Added a single test asserting that unescapeHTML() converts &lt;, &gt;, and &amp; in a node’s children string into their literal characters (e.g., "&lt;b&gt;""<b>").

Comment on lines +5 to +12
it("unescapes HTML entities in VNode children", () => {
const node = {
type: "div",
children: "&lt;b&gt;bold&lt;/b&gt; &amp; beautiful",
}
const result = unescapeHTML(node)
expect(result.children).toBe("<b>bold</b> & beautiful")
})
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This test only covers the happy path where children is a simple string containing a few entities. If unescapeHTML is meant to be a general utility, it’s easy for regressions to slip in without covering common shapes (e.g., missing/undefined children, array children, nested nodes, already-unescaped strings, or other entities). Adding a small table-driven set of cases would make this much harder to break accidentally.

Suggestion

Expand coverage with a small set of additional cases (table-driven) that reflect the function’s expected contract, e.g.:

  • children missing / null / non-string
  • children array (if supported) and nested nodes
  • idempotency (calling twice yields same result)
  • a few more entities (e.g., &quot;, &#39;, numeric entities) if supported

If you want, reply with "@CharlieHelps yes please" and I’ll add a commit that introduces a describe.each/it.each matrix covering these cases.

Comment on lines +6 to +11
const node = {
type: "div",
children: "&lt;b&gt;bold&lt;/b&gt; &amp; beautiful",
}
const result = unescapeHTML(node)
expect(result.children).toBe("<b>bold</b> & beautiful")
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The test doesn’t clarify whether unescapeHTML is expected to mutate the input node or return a new node. That behavior matters to callers and is easy to change unintentionally. Consider asserting the intended behavior explicitly (either result === node for mutation or result !== node for immutability).

Suggestion

Add an explicit assertion for mutation vs immutability based on the intended contract, e.g.:

  • If immutable: expect(result).not.toBe(node)
  • If mutating: expect(result).toBe(node)

Optionally, deep-freeze node to ensure immutability is enforced if that’s the goal. Reply with "@CharlieHelps yes please" if you’d like me to add a commit with the assertion that matches the intended behavior.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a Vitest unit test to improve coverage for a shared utility in src/utils, focusing on HTML entity unescaping behavior.

Changes:

  • Added src/utils/common.test.ts with a unit test for unescapeHTML handling common HTML entities in children.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +1 to +11
import { describe, expect, it } from "vitest"
import { unescapeHTML } from "./common"

describe("common utilities", () => {
it("unescapes HTML entities in VNode children", () => {
const node = {
type: "div",
children: "&lt;b&gt;bold&lt;/b&gt; &amp; beautiful",
}
const result = unescapeHTML(node)
expect(result.children).toBe("<b>bold</b> & beautiful")
Copy link

Copilot AI Apr 4, 2026

Choose a reason for hiding this comment

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

This test file uses double quotes for imports/strings, but the repo’s formatter config prefers single quotes (see .prettierrc singleQuote:true) and existing utils tests follow that convention. Please reformat (or run pnpm format) so this file matches the enforced style and doesn’t fail format:check.

Suggested change
import { describe, expect, it } from "vitest"
import { unescapeHTML } from "./common"
describe("common utilities", () => {
it("unescapes HTML entities in VNode children", () => {
const node = {
type: "div",
children: "&lt;b&gt;bold&lt;/b&gt; &amp; beautiful",
}
const result = unescapeHTML(node)
expect(result.children).toBe("<b>bold</b> & beautiful")
import { describe, expect, it } from 'vitest'
import { unescapeHTML } from './common'
describe('common utilities', () => {
it('unescapes HTML entities in VNode children', () => {
const node = {
type: 'div',
children: '&lt;b&gt;bold&lt;/b&gt; &amp; beautiful',
}
const result = unescapeHTML(node)
expect(result.children).toBe('<b>bold</b> & beautiful')

Copilot uses AI. Check for mistakes.
Co-authored-by: daggerstuff <261005129+daggerstuff@users.noreply.github.com>
@vercel
Copy link
Copy Markdown

vercel bot commented Apr 4, 2026

Deployment failed with the following error:

Resource is limited - try again in 24 hours (more than 100, code: "api-deployments-free-per-day").

Learn More: https://vercel.com/daggers-projects-26434d0b?upgradeToPro=build-rate-limit

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/utils/common.test.ts`:
- Around line 4-13: Add expanded tests for unescapeHTML in
src/utils/common.test.ts to cover the missing edge cases: assert additional
entity types (&quot;, &#039;, &#x2F;, &#x3D;) are decoded by unescapeHTML;
verify array children are processed recursively (arrays with strings and
VNode-like objects passed to unescapeHTML); verify nested VNode children
(objects with children that are VNodes) are unescaped recursively; and add
edge-case tests for null/undefined node, empty children, and nodes with no
children property. Reference the unescapeHTML function in your new test cases
and ensure each scenario has an expectation that matches the implementation's
return shape (e.g., result.children is the unescaped string or array).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 68b7102b-e754-498f-8ed0-9beb576afca4

📥 Commits

Reviewing files that changed from the base of the PR and between 4787225 and 9d8d4af.

📒 Files selected for processing (1)
  • src/utils/common.test.ts

Comment on lines +4 to +13
describe("common utilities", () => {
it("unescapes HTML entities in VNode children", () => {
const node = {
type: "div",
children: "&lt;b&gt;bold&lt;/b&gt; &amp; beautiful",
}
const result = unescapeHTML(node)
expect(result.children).toBe("<b>bold</b> & beautiful")
})
})
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion | 🟠 Major

Expand test coverage to include edge cases and additional entity types.

The PR description states this adds tests "to cover missing edge cases," but currently only one basic happy-path test exists. The unescapeHTML implementation handles several scenarios not covered here:

Missing test cases:

  1. Additional entity types: &quot;, &#039;, &#x2F;, &#x3D; (implementation handles 7 entity types total, test only covers 3)
  2. Array children: Recursive processing of arrays containing strings and VNodes
  3. Nested VNode children: Recursive unescaping of nested object children
  4. Edge cases: null/undefined node, empty children, no children property
📝 Proposed additional test cases to improve coverage
 describe("common utilities", () => {
   it("unescapes HTML entities in VNode children", () => {
     const node = {
       type: "div",
       children: "&lt;b&gt;bold&lt;/b&gt; &amp; beautiful",
     }
     const result = unescapeHTML(node)
     expect(result.children).toBe("<b>bold</b> & beautiful")
   })
+
+  it("unescapes all supported HTML entities", () => {
+    const node = {
+      type: "div",
+      children: "&lt;&gt;&quot;&#039;&#x2F;&#x3D;&amp;",
+    }
+    const result = unescapeHTML(node)
+    expect(result.children).toBe("<>\"'/=&")
+  })
+
+  it("unescapes HTML entities in array children", () => {
+    const node = {
+      type: "div",
+      children: [
+        "&lt;text&gt;",
+        { type: "span", children: "&amp; more &quot;text&quot;" },
+      ],
+    }
+    const result = unescapeHTML(node)
+    expect(result.children).toEqual([
+      "<text>",
+      { type: "span", children: "& more \"text\"" },
+    ])
+  })
+
+  it("handles null or undefined nodes", () => {
+    expect(unescapeHTML(null as any)).toBe(null)
+    expect(unescapeHTML(undefined as any)).toBe(undefined)
+  })
+
+  it("handles nodes without children", () => {
+    const node = { type: "div" }
+    const result = unescapeHTML(node)
+    expect(result).toEqual({ type: "div" })
+  })
+
+  it("handles deeply nested VNode children", () => {
+    const node = {
+      type: "div",
+      children: {
+        type: "p",
+        children: {
+          type: "span",
+          children: "&lt;nested&gt; &amp; deep",
+        },
+      },
+    }
+    const result = unescapeHTML(node)
+    expect(result.children).toEqual({
+      type: "p",
+      children: {
+        type: "span",
+        children: "<nested> & deep",
+      },
+    })
+  })

Would you like me to open an issue to track these additional test cases?

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
describe("common utilities", () => {
it("unescapes HTML entities in VNode children", () => {
const node = {
type: "div",
children: "&lt;b&gt;bold&lt;/b&gt; &amp; beautiful",
}
const result = unescapeHTML(node)
expect(result.children).toBe("<b>bold</b> & beautiful")
})
})
describe("common utilities", () => {
it("unescapes HTML entities in VNode children", () => {
const node = {
type: "div",
children: "&lt;b&gt;bold&lt;/b&gt; &amp; beautiful",
}
const result = unescapeHTML(node)
expect(result.children).toBe("<b>bold</b> & beautiful")
})
it("unescapes all supported HTML entities", () => {
const node = {
type: "div",
children: "&lt;&gt;&quot;&#039;&#x2F;&#x3D;&amp;",
}
const result = unescapeHTML(node)
expect(result.children).toBe("<>\"'/=&")
})
it("unescapes HTML entities in array children", () => {
const node = {
type: "div",
children: [
"&lt;text&gt;",
{ type: "span", children: "&amp; more &quot;text&quot;" },
],
}
const result = unescapeHTML(node)
expect(result.children).toEqual([
"<text>",
{ type: "span", children: "& more \"text\"" },
])
})
it("handles null or undefined nodes", () => {
expect(unescapeHTML(null as any)).toBe(null)
expect(unescapeHTML(undefined as any)).toBe(undefined)
})
it("handles nodes without children", () => {
const node = { type: "div" }
const result = unescapeHTML(node)
expect(result).toEqual({ type: "div" })
})
it("handles deeply nested VNode children", () => {
const node = {
type: "div",
children: {
type: "p",
children: {
type: "span",
children: "&lt;nested&gt; &amp; deep",
},
},
}
const result = unescapeHTML(node)
expect(result.children).toEqual({
type: "p",
children: {
type: "span",
children: "<nested> & deep",
},
})
})
})
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/utils/common.test.ts` around lines 4 - 13, Add expanded tests for
unescapeHTML in src/utils/common.test.ts to cover the missing edge cases: assert
additional entity types (&quot;, &#039;, &#x2F;, &#x3D;) are decoded by
unescapeHTML; verify array children are processed recursively (arrays with
strings and VNode-like objects passed to unescapeHTML); verify nested VNode
children (objects with children that are VNodes) are unescaped recursively; and
add edge-case tests for null/undefined node, empty children, and nodes with no
children property. Reference the unescapeHTML function in your new test cases
and ensure each scenario has an expectation that matches the implementation's
return shape (e.g., result.children is the unescaped string or array).

Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-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.

No issues found across 1 file

Co-authored-by: daggerstuff <261005129+daggerstuff@users.noreply.github.com>
Co-authored-by: daggerstuff <261005129+daggerstuff@users.noreply.github.com>
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.

2 participants