Skip to content

test: handler-level goto-def coverage for the alternate Flux registration forms - #189

Merged
mikebronner merged 2 commits into
mainfrom
chore/183-test-handler-level-goto-def-coverage-for-the-alter
Jun 16, 2026
Merged

mikebronner merged 2 commits into
mainfrom
chore/183-test-handler-level-goto-def-coverage-for-the-alter

Conversation

@mikebronner

@mikebronner mikebronner commented Jun 16, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Implements #183 — extends the handler-level goto-def coverage #108 established to the two other Flux resolution paths the same handler walks but no handler-level test exercised.

Changes

  • Add flux_tag_resolves_via_anonymous_component_path — drives the anonymous_component_paths registration form (Blade::anonymousComponentPath), where the registered directory IS the components dir, so <flux:button> resolves to {flux_dir}/button.blade.php with no components/ segment. The registered dir sits outside Flux's conventional fallback locations, so only the anonymous-component-path branch can produce the candidate.
  • Add flux_tag_resolves_via_self_named_candidate — drives the directory-self {base}/{last}.blade.php candidate (the third file shape push_component_file_candidates emits, salsa_impl.rs), with neither the direct file nor the index.blade.php present.
  • Add a flux_paths_config helper mirroring the anonymous_component_paths arm of the flux_config helper in flux_component_hover.rs.
  • Extract backend_with_config so the path-form test can prime a distinct config without duplicating the LspService harness; flux_backend now delegates to it (existing call sites unchanged).
  • Note the new coverage in the module doc.

Acceptance Criteria

  • A new #[tokio::test] primes LaravelConfigData with anonymous_component_paths: {"flux" → abs_dir} (mirroring the flux_config pattern in flux_component_hover.rs), writes {abs_dir}/button.blade.php, calls create_component_location_from_salsa with flux:button, and asserts the GotoDefinitionResponse::Link target URI points to that file
  • A new #[tokio::test] primes config with anonymous_component_namespaces: {"flux" → "components/flux"}, writes only resources/views/components/flux/button/button.blade.php (no direct button.blade.php or index.blade.php), calls the handler with flux:button, and asserts the LocationLink target is the self-named file — the third candidate ({base}/{last}.blade.php, salsa_impl.rs)
  • Both new tests drive the real async handler chain create_component_location_from_salsa → resolve_component_existing_file → LocationLink through the tower_lsp::LspService harness (same approach as the four existing tests)
  • cargo test --all-features passes with both new tests included; no existing tests regress

Test Plan

  • cargo test --all-features flux_goto_def_handler — all 6 tests pass (4 existing + 2 new)
  • cargo fmt --check clean; cargo clippy --all-features --tests no new warnings
  • Full cargo test --all-features suite: all lib/main unit tests pass. The only failing integration tests locally are fixture/environment-dependent (gitignored test-project/.env + composer update-installed Fortify package) — CI bootstraps both (ci.yml), so they pass on CI. No regression from this change (diff is one test file).

Fixes #183

…andler level

Add two `#[tokio::test]`s to `flux_goto_def_handler.rs` covering the
resolution paths #108's tests left untested at the handler level:

- the `anonymous_component_paths` registration form
  (`Blade::anonymousComponentPath`), where the registered directory IS
  the components dir — distinct from the `anonymous_component_namespaces`
  form the existing tests drive; and
- the directory-self `{base}/{last}.blade.php` candidate, the third file
  shape `push_component_file_candidates` emits.

Extract `backend_with_config` so the path-form test can prime a distinct
config without duplicating the `LspService` harness; `flux_backend` now
delegates to it (existing call sites unchanged). Add a `flux_paths_config`
helper mirroring the `anonymous_component_paths` arm in
`flux_component_hover.rs`.

Both drive the real `create_component_location_from_salsa` →
`resolve_component_existing_file` → `LocationLink` chain.

Fixes #183
@mikebronner
mikebronner marked this pull request as ready for review June 16, 2026 13:14

@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: two new #[tokio::test]s in flux_goto_def_handler.rs extending handler-level goto-def coverage to the two resolution paths #183 called out, plus a clean flux_backend → backend_with_config extraction and a new flux_paths_config helper.
  • AC #1 (anonymous-component-path form) — met. flux_tag_resolves_via_anonymous_component_path primes anonymous_component_paths: {"flux" → abs_dir}, writes {flux_dir}/button.blade.php, calls create_component_location_from_salsa("flux:button"), and pins the exact target. The registered dir (packages/flux/resources/views) sits outside every Flux hardcoded fallback (resources/views/flux, vendor/livewire/flux…), so only the anonymous-component-path branch can produce the candidate — it can't pass by coincidence.
  • AC #2 (self-named candidate) — met. flux_tag_resolves_via_self_named_candidate writes only resources/views/components/flux/button/button.blade.php — no direct file, no index.blade.php — so a pass proves the third candidate ({base}/{last}.blade.php, salsa_impl.rs:3185) resolved, not candidate 1 or 2.
  • AC #3 (real handler chain) — met. Both tests drive create_component_location_from_salsa → resolve_component_existing_file → LocationLink through the same LspService::new harness as the four existing tests; no handler is bypassed.
  • AC #4 (CI green, no regression) — met. All five checks pass (LSP test/fmt/clippy, wasm check, CodeQL ×2). Tests use disjoint TempDirs with no shared state.
  • Verified independently: the refactor preserves the existing four tests' behaviour exactly; assertions pin the full absolute path; deleting either targeted production branch would fail the corresponding test. Honest coverage, not trivia.

📋 Non-blocking follow-ups

  • None.

Ready for @mikebronner to merge.

@mikebronner
mikebronner merged commit a4ed5a5 into main Jun 16, 2026
5 checks passed
@mikebronner
mikebronner deleted the chore/183-test-handler-level-goto-def-coverage-for-the-alter branch June 16, 2026 13:49
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.

test: handler-level goto-def coverage for the alternate Flux registration forms

1 participant