Skip to content

test(text-editor): cover inlineImages validation and imagePasted suppression - #4176

Open
john-traas wants to merge 2 commits into
mainfrom
inline-image-config-tests
Open

test(text-editor): cover inlineImages validation and imagePasted suppression#4176
john-traas wants to merge 2 commits into
mainfrom
inline-image-config-tests

Conversation

@john-traas

@john-traas john-traas commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Follow-up test coverage for the inlineImages config (#4150), complementing the unit tests that merged with the feature.

What's covered

inlineImages.tagName validation guard (component-level, text-editor.spec.tsx)

  • A built-in tag name like img is rejected with a console error and the editor still renders — the runtime guard that protects plain-JS consumers, since a built-in tag name would hijack the sanitizer whitelist rules for that tag.
  • A valid custom element tag name is accepted silently.

imagePasted suppression (browser e2e, text-editor.e2e.tsx)

  • When inlineImages is configured, pasting an image file runs the upload lifecycle and the legacy imagePasted event never fires. This mutual-exclusivity contract previously existed only as a code comment in inserter.ts.
  • Positive control: without inlineImages, the same paste emits imagePasted — so the suppression assertion cannot pass vacuously.

Both suppression outcomes are synchronized on observable effects (the upload spy / the event itself), not sleeps. Mutation-checked: removing the suppressing return in handlePastedImages fails exactly the suppression test.

Out of scope: the paste→upload lifecycle tests (allowPasteImages gating, imageUploadingChange aggregation) are planned separately.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Added image-paste coverage for text editors, including inline image uploading and legacy event behavior.
    • Added support for configuring inline image handling in text-editor test scenarios.
  • Bug Fixes

    • Improved validation of custom element tag names, reporting invalid built-in names while preserving editor rendering.
    • Confirmed valid custom tag names work without console errors.

@coderabbitai

coderabbitai Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 7d523416-4850-49b8-91d1-d62ee7f4af98

📥 Commits

Reviewing files that changed from the base of the PR and between ebebd2d and f8e4a61.

📒 Files selected for processing (2)
  • src/components/text-editor/text-editor.e2e.tsx
  • src/components/text-editor/text-editor.spec.tsx

📝 Walkthrough

Walkthrough

The text editor test suites now pass inlineImages configuration through their factories. E2E tests cover image-paste events and uploads. Component tests cover built-in and custom-element tag-name validation.

Changes

Text editor inline-image coverage

Layer / File(s) Summary
Inline-image option and paste behavior
src/components/text-editor/text-editor.e2e.tsx
The E2E factory forwards inlineImages. Tests cover legacy imagePasted emission and configured inline-image uploads.
Inline-image tag-name validation
src/components/text-editor/text-editor.spec.tsx
Component tests cover console errors for built-in tags, adapter rendering after validation errors, and acceptance of valid custom-element names.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

Suggested reviewers: jecrapo

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the added tests for inlineImages validation and imagePasted suppression.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch inline-image-config-tests

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.

@github-actions

github-actions Bot commented Jul 9, 2026

Copy link
Copy Markdown

Documentation has been published to https://lundalogik.github.io/lime-elements/versions/PR-4176/

Copilot AI 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.

Pull request overview

Adds follow-up regression coverage for the inlineImages text-editor configuration introduced previously, focusing on runtime validation and event-contract behavior to protect plain-JS consumers and prevent legacy event leakage.

Changes:

  • Add component-level unit tests verifying inlineImages.tagName runtime validation rejects built-in tag names while still rendering the editor.
  • Add browser-style integration/e2e tests ensuring imagePasted fires only when inlineImages is not configured, and is suppressed when inline uploads are enabled.
  • Extend test helpers to pass the inlineImages prop through the shared createComponent factory.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/components/text-editor/text-editor.spec.tsx Adds unit tests for inlineImages.tagName runtime validation and confirms the editor still renders when config is rejected.
src/components/text-editor/text-editor.e2e.tsx Adds paste-flow coverage to assert imagePasted emits only in legacy mode and is suppressed when inlineImages.upload is configured.

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

@john-traas john-traas self-assigned this Jul 9, 2026
@john-traas
john-traas marked this pull request as ready for review August 10, 2026 09:24
@john-traas
john-traas requested a lite review from Copilot August 10, 2026 09:24

Copilot AI 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.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.

Suppressed comments (1)

src/components/text-editor/text-editor.spec.tsx:199

  • The test claims the custom element tag name is “accepted”, but the assertion only checks that console.error wasn’t called with the specific “not a valid custom element name” message. If some other console.error happens during render, the test would still pass (so it doesn’t actually verify “accepted silently”). Consider asserting that no console errors were logged for this case.
            expect(consoleErrorSpy).not.toHaveBeenCalledWith(
                invalidTagNameError
            );
        });

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