Skip to content

test(core): stop the cursor-plan test expecting a collection walk for small terms - #3703

Merged
khoinguyenpham04 merged 2 commits into
emdash-cms:mainfrom
danielmlr:fix/loader-cursor-plan-taxonomy
Sep 30, 2026
Merged

khoinguyenpham04 merged 2 commits into
emdash-cms:mainfrom
danielmlr:fix/loader-cursor-plan-taxonomy

Conversation

@danielmlr

Copy link
Copy Markdown
Member

What does this PR do?

main has been red since #3402 merged: the two taxonomy cases in loader-cursor-plan.test.ts fail there (Test Shard (2/4)) and on PRs pushed since.

Two PRs that each passed CI on their own collided:

With 40 posts the category counts as small, so the loader seeks the pivot. The loader is right; the fixture is too small. This PR creates LARGE_TERM_ASSIGNMENTS posts, so these cases test the index walk again. The loader is unchanged.

Type of change

  • Bug fix
  • Feature (requires maintainer-approved Discussion)
  • Refactor (no behavior change)
  • Translation
  • Documentation
  • Performance improvement
  • Tests
  • Chore (dependencies, CI, tooling)

Checklist

  • I have read CONTRIBUTING.md
  • pnpm typecheck passes
  • pnpm lint passes
  • pnpm test passes (or targeted tests for my change)
  • pnpm format has been run
  • I have added/updated tests for my changes (if applicable)
  • User-visible strings in the admin UI are wrapped for translation (if applicable). Do not include messages.po changes except in translation PRs — a workflow extracts catalogs on merge to main. (n/a: no admin UI change)
  • I have added and reviewed the user-facing changeset (if this PR changes a published package) (n/a: test-only, no published package changes)
  • New features link to an approved Discussion: https://github.com/emdash-cms/emdash/discussions/... (n/a: test fix, not a feature)
  • I have included screenshots below if this PR changes the UI (n/a: no UI change)

AI-generated code disclosure

  • This PR includes AI-generated code — model/tool: Claude Opus 5.5 (Claude Code)

Screenshots / test output

  • On main, the plan sorts in a temporary B-tree instead of walking the index:
    CO-ROUTINE picked
    SEARCH ct USING COVERING INDEX idx_content_taxonomies_group_lookup (taxonomy_id=? AND collection=?)
    SEARCH r USING INDEX idx_ec_post_del_tg_locale (deleted_at=? AND translation_group=?)
    USE TEMP B-TREE FOR ORDER BY
    
    Paging is unaffected: without the plan assertions, each case returns all 40 posts once, over 8 pages.
  • With this PR, every page walks the index again, including the seek on descending pages that continue from an undated entry.
  • A fixture of LARGE_TERM_ASSIGNMENTS - 5 posts fails exactly these two cases again; reverting fix(core): page lists across empty sort values #3662's loader and query changes fails all four on the page count.
  • Small terms stay covered by "seeks a small term on the pivot for a published_at sort" in loader-taxonomy-pivot-plan.test.ts.

… small terms

The taxonomy cases in loader-cursor-plan.test.ts tag 40 posts with one
term and assert that every page walks the ec_post published_at index.
Since the small-term change (emdash-cms#3402), the loader walks ec_post only for a
term with at least LARGE_TERM_ASSIGNMENTS (200) pivot rows and seeks a
smaller term on the pivot, sorting just its entries. Both changes were
green on their own bases; together they fail both taxonomy cases on
main.

The fixture now creates LARGE_TERM_ASSIGNMENTS posts, so the taxonomy
cases keep exercising the walk this test guards, including the seek on
descending pages that continue from an undated entry. Small terms stay
covered by loader-taxonomy-pivot-plan.test.ts.
The fixture follows LARGE_TERM_ASSIGNMENTS, but the expected page count
divided it by the page size, which is exact only while the page size
divides the threshold. The last page can be partial, so the count now
rounds up and a retuned threshold keeps the test on what it guards.
@changeset-bot

changeset-bot Bot commented Sep 30, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 59ea008

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

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

This is the right fix for the right problem. Two independent PRs collided: #3662 added a test that asserted an index walk for a taxonomy-filtered published_at sort, and #3402 made that code path conditional on a term having at least LARGE_TERM_ASSIGNMENTS assignments. With only 40 tagged posts the term is small, the loader correctly seeks the pivot, and the plan assertions fail. Raising the fixture to LARGE_TERM_ASSIGNMENTS posts restores what the test was actually meant to exercise—the cursor-pagination plan shape on an index walk—without touching the loader.

I read the diff, the full test file, the loader source around LARGE_TERM_ASSIGNMENTS and buildTaxonomyPivotQuery, and the sibling loader-taxonomy-pivot-plan.test.ts. The small-term pivot path remains covered there, so this change doesn’t leave a gap. The new POSTS / PAGE_SIZE constants and the explanatory comment make the fixture boundary explicit. No production code, API contract, authorization boundary, locale filter, or logged-out query path is changed.

The PR is test-only, so no changeset is required and the author correctly marked those checklist items n/a. The formatting matches the repo’s tab convention. I found no issues to fix.

@emdashbot emdashbot Bot added review/approved Approved; no new commits since and removed review/needs-review No maintainer or bot review yet labels Sep 30, 2026
@danielmlr danielmlr added the ci:run Approve and re-run CI on the PR's latest commit label Sep 30, 2026
@github-actions github-actions Bot removed the ci:run Approve and re-run CI on the PR's latest commit label Sep 30, 2026
@danielmlr danielmlr added the ci:run Approve and re-run CI on the PR's latest commit label Sep 30, 2026
@github-actions github-actions Bot removed the ci:run Approve and re-run CI on the PR's latest commit label Sep 30, 2026
@khoinguyenpham04
khoinguyenpham04 self-requested a review September 30, 2026 20:34

@khoinguyenpham04 khoinguyenpham04 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks!

@khoinguyenpham04
khoinguyenpham04 merged commit b22976d into emdash-cms:main Sep 30, 2026
64 of 68 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants