I think the first part of this question may be answered by the second part, but I'm asking each in case I don't fully understand all this. This is for a bUnit test.
- How do I await until OnInitAsync() has completed for my page, including for every child component in it? In my particular use case I have pages where the page itself has no
OnInitializedAsync()
call but has several components that each have aOnInitializedAsync()
that is hitting the database. If I go to test immediately, I get the "Is Loading" text on the page. I want to assert the page after it is fully populated. The solutions I see are:- Have a MyPage.IsLoaded property and then call
rc.WaitForState(() => rC.Instance.IsLoaded)
- Have the call
rc.WaitForState(() => rc.FindAll(" ... ").Count > 0)
where it is finding the html node at the end of the rendering in the last inner component.
- Have a MyPage.IsLoaded property and then call
I'm not wild on solution 1.2 as that assumes I know which inner component will render last. Solution 1.a works because IsLoaded is set to true in OnAfterRender()
and therefore I know everything is good.
- Why would I call
IRenderedComponent.Render()
to re-render the page? Is it:- To solve the above problem #1? So it then renders the page twice, but I now know it is fully rendered?
- Is it to be the equivalent of calling
StateHasChanged()
in the page code? So I can set some parameters and then I need it to re-render for those new values?