Unable to Simulate User Interaction for FluentCheckbox of Blazor Fluent Component via UI in bUnit A #1740
Replies: 5 comments
-
Egil and I are currently one holiday so can only use mobile right now: My personal opinion would be not to rely on their party and instead try to mock/fake the component (3rd party) with a test double. This can be achieved via: https://bunit.dev/docs/providing-input/substituting-components.html?tabs=moq |
Beta Was this translation helpful? Give feedback.
-
Thanks @linkdotnet for reply. Also, using The only way to fix the issue is to add a delay before Assert, like
It seem that the TriggerEvent has not finished updating the UI and rededering is still in progress. |
Beta Was this translation helpful? Give feedback.
-
If that is the case and there are async updates, you should use the |
Beta Was this translation helpful? Give feedback.
-
I will convert this into a discussion as this isn't a bug per-se. |
Beta Was this translation helpful? Give feedback.
-
I Used instead of the delay:
The test pass |
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.
-
This issue is posted on stackoverflow , but no answer.
When trying to test a component that use Fluent UI Blazor library
<FluentCheckbox>
withbUnit
, test fail because user interaction is not applied.The Environment:
The component source code is:
The bunit test is:
In the above test,the test fail. I am unable to simulate user interaction that updates the bound model property using TriggerEvent in bUnit .
<FluentCheckbox>
does not support calling.Change(true)
orClick()
Attempting to use
.TriggerEvent()
has no effect.Is there a recommended bUnit approach to simulate user interaction (checking/unchecking) for FluentCheckbox that causes the model to update as it would in a browser?
Note: The component uses
@bind-Value
, and the only reliable way is to update from model to UI by setting the bound value directly and re-render. This does not simulate a real user interaction.Thanks for your help!
Beta Was this translation helpful? Give feedback.
All reactions