Skip to content

Folio rename decl/rename tests never exercise a non-contact-length leaf - #196

Merged
mikebronner merged 2 commits into
mainfrom
chore/191-folio-rename-decl-tests-non-contact-leaf
Jun 16, 2026
Merged

mikebronner merged 2 commits into
mainfrom
chore/191-folio-rename-decl-tests-non-contact-leaf

Conversation

@mikebronner

@mikebronner mikebronner commented Jun 16, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Implements #191 — closes the span-length blind spot in the Folio rename test suite.

Every test that drives the production decl/rename logic seeded a contact leaf (7 chars), so the re-read name('...') span always coincided with the NAME_START/NAME_END constants. A span-computation regression for a different name length would have passed green. This adds two tests that drive the same production functions against a 9-char dashboard leaf and assert the literal columns the page body dictates.

Changes

Acceptance Criteria

  • seed_page writes <?php name('<leaf>'); ?> derived from the actual leaf segment, so body and route-index key stay consistent for any leaf length; existing contact/admin.contact tests pass unchanged. (Already satisfied by PR seed_page still hardcodes contact-specific page content and uri that don't track route_name #190 — verified, no change needed.)
  • A new #[tokio::test] drives decl_range_at with a non-contact-length leaf (dashboard, 9 chars), asserting the returned Range covers columns 12..21, NOT the NAME_START/NAME_END constants.
  • A new #[tokio::test] drives collect_route_declaration_targets with the same leaf, asserting start_column == 12 and end_column == 21 on the returned EditTarget.
  • cargo test -p laravel-lsp folio_rename passes with all tests green (14 tests: 2 new + 12 pre-existing).

Test Plan

  • cargo test -p laravel-lsp folio_rename — 14 passed, 0 failed.
  • cargo fmt --check — clean.
  • cargo clippy --tests -p laravel-lsp — no new lints.

Fixes #191

…-length leaf

Every Folio decl/rename test seeds a `contact` leaf (7 chars), so they all
re-read a span that coincides with the `NAME_START`/`NAME_END` constants — a
span-computation bug for a different name length would still pass green.

Add two tests driving the production decl logic with a 9-char `dashboard`
leaf, asserting the *literal* columns the page body dictates:

- `decl_range_at_returns_the_page_name_span_for_a_non_contact_length_leaf`
  asserts the prepare_rename range covers columns 12..21.
- `collect_targets_rewrites_a_non_contact_length_leaf_declaration` asserts
  the EditTarget's start_column == 12 and end_column == 21.

Neither references NAME_START/NAME_END, so a span regression for another
name length now fails red instead of passing by coincidence. seed_page
already derives the body from the leaf (PR #190), so no helper change is
needed.

Fixes #191
@mikebronner
mikebronner marked this pull request as ready for review June 16, 2026 18:08

@mr-sherlock-holmes mr-sherlock-holmes Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

✅ Approved

Review Summary

  • Test-only PR (+86 −0): two new #[tokio::test]s in laravel-lsp/src/tests/folio_rename.rs that drive the Folio decl/rename logic against a 9-char dashboard leaf instead of the 7-char contact leaf every other test uses — closing the span-length blind spot #191 flagged.
  • AC #1 — met (by existing state, noted divergence). The AC anticipated seed_page being updated to derive the body from the leaf; that update already landed in PR #190 (closing #188). seed_page writes format!("<?php name('{leaf}'); ?>") (folio_rename.rs:91) from the leaf at :88, so no change was needed here — the new tests confirm it produces name('dashboard') for a dashboard leaf, and the pre-existing contact/admin.contact tests stay green. Intent satisfied; flagging the divergence for the record.
  • AC #2 — met. decl_range_at_returns_the_page_name_span_for_a_non_contact_length_leaf asserts the returned Range is start character: 12, end character: 21 as hardcoded literals, not NAME_START/NAME_END. Column math checks out: in <?php name('dashboard'); ?> the 9-char content sits at cols 12..=20, quote-excluded span 12..21.
  • AC #3 — met. collect_targets_rewrites_a_non_contact_length_leaf_declaration asserts t.start_column == 12 and t.end_column == 21 (literals), plus targets.len() == 1, file_path, line == 0, and new_text == "home". Call convention matches the sibling collect_targets_rewrites_the_page_name_declaration.
  • AC #4 — met. CI green (LSP — test, fmt, clippy passed), and the review lenses independently ran cargo test -p laravel-lsp folio_rename — all 14 tests pass, including the two new ones.

The tests are honest regression guards: because they assert the literal 12/21 columns rather than the contact-sized constants, a span-computation bug for any other name length would fail red — exactly the gap #191 set out to close.

📋 Non-blocking follow-ups

  • None.

Ready for @mikebronner to merge.

@mikebronner
mikebronner merged commit dba935c into main Jun 16, 2026
5 checks passed
@mikebronner
mikebronner deleted the chore/191-folio-rename-decl-tests-non-contact-leaf branch June 16, 2026 18:53
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.

Folio rename decl/rename tests never exercise a non-contact-length leaf — span constants untested against other name lengths

1 participant