Repository navigation
test(e2e): add image rendering and TOC sidebar smoke tests - #4441
Closed
rkristelijn wants to merge 1 commit into
Closed
rkristelijn wants to merge 1 commit into
rkristelijn wants to merge 1 commit into
Conversation
These tests verify that: - Images render as visible <img> elements in the editor - TOC sidebar populates with heading entries from the document Currently failing due to the @muyajs/core migration (efcaf0c) breaking image loading and TOC generation.
3 of 6 tasks
3 tasks done
Jocs
pushed a commit
that referenced
this pull request
Jun 18, 2026
…4448) * fix: populate the table of contents on open and fix link navigation The @muyajs/core migration broke table-of-contents generation (see #4441): the sidebar TOC stayed empty until the first edit, and clicking a TOC entry did not scroll to the heading (the click-to-navigate behaviour requested in - Seed the TOC from the engine on file load and on tab switch. The engine emits no json-change in those paths, so listToc/toc remained empty until a document change occurred. - Resolve TOC link clicks by heading order. @muyajs/core slugs are stable per-block ids that are not stamped onto the heading DOM, so a `#slug` selector never matched; walk the headings in document order and map the slug to its index instead. Refs #2992 Refs #4441 * fix(toc): scope heading navigation to top-level headings Address review on #4448: scrollToHeader resolved a slug to its index in listToc, then indexed querySelectorAll('h1..h6'). getTOC only walks top-level scrollPage children (no recursion), so headings nested in blockquotes/list items or inside raw-HTML blocks were counted by the DOM but not by getTOC, shifting every later index and scrolling to the wrong heading. Scope the DOM query to direct-child headings (:scope > h1..h6) so the DOM set matches getTOC's set by construction. Extract the resolution into a pure resolveTocHeadingElement (util/tocNavigation.ts) so it is unit testable. Also from the review: - extract a shared scrollElementIntoView(el) helper, de-duping the getBoundingClientRect + animatedScrollTo math between scrollToHeader and scrollToElement - reword the UPDATE_TOC JSDoc: it is an unconditional re-seed on load/switch, drop the inaccurate deep-equal 'subset' rationale - add toc-navigation.spec.ts covering UPDATE_TOC (seed + unconditional re-seed) and the slug->index resolution, pinning the nested / raw-HTML heading edge case (no longer relying on the unmerged #4441 e2e) Refs #4448 * fix(toc): anchor heading query on .mu-container, not the scroll root Runtime verification (opening a doc and clicking a TOC entry) surfaced that the previous ':scope > hN' selector matched zero headings: the scroll container returned by getScrollContainer() is muya's root (.mu-editor), which WRAPS the scrollPage root (.mu-container) whose direct children are the top-level blocks. The headings are one level deeper than ':scope >' looked, so the click resolved to nothing and the editor never scrolled. Anchor the selector on '.mu-container > hN' so it matches the top-level headings wherever .mu-container sits under the scroll container, while still excluding nested (blockquote/list) and raw-HTML headings. Update the unit fixture to mirror the real .mu-editor > .mu-container > heading nesting so a regression to a scroller-scoped selector is caught. Verified in-app: TOC seeds with the 3 top-level headings on open, and clicking 'Top Two' scrolls it to the target offset (y=320) past the interleaved blockquote/raw-HTML headings. Refs #4448
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds two e2e smoke tests that verify core rendering still works after engine changes:
link-image.md, asserts<img>is visible in the editorheadings.md, opens TOC sidebar, asserts heading entries appearWhy
The
@muyajs/coremigration (efcaf0c2) broke image loading and TOC generation. These tests would have caught the regression.Status
These tests are expected to fail on current develop until the image/TOC regression is fixed. They serve as a regression gate for future engine changes.
Files
test/e2e/image-toc-render.spec.tstest/e2e/data/headings.md