Skip to content

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

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

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

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

@coderabbitai

coderabbitai Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 974bfefa-e85c-4e28-b8c1-8314bba0d653

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 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
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