Skip to content

Failing backend test: setHTML returns code:1 on complex nested lists #7786

@JohnMcLear

Description

@JohnMcLear

Failing test: Tests > Sets the HTML of a Pad attempting to pass ugly HTML and Tests > Pad with complex nested lists of different types and Tests > Pad with white space between list items
File: src/tests/backend/specs/api/pad.ts:462-505
Status on develop HEAD (b96e262): these three tests fail with the same shape — reproducible locally.

Note: the first two of the three were already failing on develop before any other recent change. The middle one (Pad with complex nested lists of different types) is the most informative; the diff makes the root cause obvious.

What's failing

The tests call setHTML with various HTML payloads, then re-fetch via getHTML and compare the result. Two distinct symptoms appear:

  1. res.body.code is 1 instead of 0 (the setHTML / getHTML round-trip is signalling an error from the API).
  2. When the response IS received, the HTML output of nested ordered lists drops the start attribute on the inner <ol>:
- expected:  <ol start="1" class="number"><li>item<ol start="2" class="number"><li>item1
+ actual:    <ol start="1" class="number"><li>item<ol class="number"><li>item1

The inner <ol> should carry start="2" (continuing the outer numbering); the export pipeline emits it without a start attribute.

Where to look

The first symptom (code:1) suggests setHTML itself is rejecting the input — likely in the HTML → changeset path (src/node/utils/ImportHtml.tspad.appendRevision).

The second symptom (missing start="2") is purely on the export side — src/node/utils/ExportHtml.ts walks attribs to build the nested <ol> tree and isn't propagating the start index into the nested element.

Reproduction

NODE_ENV=production npx mocha --import=tsx --require ./tests/backend/diagnostics.ts \
    --timeout 60000 tests/backend/specs/api/pad.ts

Look for Sets the HTML of a Pad attempting to pass ugly HTML, Pad with complex nested lists of different types, and Pad with white space between list items.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions