Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot test for magic actions #26

Closed
jonjakoblich opened this issue Dec 8, 2023 · 3 comments · Fixed by #27
Closed

Cannot test for magic actions #26

jonjakoblich opened this issue Dec 8, 2023 · 3 comments · Fixed by #27

Comments

@jonjakoblich
Copy link
Contributor

I ran into an issue trying to assert that a property was wired in my component, but via a magic action.

<a href="#" wire:click.prevent="$toggle('changeUser')">Change assigned user</a>

In my Livewire component changeUser is a property with a boolean value. I tried the following tests and both failed to match for a PCRE pattern.

Livewire::test(AssignUser::class,[
        'maintenanceRequest' => $maintenanceRequest,
    ])
        ->assertOk()
        ->assertMethodWired('$toggle(\'changeUser\')');
Livewire::test(AssignUser::class,[
        'maintenanceRequest' => $maintenanceRequest,
    ])
        ->assertOk()
        ->assertMethodWired(changeUser');

I think this could be accomplished by modifying the regular expression in the methods assertMethodWired and assertMethodNotWired to allow for magic actions.

@christophrumpel
Copy link
Owner

Hey, did not know about the magic methods. Good point. Would you be willing to creat a PR for that?

@jonjakoblich
Copy link
Contributor Author

Yes, definitely willing! Before I work on that, what tool are you using to test/build your regular expressions? I kept getting an error with the tester I was using with your existing regex so just looking to be consistent with existing code.

@christophrumpel
Copy link
Owner

Hey, from what I remember, I did not write that regex 😅 The last few times I used AI to write it for me hehe. So if it can be improved, I'm open to that 👍

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 a pull request may close this issue.

2 participants