-
I'm running into a situation where I want to test some functionality that opens in a popup. The component that I am using (Telerik Window) renders that window as part of the Root Component. See Important Notes. My question is there any way to render and interact with root component which is added via |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 6 replies
-
Hi @groogiam, good quesiton. A few points on this:
To achieve the second point, I would probably look at mocking @EdCharbeneau might have more good ideas to share on this. |
Beta Was this translation helpful? Give feedback.
-
Below is a summary from the response from Telerik. The Window component and all popups in general are rendered not in their place of declaration but on root level. Therefore, you should look for their content inside the TelerikRootComponent. You can find some more details in this regard in the readme file of our testing sample - see the last bullet in this section covering popup components. In addition, here you can check the example of testing the content of a Window component - https://github.com/telerik/blazor-ui/blob/master/testing/bUnit-justmock/Telerik.Blazor.BUnit.JustMock/DemoSample/WindowButtonPage.cs. This approach basically extends the test context to include an instance of the TelerikRootComponent. Instead of adding it directly it is first rendered and then added to the RenderTree as cascading parameter. The render instance can then be stored as a property an used later. I am still however running into an issue where the event handlers do not seem to function on the root context. E.g. clicking buttons is not triggering any blazor code to execute. I have a question out to Telerik and will update this answer when I get that resolved. @egil This solution requires you set all this up by extending the TestContext. I was trying to just get an instance of the TelerikRoot component using the out of box TestContext via Renderer.FindComponent? This requires passing in a parent and I couldn't figure out what that would be for the root level components. Is that possible? |
Beta Was this translation helpful? Give feedback.
Below is a summary from the response from Telerik.
The Window component and all popups in general are rendered not in their place of declaration but on root level. Therefore, you should look for their content inside the TelerikRootComponent. You can find some more details in this regard in the readme file of our testing sample - see the last bullet in this section covering popup components. In addition, here you can check the example of testing the content of a Window component - https://github.com/telerik/blazor-ui/blob/master/testing/bUnit-justmock/Telerik.Blazor.BUnit.JustMock/DemoSample/WindowButtonPage.cs.
This approach basically extends the test context to include an instance of the…