fix: detect visit() when wrapped in another function call - #238
Open
pINKmUNster wants to merge 1 commit into
Open
fix: detect visit() when wrapped in another function call#238pINKmUNster wants to merge 1 commit into
pINKmUNster wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
BrowserTestIdentifier::usesFunction()requires the token immediately precedingvisit((or\visit() to be whitespace to classify a test as a browser test:This misses the common pattern of wrapping
visit()in another function call, e.g.:Here the token right before
visitis(, not whitespace, soisBrowserTest()returnsfalse. The test is then never registered as a browser test, Playwright never starts, andvisit()still executes — failing instantly with a WebSocket-not-connected error instead of running as intended.We hit this in production with a project-wide helper (
acknowledgeEnvironment(visit(...))— clicks through a "testing environment" interstitial before proceeding) used across ~50 test files, all silently never running as real browser tests.Fix
Also accept
(as a valid token precedingvisit:Covers both the plain and fully-qualified (
\visit() cases, since the fully-qualified name token check already runs before this line.Test plan
tests/Unit/Support/BrowserTestIdentifierTest.php:visit()and\visit()wrapped in another function call.visit(tokens, which trips the plugin's own detector and requires a real Playwright install to execute throughpest) that all existing cases (plainvisit(),\visit(),Livewire::visit(), method-call$page->visit(), string literal, wrapped in another call) resolve correctly with this change — no regressions.