-
-
Notifications
You must be signed in to change notification settings - Fork 341
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
[LiveComponent] Testing forms causes exeption "There is currently no session available." #2177
Comments
Forgot to add: I‘m using the latest versions of Symfony and the UX components. |
Hi @daFish ! I'd need a bit more information to help you I think, as I dont see right now what could be the problem. Could you maybe share some code from your test and/or your component? Or, even better, if you could create a minimal bug reproducer ? |
Hi @smnandre, I have created a reproducer. The commit with all relevant changes is daFish/symfony-ux-issue-2177@12cc45f The project has been created from the Symfony demo application. Running the tests with |
@daFish thank you for creating this ideal reproducer 😃 I'll look at it tonight! |
It seems to occur when the CSRF token is generated, but i'm not too sure why right now. |
No change with the latest releases of Symfony UX packages. |
Ok, after some digging and with the help of Fracsi in Slack I got to the point where the exception is no longer thrown:
Adding this boilerplate code before creating the live component in the test solved it. However, I was under the impression that something like this isn't needed at all. |
I have this issue as well. This occurs only in Components using the ComponentWithFormsTrait. In ComponentsWithFormsTrait::initializeForm (which is called PostMount), the FormView is generated, which in turn creates a CSRF-Token. When running Tests, there is no Request on the RequestStack. That's why the Session-Object cannot be fetched from the RequestStack. There is already a PR for this: #2254 |
I'm trying to test my live component which contains a form. The following code raises an exception of type
Symfony\Component\HttpFoundation\Exception\SessionNotFoundException
.My sample testcode:
The user and the field exist. What else is needed to get the test working?
The text was updated successfully, but these errors were encountered: