test(text-editor): cover inlineImages validation and imagePasted suppression - #4176
test(text-editor): cover inlineImages validation and imagePasted suppression#4176john-traas wants to merge 2 commits into
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThe text editor test suites now pass ChangesText editor inline-image coverage
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
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. Comment |
|
Documentation has been published to https://lundalogik.github.io/lime-elements/versions/PR-4176/ |
There was a problem hiding this comment.
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.tagNameruntime validation rejects built-in tag names while still rendering the editor. - Add browser-style integration/e2e tests ensuring
imagePastedfires only wheninlineImagesis not configured, and is suppressed when inline uploads are enabled. - Extend test helpers to pass the
inlineImagesprop through the sharedcreateComponentfactory.
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.
There was a problem hiding this comment.
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
);
});
Follow-up test coverage for the
inlineImagesconfig (#4150), complementing the unit tests that merged with the feature.What's covered
inlineImages.tagNamevalidation guard (component-level,text-editor.spec.tsx)imgis 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.imagePastedsuppression (browser e2e,text-editor.e2e.tsx)inlineImagesis configured, pasting an image file runs the upload lifecycle and the legacyimagePastedevent never fires. This mutual-exclusivity contract previously existed only as a code comment ininserter.ts.inlineImages, the same paste emitsimagePasted— 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
returninhandlePastedImagesfails exactly the suppression test.Out of scope: the paste→upload lifecycle tests (
allowPasteImagesgating,imageUploadingChangeaggregation) are planned separately.🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Bug Fixes