-
I am writing a test to ensure when a bound value of a component is changed, that it is rendered correctly. The component appears to be working correctly(manual testing): Pressing the toggle button changed the bound value to the component. Then, the user changes the value inside the component and it should update the bound value. Then toggling the button should switch between the values and the new value should be displayed(like above) Here is the original bug(with gifs showing the bug): Here my repo and test code: The test seems to behave like the old version, but the real UI version seems to work fine. Any help would be appreciated! |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 2 replies
-
hi @gismofx, What's the name of the branch you are working on? I would like to clone locally and try it out. |
Beta Was this translation helpful? Give feedback.
-
So I had a look, and nothing springs out at me in the test. I did change a few things, but it still has the same problem. My problem is that the components under test is too complex for me to comprehend without spending quite a while to untangle what goes on where, so I'm afraid its as far as can go with the current sample. Here is my updated test (still fails): [Test]
public async Task Autocomplete_ChangeBoundValue()
{
var comp = Context.RenderComponent<AutocompleteChangeBoundObjectTest>();
Console.WriteLine(comp.Markup);
var autocompletecomp = comp.FindComponent<MudAutocomplete<string>>();
var autocomplete = autocompletecomp.Instance;
autocompletecomp.SetParametersAndRender(parameters => parameters.Add(p => p.DebounceInterval, 0));
autocompletecomp.SetParametersAndRender(parameters => parameters.Add(p => p.CoerceText, true));
// check initial state
autocomplete.Value.Should().Be("Florida");
autocomplete.Text.Should().Be("Florida");
comp.WaitForAssertion(() => autocompletecomp.Find("input").GetAttribute("value").Should().Be("Florida"));//redundant?
//Get the button to toggle the value
comp.Find("button").Click();
autocomplete.Value.Should().Be("Georgia");
autocomplete.Text.Should().Be("Georgia");
comp.WaitForAssertion(() => autocompletecomp.Find("input").GetAttribute("value").Should().Be("Georgia"));//redundant?
//Change the value of the current bound value component
//insert "Calif"
autocompletecomp.Find("input").Input("Alabam");
await Task.Delay(100);
//press Enter key
autocompletecomp.Find("input").KeyUp(key: Key.Enter);
//The value of the input should be California
comp.WaitForAssertion(() => autocompletecomp.Find("input").GetAttribute("value").Should().Be("Alabama"));
autocomplete.Value.Should().Be("Alabama");
autocomplete.Text.Should().Be("Alabama");
//Change the bound object
comp.Find("button").Click();
autocomplete.Value.Should().Be("Florida"); //pass
autocomplete.Text.Should().Be("Florida"); //fail
comp.WaitForAssertion(() => autocompletecomp.Find("input").GetAttribute("value").Should().Be("Florida"));//breaks here:
var markup2 = autocompletecomp.Markup;
autocomplete.Value.Should().Be("Florida");
//autocomplete.Text.Should().Be("Florida");
//Change the bound object back and check again.
comp.Find("button").Click();
var t1 = autocompletecomp.Find("input").GetAttribute("value");
var t2 = autocompletecomp.Find("input").GetAttribute("text");
autocomplete.Value.Should().Be("Alabama");
autocomplete.Text.Should().Be("Alabama");
} A few things I would try next:
Hope this helps. |
Beta Was this translation helpful? Give feedback.
-
@egil Thank you for taking the time to look and providing feedback. I suppose I'm just looking for a sanity check as well; and that my approach isn't completely wrong... I appreciate it. I'm digging deeper into the base components and classes and hope to get some help from the MB devs too. I'll update this thread if I get any answers. |
Beta Was this translation helpful? Give feedback.
@egil Thank you for taking the time to look and providing feedback. I suppose I'm just looking for a sanity check as well; and that my approach isn't completely wrong...
I appreciate it. I'm digging deeper into the base components and classes and hope to get some help from the MB devs too. I'll update this thread if I get any answers.