Skip to content

test(content): pin where the agent's product grid goes when the most-linked section isn't the last - #1653

Merged
gkhngyk merged 1 commit into
ansvisor:mainfrom
cihan-gyk:test/shopping-grid-placement
Oct 28, 2026
Merged

gkhngyk merged 1 commit into
ansvisor:mainfrom
cihan-gyk:test/shopping-grid-placement

Conversation

@cihan-gyk

Copy link
Copy Markdown
Collaborator

Summary

Follow-up from #1607 (item 2): the test now pins where the Content Agent puts its product grid when the most-linked section isn't the last one.

The grid goes at the end of the H2 section that links the path's products most. In the existing tests, that section was always the one just before the FAQ. So the tests still passed if the grid always went before the last H2, or after the first section that links any product.

The new test page links one product before the most-linked section and one after it, with another section and the FAQ last. A second case has two sections that link products equally often; the first of them wins.

Each of these wrong placements fails the new test (checked by breaking the code on purpose, then putting it back):

  • the grid always before the last H2;
  • the grid after the first section that links any product;
  • the later of two sections on a tie.

Test only, no behaviour change.

Related issue

Follow-up from #1607's review.

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 server && npx vitest run src/lib/shopping-blocks.test.js

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

Full checks were run in one tree with this batch's six follow-up branches merged:

  • server: 3,347 tests passed. Three files (content-agent, content-people, page-content) timed out under load; each passed when run alone.
  • web: 4,347 tests passed, plus typecheck, lint (0 errors) and build.

The branch prefix is test/, matching the commit type.

🤖 Generated with Claude Code

…linked section isn't the last

Follow-up from ansvisor#1607 (item 2). The grid goes at the end of the H2 section
that links the path's products most. In the tests that section was always
the one before the FAQ, so the tests still passed if the grid always went
before the last H2, or after the first section that links any product.

A page now links one product before the most-linked section and one after
it, with a section and the FAQ last; and two sections that link them as
often take the first. Each of these breaks the new test: the grid before
the last H2 always, after the first section that links any, and the later
of two on a tie.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

@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.

What I checked:

  • Own change. 5f9ebba on main (3f6a4d4), one test file. It merges cleanly on main and with #1654, #1662, #1663 and #1664.
  • The test pins the placement. On this head, shopping-blocks.test.js passes (12 tests). With insertProductGrid broken on purpose, the new test fails each time:
    • the grid always before the last H2;
    • the grid after the first section that links a product;
    • the later of two sections on a tie (>= for >);
    • the grid after the last section that links a product (this one also fails the older test).
  • The tie case's regex tells the two sections apart by their last link (p2 in "Picks", p1 in "More"), so a grid after "More" can't match it.

Before the API deploy: test only, nothing changes.

@gkhngyk
gkhngyk merged commit 35209c9 into ansvisor:main Oct 28, 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