Skip to content

Reading-position tests expect missing quote and section fields #5074

Closed

Description

@leaf-agent

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

The tests fail while inspecting stored reading state: KeyError quote or section, before proving restoration. Read the current stored-view contract and the change that moved it; preserve the actual restoration guarantees when updating fixtures.

  • tests.browser.projection.test_reading_position::test_revision_changes_keep_the_complete_heading_below_user_chrome: KeyError: 'quote'
  • tests.browser.projection.test_reading_position::test_revision_changes_follow_authored_text_into_declared_shadow_trees: KeyError: 'quote'
  • tests.browser.projection.test_reading_position::test_the_reading_position_restores_onto_a_section_that_draws_no_box: KeyError: 'section'
Representative failing boundary
place to preserve.
    
        A revision change used the heading as its semantic landmark and restored its exact
        viewport coordinate. When the user had moved just far enough for the first title
        line to sit above the scroller's landable top (then under the fixed banner), both
        an arriving current revision and a chosen historical version faithfully restored
        that broken view: the later line looked like the whole heading. The scroller
        declares its landable top through scroll-padding, so a heading landmark must honor
        that edge while ordinary passage landmarks retain their exact coordinate.
        """
        title = "The page should own the complete one-off playground"
        revised_title = "The complete one-off playground belongs to the page"
        first = leaf_page(
            "Heading continuity",
            f"""
    <header id="summary">
      <p class="eyebrow">Playground replacement audit</p>
      <h1>{title}</h1>
      <p>The opening account is long enough to become the next reading landmark.</p>
    </header>
    <div style="height: 1200px"></div>
    """,
        )
        version_url = serve(first)
        page = open_page(browser, live_url(version_url))
        resized(page, 668, 704)
    
        # The heading's first line stands 12px above the landable top the scroller's
        # scroll-padding declares, the rest of it below.
        clip_heading = """() => {
              const heading = document.querySelector('#summary h1');
              const inset = parseFloat(
                getComputedStyle(document.scrollingElement).scrollPaddingTop
              );
              document.scrollingElement.scrollBy({
                top: heading.getBoundingClientRect().top - inset + 12,
                behavior: 'instant',
              });
              const title = heading.getBoundingClientRect();
              const summary = document.getElementById('summary').getBoundingClientRect();
              return {title: title.toJSON(), summary: summary.toJSON(), inset};
            }"""
        heading_position = """() => {
              const title = document.querySelector('#summary h1').getBoundingClientRect();
              const inset = parseFloat(
                getComputedStyle(document.scrollingElement).scrollPaddingTop
              );
              return {
                title: title.toJSON(),
                inset,
                live: document.documentElement.hasAttribute('data-lf-live'),
              };
            }"""
    
        clipped = page.evaluate(clip_heading)
        assert clipped["title"]["top"] < clipped["inset"], clipped
        assert clipped["title"]["bottom"] > clipped["inset"], clipped
    
        # The producer owns the invariant: a saved semantic heading coordinate is never
        # inside the chrome, so in-place activation and document travel consume the same
        # valid view rather than each repairing it independently.
        page.evaluate("dispatchEvent(new PageTransitionEvent('pagehide'))")
        view = page.evaluate(
            """() => {
              for (const key of Object.keys(sessionStorage))
                if (key.endsWith('lf-view')) return JSON.parse(sessionStorage[key]);
              return null;
            }"""
        )
>       assert view["quote"].startswith(title), view
               ^^^^^^^^^^^^^
E       KeyError: 'quote'

/home/runner/work/leaf/leaf/tests/browser/projection/test_reading_position.py:391: KeyError

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 4, 2026

    @leaf-agent
    CollaboratorAuthor

    This is a stale test contract, not a product regression. #4873 moved the page's reading in the stored lf-view under page, beside revision and regions. Restoration reads that new shape, but these three tests still read quote and section from the top level. All three failed with this KeyError on current main, and they pass once they read .page, including their checks that the reading position comes back after the revision changes.

    #5330 carries the fix and is green on CI. My merge attempt got repeated GitHub 502 / "merge already in progress" responses, so the queued tend-land run will make the pinned merge, and this issue closes when it lands.

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