[Autocomplete] Testing an autocomplete #2921
Replies: 17 comments
-
Hey, symfony/symfony#47642 should help if someone will care :D |
Beta Was this translation helpful? Give feedback.
-
With Crawler you might need to add the |
Beta Was this translation helpful? Give feedback.
-
@yceruto I've tried this but there is still a problem - it's impossible to add choice to single select element. so it's simulating a wrong behavior? |
Beta Was this translation helpful? Give feedback.
-
I've been through the same issue here and didn't find any solutions at that time... |
Beta Was this translation helpful? Give feedback.
-
I found that |
Beta Was this translation helpful? Give feedback.
-
You do want a full application test ? Or an unit -- integration ? Can you share a bit of code ? There are as many ways to use those classes than there are developers.. |
Beta Was this translation helpful? Give feedback.
-
For sure an functional test |
Beta Was this translation helpful? Give feedback.
-
It's really surprising that |
Beta Was this translation helpful? Give feedback.
-
If someone was inclined to create a mini reproducer that could help motivate people to digg into this with you |
Beta Was this translation helpful? Give feedback.
-
Hey guys! I'm facing an issue with this test where I try to create a user from a form:
And I'm getting this error: I'd like to add an option in my autocomplete field (maybe with |
Beta Was this translation helpful? Give feedback.
-
As temporal, ugly workaround, you can add the new options this way (this should be done before submitting the form): \Closure::bind(function () {
// add here the new options e.g.
$this->options[] = ['value' => '1'];
}, $field, ChoiceFormField::class)(); Being |
Beta Was this translation helpful? Give feedback.
-
I also have the same issue. As a workaround, Instead of using See https://github.com/symfony/ux/blob/2.x/src/Autocomplete/tests/Functional/AutocompleteFormRenderingTest.php for an example with |
Beta Was this translation helpful? Give feedback.
-
Thank you for this issue. |
Beta Was this translation helpful? Give feedback.
-
Not resolved |
Beta Was this translation helpful? Give feedback.
-
Thank you for this issue. |
Beta Was this translation helpful? Give feedback.
-
Is there already an update of the documentation somewhere? |
Beta Was this translation helpful? Give feedback.
-
If you're experiencing issues with submitForm in functional tests using Symfony's KernelBrowser, you can work around it by directly interacting with the form fields and submitting the form manually. Below is an example: $form = $this->client->getCrawler()->selectButton('transaction_form')->form();
// Disabling validation for the autocomplete field
$form['transaction_form[user]']->disableValidation()->setValue($user->id->toString());
$form['transaction_form[phoneNumber]']->setValue('some phone number');
$form['transaction_form[amount]']->setValue('5');
// Submit the form manually
$this->client->submit($form); The disableValidation method is marked as internal. Your editor may not detect it, and tools like PHPStan might flag it as an error. However, it works in practice and can be safely used in this context. If necessary, you can suppress the PHPStan error for this specific line or adjust your PHPStan configuration. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello !
I'm currently testing an application that uses symfony/ux-autocomplete in a form and i'm facing an issue where i can't test my form because there is no possible values.
Do you have an idea of what i can do to test this field ?
PHPUnit : 9.6
Symfony : 6.4
UX-Autocomplete : 2.13.2
Beta Was this translation helpful? Give feedback.
All reactions