Skip to content

Draft round-trip and submission assertions disagree on line breaks #5075

Closed

Description

@leaf-agent

Push run 41395985405, at 5d7e533eb225, records the following failures.

The print/round-trip checks flatten a newline to a space, while submit and touch-return checks see an extra newline. These are separate observed boundaries; determine whether the shared text serialization explains both before grouping the fix.

  • tests.browser.drafts.test_draft_editing::test_double_clicking_a_draft_keeps_its_frame_and_selected_word: AssertionError: the printed page lost the draft's words to a box paper hasn't got assert 'Run the migr...It is online.' == 'Run the migr...It is online.' - Run the migration before deploying. ? ^ + Run the migration before deploying. It is online. ? ^^^^^^^^^^^^^^ - It is online.
  • tests.browser.drafts.test_round_trip::test_page_round_trip: AssertionError: assert 'Run the migr...It is online.' == 'Run the migr...It is online.' - Run the migration before deploying. ? ^ + Run the migration before deploying. It is online. ? ^^^^^^^^^^^^^^ - It is online.
  • tests.browser.navigation.test_commenting::test_submit_shortcuts_activate_the_controls_that_promise_the_action: AssertionError: Locator expected to have JS Property 'Save through the visible control. Keep the second line.' Actual value: Save through the visible control. Keep the second line. Call log: - Expect "to_have_property" locator("#plan leaf-text") with timeout 120000ms - waiting for locator("#plan leaf-text") 242 × locator resolved to <leaf-text tabindex="0" role="textbox" data-lf-gen="1" data-lf-offer="" data-lf-focus="" data-lf-runtime="" aria-multiline="true" data-lf-focus-within="" data-lf-focus-visible="" aria-label="Edit the draft" data-lf-focus-visible-within="" class="lf-draft-edit lf-ui scroll" aria-keyshortcuts="Meta+Enter C
  • tests.browser.navigation.test_commenting::test_touch_return_keeps_newlines_until_the_user_taps_submit: AssertionError: Locator expected to have JS Property 'First paragraph Second paragraph' Actual value: First paragraph Second paragraph Call log: - Expect "to_have_property" locator("#plan leaf-text") with timeout 120000ms - waiting for locator("#plan leaf-text") 243 × locator resolved to - un
Representative failing boundary
t.createRange();
                r.setStart(node, at); r.setEnd(node, at + word.length);
                const b = r.getBoundingClientRect();
                return [b.x + b.width / 2, b.y + b.height / 2];
            }""",
            "migration",
        )
        page.mouse.dblclick(*spot)
        editor = page.locator("#draft-ops leaf-text")
        expect(editor).to_be_focused()
        pencil = draft_control(page, "edit", "draft-ops")
        assert page.screenshot(clip=band) == outside_before, (
            "opening the editor painted outside the box the draft already occupied"
        )
        assert page.screenshot(clip=inside) != inside_before, (
            "the open editor is indistinguishable from the read view at the box's edge"
        )
        edited = page.evaluate(metrics, "leaf-text")
        assert edited == read, (
            "the editor moved, narrowed or changed the height of the draft's words"
        )
        assert page.locator("#draft-ops").bounding_box() == host, (
            "the draft changed shape under the pointer when the editor opened"
        )
        assert (
            page.evaluate(
                "() => getSelection().rangeCount > 0 && "
                "getSelection().containsNode(document.querySelector('#draft-ops .lf-draft-body'), true)"
            )
            is False
        ), "the gesture left the page's own words selected under the open editor"
        selected = page.evaluate(
            "() => { const t = document.querySelector('#draft-ops leaf-text');"
            "        return t.value.slice(t.selectionStart, t.selectionEnd); }"
        )
        assert selected == "migration", (
            f"the box opened on {selected!r} rather than the word clicked"
        )
    
        # Closing states both properties in reverse, and the focus half is a question
        # only because the ✎ is CSS-hidden for as long as the editor is there: #close
        # reaches for it the instant the editor goes, so a style that hadn't caught up
        # would drop a keyboard user back at the top of the page.
        page.keyboard.press("Escape")
        expect(pencil).to_be_focused()
        expect(pencil).to_have_attribute("aria-expanded", "false")
        assert page.locator("#draft-ops").bounding_box() == host, (
            "the draft came back from an edit a different shape than it went in"
        )
    
        # Reopened through the other door, because print is where the box has to be
        # gone and its words still there — and print emulation blurs the leaf-text it
        # hides, so an editor opened before this point is no longer one Escape closes.
        draft_control(page, "edit", "draft-ops").click()
        expect(page.locator("#draft-ops leaf-text")).to_be_visible()
        page.emulate_media(media="print")
>       assert page.locator("#draft-ops").inner_text() == DRAFT_TEXT, (
            "the printed page lost the draft's words to a box paper hasn't got"
        )
E       AssertionError: the printed page lost the draft's words to a box paper hasn't got
E       assert 'Run the migr...It is online.' == 'Run the migr...It is online.'
E         
E         - Run the migration before deploying.
E         ?                                    ^
E         + Run the migration before deploying. It is online.
E         ?                                    ^^^^^^^^^^^^^^
E         - It is online.

/home/runner/work/leaf/leaf/tests/browser/drafts/test_draft_editing.py:138: AssertionError

This session read the CI evidence but ran no local reproduction. Reconcile current main, later repairs and active work first; reproduce the focused boundary and read the introducing change’s intent before choosing a repair. Preserve the user behavior, and distinguish a stale test contract from a product regression. A passing attempt alone does not retire an intermittent failure.

Cause of a failure tracked in #3985.

Activity

  1. added
    tend-ci-cause
    on Nov 2, 2026
  2. leaf-agent commented on Nov 2, 2026

    @leaf-agent
    CollaboratorAuthor

    An additional older consumer to reconcile: push run 41346283661 fails tests/browser/test_render_send_placement.py::test_a_reply_written_in_a_card_keeps_its_line_breaks_once_sent[mouse] at its expected-versus-actual line list. It is absent from the newest run's failure list. This report session has not established whether it shares the draft serialization cause, or whether a later change repaired it; retain it as a separate observation until reproduction establishes that connection. The run's failed log and JUnit artifact contain the full line-list diff.

  3. leaf-agent commented on Nov 4, 2026

    @leaf-agent
    CollaboratorAuthor

    The tests were out of date; the drafts behave as #4872 intended. That PR made a draft read as Markdown: a line break inside a paragraph draws as a space, which explains the print and round-trip failures. Return or Shift+Enter after a paragraph's last words now starts a new paragraph (\n\n), which explains the submit and touch failures. #5333 updates the four tests to expect this and is now merged. All four failed locally on main and pass on the fix, and the PR's CI was green at its head.

    test_a_reply_written_in_a_card_keeps_its_line_breaks_once_sent[mouse], from the earlier comment, has a separate cause. Under a mouse, the sent message wraps one word earlier than the reply editor did, so the card's message column is slightly narrower than the reply field's. It still fails on main and is now tracked in #5332.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    tend-ci-cause

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions