Skip to content

test(superdoc): raise package coverage to 90%#2836

Merged
caio-pizzol merged 6 commits into
mainfrom
caio/superdoc-coverage-tests
Apr 16, 2026
Merged

test(superdoc): raise package coverage to 90%#2836
caio-pizzol merged 6 commits into
mainfrom
caio/superdoc-coverage-tests

Conversation

@caio-pizzol

@caio-pizzol caio-pizzol commented Apr 16, 2026

Copy link
Copy Markdown
Contributor

Adds tests for parts of the SuperDoc package that weren't covered before. Test coverage goes from 78.6% to 90.1%, hitting the 90% target set up by #2831.

New tests cover:

  • PDF viewing (opening files, rendering pages, handling errors)
  • Whiteboard drawing, text, and sticker tools
  • Comments (creating, resolving, mentions, grouping)
  • Form fields, AI writer, and document users list
  • Store actions (reset, page tracking, error handling)

No changes to shipped code — tests only.

Adds test coverage for previously untested files:
- core/pdf/pdf-adapter.js — factory, adapter, CDN worker helper
- components/CommentsLayer/use-conversation.js — conversation composable
- components/CommentsLayer/use-floating-comment.js — floating comment state
- components/CommentsLayer/CommentGroup.vue — grouped comment rendering
- components/PdfViewer/PdfViewer.vue — top-level viewer with adapter mocks
- components/PdfViewer/PdfViewerDocument.vue — page list wrapper
- components/PdfViewer/PdfViewerPage.vue — page render + text layer

62 new tests. Lifts filtered coverage from 78.6% to 81.1%.
- composables/use-field.js — useField + sub-handlers (SELECT/IMAGE/CHECKBOX)
- composables/use-ai.js — AI writer cursor positioning, fallbacks, tool click
- components/CommentsLayer/commentsList/super-comments-list.js — Vue app lifecycle
- components/Whiteboard/use-whiteboard.js — event wiring, page ready, teardown

46 new tests. Lifts filtered coverage 81.1% → 83.3%.
Mock Konva Stage/Layer/Line/Text/Image/Transformer and trigger
stage/text-node event listeners to exercise the interactive code
paths: draw/erase flows, stage click handlers (text + select),
text node selection + drag + Delete, image node events.

38 tests. Lifts WhiteboardPage coverage 40% → 81%, package 83.3% → 88.5%.
The word-diff executor added in #2817 calls `tr.doc.textBetween(...)` and
`tr.doc.nodesBetween(...)` in the text.rewrite path, but the `tr.doc`
mocks in determinism-stress, executor, and preview-parity tests were
never updated to match. That broke determinism-stress, executeCompiledPlan,
previewPlan, and revision-drift-guard tests on main with `TypeError:
tr.doc.textBetween is not a function` / `doc.nodesBetween is not a function`.
Add targeted tests to close remaining gaps:
- use-comment extended — resolveComment, setIsInternal, setText, mentions
- superdoc-store extended — reset, getDocument, handlePageReady, getPageBounds,
  areDocumentsReady, setExceptionHandler, collaboration mode
- Whiteboard extended — tool/enabled propagation, opacity clamping, callbacks
- New small files: comment-schemas, DocumentUsers.vue, SuperToolbar.vue,
  use-selection, CommentsLayer/helpers formatDate

Lifts package coverage from 83.3% to 90.1%.
@caio-pizzol
caio-pizzol merged commit e5829cf into main Apr 16, 2026
49 of 55 checks passed
@caio-pizzol
caio-pizzol deleted the caio/superdoc-coverage-tests branch April 16, 2026 01:20

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a34649971e

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines +120 to +121
document.body.appendChild(container);
page.mount(container);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Add teardown for mounted WhiteboardPage instances

This helper mounts WhiteboardPage instances but never destroys them, and WhiteboardPage.mount() registers a global window keydown listener that is only removed by destroy(). Because this file mounts many pages and also dispatches Delete key events, stale listeners from earlier tests can keep firing against old page state, creating order-dependent/flaky behavior and hidden side effects across tests; adding per-test cleanup (page.destroy() and DOM removal) will keep the suite isolated.

Useful? React with 👍 / 👎.

@superdoc-bot

superdoc-bot Bot commented Apr 16, 2026

Copy link
Copy Markdown
Contributor

🎉 This PR is included in @superdoc-dev/react v1.2.0-next.16

The release is available on GitHub release

@superdoc-bot

superdoc-bot Bot commented Apr 16, 2026

Copy link
Copy Markdown
Contributor

🎉 This PR is included in vscode-ext v2.3.0-next.19

@superdoc-bot

superdoc-bot Bot commented Apr 16, 2026

Copy link
Copy Markdown
Contributor

🎉 This PR is included in template-builder v1.5.0-next.19

The release is available on GitHub release

@superdoc-bot

superdoc-bot Bot commented Apr 16, 2026

Copy link
Copy Markdown
Contributor

🎉 This PR is included in esign v2.3.0-next.19

The release is available on GitHub release

@superdoc-bot

superdoc-bot Bot commented Apr 16, 2026

Copy link
Copy Markdown
Contributor

🎉 This PR is included in superdoc v1.26.0-next.19

The release is available on GitHub release

@superdoc-bot

superdoc-bot Bot commented Apr 16, 2026

Copy link
Copy Markdown
Contributor

🎉 This PR is included in superdoc-cli v0.7.0-next.20

The release is available on GitHub release

@superdoc-bot

superdoc-bot Bot commented Apr 16, 2026

Copy link
Copy Markdown
Contributor

🎉 This PR is included in superdoc-sdk v1.6.0-next.17

@superdoc-bot

superdoc-bot Bot commented Apr 17, 2026

Copy link
Copy Markdown
Contributor

🎉 This PR is included in superdoc-cli v0.7.0

The release is available on GitHub release

@superdoc-bot

superdoc-bot Bot commented Apr 17, 2026

Copy link
Copy Markdown
Contributor

🎉 This PR is included in superdoc v1.27.0

The release is available on GitHub release

@superdoc-bot

superdoc-bot Bot commented Apr 21, 2026

Copy link
Copy Markdown
Contributor

🎉 This PR is included in @superdoc-dev/react v1.2.0

The release is available on GitHub release

@superdoc-bot

superdoc-bot Bot commented Apr 22, 2026

Copy link
Copy Markdown
Contributor

🎉 This PR is included in superdoc-sdk v1.6.0

@superdoc-bot

superdoc-bot Bot commented May 5, 2026

Copy link
Copy Markdown
Contributor

🎉 This PR is included in vscode-ext v2.3.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant