fix: livewire finder resolution for contained component assertions#47
Merged
christophrumpel merged 2 commits intoMar 29, 2026
Conversation
328dada
into
christophrumpel:production
0 of 30 checks passed
Owner
|
thanks 🙏 |
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
This PR fixes namespaced component resolution in both
assertContainsLivewireComponent()andassertDoesNotContainLivewireComponent()when Livewire components are resolved through a configured class namespace such asApp\Livewire.In Livewire 4, the finder is not just a plain helper class. Livewire registers a configured finder singleton in the container as
livewire.finder, and during registration it adds the component class namespace fromconfig('livewire.class_namespace')as well as any additional component namespaces. Livewire then uses that configured finder to normalize component class names into the component names used in Blade tags and directives.These assertions were resolving class-based components with a fresh
Finderinstance viaapp(Finder::class). That creates a new finder instead of reusing Livewire's configured singleton. Because that fresh instance does not know about the namespaces registered by Livewire,normalizeName()can return the wrong component name. For example, a component under the defaultApp\Livewirenamespace may be normalized asapp.livewire.component.indexinstead ofcomponent.index.Changes
app('livewire.finder')inassertContainsLivewireComponent()assertDoesNotContainLivewireComponent()livewire.class_namespaceset to a configured namespaceWhy this matters
These assertions are expected to follow the same component resolution rules as Livewire itself. Reusing
livewire.finderis important because it carries the namespace configuration that Livewire registers at boot time. Without that, tests can fail or behave inconsistently even though the component usage is valid in a real application.This change keeps the package aligned with Livewire 3 behavior, avoids false positives and false negatives, and improves compatibility for applications using the default namespace or custom component namespaces.
Testing
Ran:
Notes
This is a focused bug fix with regression coverage and no intended public API change.
References