Coder Social home page Coder Social logo

IMatDialogService + BUnit about matblazor HOT 14 CLOSED

drma-dev avatar drma-dev commented on August 26, 2024
IMatDialogService + BUnit

from matblazor.

Comments (14)

drma-dev avatar drma-dev commented on August 26, 2024

<MatPortalHost></MatPortalHost>

maybe it has something to do with it, but I'm not sure how to enable it in BUnit.

from matblazor.

egil avatar egil commented on August 26, 2024

If MatBlazor needs a root component to be added in App.razor, then this might be what you need: https://bunit.dev/docs/providing-input/root-render-tree.html

from matblazor.

drma-dev avatar drma-dev commented on August 26, 2024

I think so, but I still can't make it work.

ctx.RenderTree.TryAdd<CascadingValue<MatPortalHost>>(parameters => parameters
    .Add(p => p.Value, new MatPortalHost())
);

ctx.RenderTree.TryAdd<CascadingValue<MatDialogReference>>(parameters => parameters
    .Add(p => p.Value, new MatDialogReference() { Service = new MatDialogService(new MatPortalService()) })
);

I tried these two together, alone, but it seems to have no effect.

from matblazor.

drma-dev avatar drma-dev commented on August 26, 2024

https://www.matblazor.com/DialogService

from matblazor.

egil avatar egil commented on August 26, 2024

Did you try:

ctx.RenderTree.TryAdd<MatPortalHost>();

from matblazor.

drma-dev avatar drma-dev commented on August 26, 2024

System.ArgumentException : The MatBlazor.MatPortalHost does not have a ChildContent or Body parameter. Only components with one of these parameters can be added to the root render tree.

from matblazor.

egil avatar egil commented on August 26, 2024

Then MatPortalHost doesn't provide a cascading value. So are you sure you need it?

You may need to add a service to Services though. Take a look at the docs for the component to figure out it's dependencies.

from matblazor.

drma-dev avatar drma-dev commented on August 26, 2024
    [CascadingParameter]
    public MatDialogReference DialogReference { get; set; }

is this necessary. Furthermore:

// in root Blazor app component - App.razor
<MatPortalHost></MatPortalHost>

from matblazor.

drma-dev avatar drma-dev commented on August 26, 2024

this is not necessarily a cascading father (because you have to put it in app.razor).
I don't even know if that's the problem, it was just a possibility.

await cut.Instance.DialogReference.Service.OpenAsync(typeof(ChangeDialog), new MatDialogOptions() { Attributes = att });

I know it stops on that line. does not give error or anything.

from matblazor.

drma-dev avatar drma-dev commented on August 26, 2024

@egil

<MatPortalHost></MatPortalHost>

how can i declare this like it was in app.razor?
because this RenderTree you mentioned as far as I understand only registers parent components, not necessarily something that is in the app.

I think that's what's missing for me to be able to correctly register the services.

from matblazor.

egil avatar egil commented on August 26, 2024

when I run that last line of code, the system crashes.

To get more help, you might want to share what the exception message is.

from matblazor.

drma-dev avatar drma-dev commented on August 26, 2024

there is no error message. the execution just stops.

from matblazor.

egil avatar egil commented on August 26, 2024

there is no error message. the execution just stops.

So the system doesn't crash as you wrote before, the test completes without an error?

I don't know how the MadDialog works, but my guess is that it calls triggers something in a other component, perhaps in MatPortalHost, and that shows the dialog.

So the question is. Why would you want to test the internal dialog feature of MadBlazor?

Why not just render the content you want to show in the dialog and trust that the dialog itself works correctly.

Sorry, it's super hard to help any more. I'm not a MadBlazor dev, so don't know how it works.

from matblazor.

drma-dev avatar drma-dev commented on August 26, 2024

I don't know what the word crash means exactly.

but the execution stops, doesn't finish. if you debug the method, debugging will stop at that line, and not continue. as if there was an internal error, but this exception doesn't come back to you, so you don't know what's going on.

I use this functionality to open a popup a lot, so my test has to respect that, to be as close as possible to an interacting user.

from matblazor.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.