Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to add a default view when using addCustomView (from lookupcontrol.mock) #96

Open
boretti opened this issue Dec 5, 2024 · 0 comments

Comments

@boretti
Copy link

boretti commented Dec 5, 2024

I am trying to use the LookupControl to test a functionnality that should add a custom view.

It look like there is an inconsistency in the implementation of the Mock which prevent me to do so :

Scenario

If i create create an attribute with a component :

XrmMockGenerator.Attribute.createLookup({
  name: 'attr',
}, [{
  name: 'attr',
  views: [],
}])

And then have some implementation that add a customView (with default set to true), like :

ctrl.addCustomView(
   guid,
   config.entityName,
   viewName,
   fetchXml,
   layoutXml,
   true,
)

I end up with an error from the mock : No default view was found!. This is from the getDefaultView method from the mock (https://github.com/camelCaseDave/xrm-mock/blob/88c77c97e96a9ff2051b0ffdc2b4bed1e13262c0/src/xrm-mock/controls/lookupcontrol/lookupcontrol.mock.ts#L89). This method throw an exception when there is no default view and is used inside the addCustomView in the first if.

But if add a default view before execution of addCustomView :

XrmMockGenerator.Attribute.createLookup({
  name: 'attr',
}, [{
  name: 'attr',
  views: [{
    entityName: 'eN',
    fetchXml: '',
    isDefault: true,
    layoutXml: '',
    viewDisplayName: 'vn',
    viewId: 'id',
  }],
}])

I have the exception from the mock : Lookup Control cannot have more than one default view..

Correction proposal

If we replace the throw new Error("No default view was found!"); from getDefaultView with a return undefined when doesn't have the issue anymore and the first scenario is passing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant