-
-
Notifications
You must be signed in to change notification settings - Fork 293
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
fix: use method from metadata for live component test helper #1434
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The change looks good, but I see that there are now failures inside the LiveComponent package itself.
If you set "method: 'get'" on some of the tests that now fail, does it fix the problem or not ? (without the changes from this PR) (just want to know if everything works in that case) |
@smnandre Setting |
From your PR, could you try to, when in POST, send "props" in JSON and not in the query string ? Someything "like that" (did not test at all) $this->client->request('POST', $this->router->generate(
$this->metadata->get('route'),
[
'_live_component' => $this->metadata->getName(),
]
), [
'json' => ['props' => $props->getProps()]
]); |
This did the trick:
|
@daFish good news! Could you update your PR to include this change, and we'll see then if tests are OK or if there is something else to fix :) |
e3b4bf0
to
1d01162
Compare
Looks like there is more work todo. I'll see if I can do something about it. Any hints are appreciated. |
'props' => json_encode($props->getProps(), flags: \JSON_THROW_ON_ERROR), | ||
] | ||
)); | ||
$this->client->request($this->metadata->get('method'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if ('POST' === $method = strtoupper($this->metadata->get('method'))) {
$this->client->request(
$method,
$this->router->generate($this->metadata->get('route'), [
'_live_component' => $this->metadata->getName(),
]),
[
'json' => ['props' => $props->getProps()],
],
);
} else {
$this->client->request($method, $this->router->generate(
$this->metadata->get('route'),
[
'_live_component' => $this->metadata->getName(),
'props' => json_encode($props->getProps(), flags: \JSON_THROW_ON_ERROR),
]
));
}
We need to handle both situations there
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Of course - adjusted.
@@ -141,7 +144,7 @@ private function request(array $content = [], string $action = null): self | |||
$csrfToken = $this->csrfToken(); | |||
|
|||
$this->client->request( | |||
'POST', | |||
$this->metadata->get('method'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure this one need any change... do your tests fail there ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reverted.
1d01162
to
0498164
Compare
Do all your tests pass with this change? 😄 |
Yes, they do. And the checks here are also passing. But some more feedback from others would also be appreciated. |
0498164
to
f0baa2a
Compare
'_live_component' => $this->metadata->getName(), | ||
]), | ||
[ | ||
'data' => json_encode(['props' => $props->getProps()]), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops, we lost the flag :)
'data' => json_encode(['props' => $props->getProps()], flags: \JSON_THROW_ON_ERROR),
f0baa2a
to
d84f3eb
Compare
Failure unrelated. |
Thanks Marcus! |
After #1218 has been released as part of 2.14.0 my tests fail. This change passes the actual method to the requests made by the test helper.