Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • May 08 17:08
    egil synchronize #391
  • May 08 17:08
    egil edited #391
  • May 08 17:08
    egil edited #391
  • May 08 17:08
    egil edited #391
  • May 08 17:08
    egil edited #391
  • May 08 17:08
    egil edited #391
  • May 08 17:08
    egil edited #391
  • May 08 17:07
    egil edited #391
  • May 08 17:07
    egil edited #391
  • May 08 17:07
    egil edited #391
  • May 08 17:07
    egil opened #391
  • May 08 17:02
    egil edited #388
  • May 08 17:01
    egil edited #388
  • May 07 11:33
    egil commented #388
  • May 07 08:29
    mrpmorris commented #388
  • May 06 19:34
    egil commented #388
  • May 06 18:48
    mrpmorris commented #388
  • May 06 12:19
    egil edited #388
  • May 05 20:15
    KristofferStrube commented #388
  • May 05 20:07
    egil commented #388
George Fabish
@thepigeonfighter
Sorry my fault I just saw an example of this is the workshop link you shared. Thanks.
Egil Hansen
@egil
No need to be sorry. It can be hard to discover things like this.
Glad you figured it out.
Brett McDonald
@bfmsoft
I am developing an Blazor HTML5 canvas application. I am getting a lot working so that isn't the issue. What I am trying to figure out is how to test the Canvas code. I was thinking to capture a bitmap then test comparing the output of the canvas to check for regression. Using like Selenium in xUnit or bUnit? I am looking for ideas...
Egil Hansen
@egilhansen:matrix.org
[m]
@bfmsoft isn't the problem that bUnit doesn't run JavaScript, and canvas is entirely driven by JavaScript?
With bUnit, the only thing you can do is have it record the JavaScript invocations and assert against those. Not sure the value of that kinda test though.
George Fabish
@thepigeonfighter
So I've ran into an issue trying to follow the new razor testing patterns put forth in https://github.com/egil/blazor-workshop. the following code results in some unexpected results. When I inspect the values after these "change" calls the first "change" call appears to not be setting the value in the component's markup. I suspect it has something to do with the component not being completely rendered?
 var cut = Render(@<ManageUser ConfirmPasswordChange="DummyActions.AlwaysTrueFunc"
                                      OnPasswordUpdate="DummyActions.OnEvent"></ManageUser>);


        cut.Find("#new-password").Change("Test123!");
        cut.Find("#new-password-confirm").Change("Test123!");
        cut.Find("#old-password").Change("Admin123!");
For context the ManageUser component uses OnInitializeAsync. I have switched the order of these find statements and whatever the order the first of the three calls is null in the rendered markup while the other have expected values.
Egil Hansen
@egil
hi @thepigeonfighter, that has nothing todo with the new razor testing pattern. If you have some async code in a component life cycle method, is is like, as you say, that it is because the component has not finished rendering when you start issuing your Find and Change calls. You likely need https://bunit.egilhansen.com/docs/interaction/awaiting-async-state.html or https://bunit.egilhansen.com/docs/verification/async-assertion.html to help you.
George Fabish
@thepigeonfighter
Ok interesting, is there any other way to figure out when a component has finished rendering other than checking for markup existing?
Egil Hansen
@egil
@thepigeonfighter hmm, no that is really the thing you are looking, the output from the component. however, if your component has a property that is set when it is done rendering, e.g. MyCompoent.ImDoneNow, then you can also inspect that. E.g. cut.WaitForState(() => cut.Instance.ImDoneNow);
George Fabish
@thepigeonfighter
Ok I was wondering about that. It's a shame Blazor doesn't offer something like that by default on components. An IsInitialized boolean would be perfect.
Egil Hansen
@egil
well, in Blazor, we never watch the components from the outside, so it being initialized is implicit in that its life cycle methods has been called.
I would also recommend that you assert on expected output, since that will make your tests more stable. I am planning to add a WaitForElement/WaitForElements that will make it a little less verbose.
For now, I would do cut.WaitForState(() => cut.FindAll("elementSelector").Count == 1)
George Fabish
@thepigeonfighter
Ok good to know, thanks! It working now.
Egil Hansen
@egil
When WaitForElement is there, then you can do a var elm = cut.WaitForElement(cssSelector). So it works like Find, just that it waits.
George Fabish
@thepigeonfighter
Actually in my use case it was finding the input element. It just wasn't setting the value of the input. If that makes sense. Looking at how the page loads naively I'd guess that the input tag gets rendered and then the value set by blazor's javascript? Not sure how long the delay between those two events are. So in my particular case I'm not sure waiting until i could find the element would do the trick?
Egil Hansen
@egil
Ahh, yeah, that might be it.
I have one "bug" that might be related to what you are seeing: egil/bUnit#46
Egil Hansen
@egilhansen:matrix.org
[m]
Hey folks, it's here. V1. Release notes here: https://github.com/egil/bUnit/releases/tag/v1.0.16
Christian Oleson
@Christian-Oleson
Awesome, thanks for all the hard work!
Gary Chan
@c0g1t8
🙏🙏🙏🎉🎉🎉
Peter Morris
@mrpmorris
Congratulations!!
Egil Hansen
@egil
Thanks folks, and for all the help getting here.
Martin Muller
@mmuller88
Thank you :)
Diako
@dkezri
Hi! is there a way to test input (type file) events like change() or input() events ?
Egil Hansen
@egilhansen:matrix.org
[m]
hi @dkezri
I have actually not tried that myself. Can you provide a minimal example of the component you want to test, and what you want to test?
Egil Hansen
@egilhansen:matrix.org
[m]
hey folks, im live on https://www.twitch.tv/egilhansen. ill be talking about github workflows, strong name signing of bUnit, and any questions you might have.
Egil Hansen
@egilhansen:matrix.org
[m]
Hey folks, wanna help me design the API for mocking of components in bUnit tests? Im going live now on twitch.tv/egilhansen to work on just that.
Brett McDonald
@bfmsoft
I am converting to the new version (BTW great job). I used a Setup method that was called from the Fixture component? Do you just inline that code in the Fact test?
Egil Hansen
@egilhansen:matrix.org
[m]
Uhm no, there are no changes to the fixture and SnapshotTest test component's.
Have you added the bunit.web.testcomponents package and removed the bunit.xunit package?
Ohh and thanks btw. @bfmsoft
Egil Hansen
@egilhansen:matrix.org
[m]
Hey folks I'm live on Twitch with more design/implementation work on the component double feature in #bUnit. Learn more about this here bUnit-dev/bUnit#388 and join the discussion live at https://www.twitch.tv/egilhansen
Egil Hansen
@egilhansen:matrix.org
[m]
Hey all, would love some feedback on the design of the component double/replacement feature in working on in bUnit: bUnit-dev/bUnit#388
Brandon James
@brandon-james105
Hi. I am having an issue with bUnit and a component using the Authorize attribute in regards to user roles. The component should not be rendered for a user without a role. I am using Telerik controls. Is there anything else I should be doing for the component to behave properly? My guess is perhaps I should wrap the component with another one but I'm not sure exactly which. I have already done test setup and applied the TestAuthorization for the user I am checking.
Egil Hansen
@egilhansen:matrix.org
[m]
Hi @brandon-james105
Brandon James
@brandon-james105
Hi @egilhansen:matrix.org , Thanks for the quick reply. Yes I have checked this article out. I can confirm in debugging the page that the user has been attributed the claims from the code I put in on that page (authContext.SetAuthorized, authContext.SetRoles).
Egil Hansen
@egil
Hmm if it doesnt work as you expect when you have the auth configured as it should for your scenario, I would try to create the most basic example, e.g. with a very simple component without any sub components, and see if the problem persists. @marin-bratanov from or @EdCharbeneau from Progress might know if there are anything in particular you need to be aware of wrt. the Telerik components.
But either way, you would need to share a minimal example of the problem you have, otherwise it is hard to provide additional help
Brandon James
@brandon-james105
@egilhansen:matrix.org, My suspicion is that it has something to do with the root component. I have set my root component to the TelerikRootComponent as suggested in another article I found. My guess is that the Authorize attribute does not hide the component because the parent component of the one I'm testing isn't related to routing. If not that, then something related to a service I'm missing, or both. My test case is just to confirm that certain components are not rendered when a user lacks roles. I can get an AuthorizeView to work, but not the entire component with the Authorize attribute.
Egil Hansen
@egil
ok. if you can, please share a minimal reproduction of the thing you are trying to do in the QA forum (https://github.com/bUnit-dev/bUnit/discussions/categories/q-a) and tag @marin-bratanov, he can help with the Telerik part of the challenge here, and ill help with the bUnit bits. Ideally, if you can upload a minimal runnable test project which shows the problem, then it will be much easier for us to help.
Brandon James
@brandon-james105
@egil Ok I will take some time because I have to create a new project on another machine. I am unable to copy the code over to the forum because I am unable to log in to GitHub on the computer the project is. I think I can reproduce this without including the Telerik controls.
Egil Hansen
@egilhansen:matrix.org
[m]
Cool. I'll take a look as soon as it's there.
Off to bed now though :-)