Skip to content

test(content): state which branch the Fix run's Length hint test takes (#1553 review) - #1558

Merged
gkhngyk merged 1 commit into
ansvisor:mainfrom
cihan-gyk:chore/over-length-test-branch
Oct 27, 2026
Merged

gkhngyk merged 1 commit into
ansvisor:mainfrom
cihan-gyk:chore/over-length-test-branch

Conversation

@cihan-gyk

Copy link
Copy Markdown
Collaborator

Summary

Follow-up to #1553's review. The editor test "tells a Fix run how far past its Length the page is when it doesn't send the Length" accepted either outcome:

  • the Length sent as a rule, with no hint;
  • or the Length held, with the hint.

In its fixture the page is far past a 20-character Length, so the Length is held and only the second branch ran. If the fixture changed so the Length wasn't held, the test would still pass but stop checking the call.

Now it states the branch:

expect(sent.rules.map((r: { key: string }) => r.key)).not.toContain('length');
expect(sent.overLength).toEqual({ count: expect.any(Number), max: 24 });

Test only; no behavior change.

Related issue

Follow-up to #1553 (review item 1).

Type of change

  • feat — New feature
  • fix — Bug fix
  • chore — Maintenance / dependencies
  • docs — Documentation only
  • refactor — Code change that neither fixes a bug nor adds a feature
  • test — Adding or updating tests

How to test

cd web && yarn vitest run 'src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/page.test.tsx' -t "how far past its Length"

Checklist

  • Branch follows the naming convention (feature/, fix/, chore/, docs/) — see CONTRIBUTING.md
  • Commits follow Conventional Commits
  • yarn lint passes (run from web/)
  • yarn typecheck passes (run from web/)
  • yarn format:check passes (run from web/)
  • Changes are focused — one concern per PR

Also run: yarn test (427 files, 4,080 tests) and yarn build, both pass.

🤖 Generated with Claude Code

@gkhngyk gkhngyk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good, with a follow-up.

The #1553 review's item (state which branch the Fix test takes) is done.

What I checked:

  • The assertions fit the fixture.
    • The Length is 20, so the top of its band is lengthBand(20).max, which is round(20 × 1.2) = 24. overLengthFor sends the status's max as it is.
    • The page counts 53 characters: the H1's 20 and the paragraph's 33. So the Length is open as long.
    • The Length is held. With no last rewrite, lengthOutOfReach holds it when the rewrite floor is past 24. Here rewriteFloor comes to 120: the H1's 20 plus the least summary (LEAST_SUMMARY, 100), because the Summary rule is on by default.
    • So the Fix run sends no Length rule, and overLengthFor gives { count: 53, max: 24 }. toEqual matches it exactly, with no other key.
  • It passes on main and fails without the hint.
    • The two new lines are the old else branch plus the opposite of the old if. In this fixture only the else ran, so the test passes on main's code as it did before.
    • Main's web hasn't changed since the PR's base. 3b650fb changed only server files.
    • If the hint were dropped, by overLengthFor or by the Fix call (_draft-editor.tsx:2402-2405), sent.overLength is undefined and the second line fails.
    • If the Length stopped being held and were sent as a rule, the first line fails. The old test passed in that case.
    • I read the test but didn't run it.
  • Merge.
    • One commit on top of main. It merges cleanly, and only the test file changes.
    • It also merges cleanly with #1560, the other open PR that edits page.test.tsx. #1560 doesn't change how the Fix run holds the Length or sends the hint.
    • Test only. Users see nothing, and nothing depends on the API deploy.

Follow-up:

  1. The comment gives the wrong reason for the hold (page.test.tsx:6946).
    • Being far past the Length isn't why it's held. A page far past its Length still gets the rule sent when a rewrite could reach it: that's the other branch.
    • It's held here because a rewrite keeps the H1 and writes at least a summary, 120 characters, which is past the top of 24.
    • Fix:
      // A rewrite keeps the H1 and writes a summary, at least 120 characters, past the
      // Length's top of 24: the Length is held from Fix, and the hint goes instead.

@gkhngyk
gkhngyk merged commit 0ef6e97 into ansvisor:main Oct 27, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants