XRM-OSS/D365-UI-Test

Quick create promise does not resolve

Opened this issue · 6 comments

Hi!

Great framework! Thanks much for open sourcing!

I am trying to use the quick create form and the form opens successfully, however the promise never resolves. I.e.
test("Create insurance and calculate price", async () => {
await xrmTest.Navigation.openQuickCreate("account");
const id = await xrmTest.Entity.save();
});

The save never happens and Jest times out. Any help would be greatly appreciated!.

I am testing this on an instance that has Swedish as base language (and only language installed).

Did some further debugging. Removing my comment above, it is not relevant.

It seems that the promise does not resolve until after you click save and close or cancel on the quick create form. So one would need to adjust the behavior of the code to take that into account.

Hi @peterbjorkmarker,

Yes, that is correct.

We call a Dynamics Utility function for opening quick create, which will also just resolve once you save or dismiss the dialog.
Are you fine with adjusting your code's behavior?

Kind regards,
Florian

I ended up forking the code. Here is my version:
`
openQuickCreate = async (options: QuickCreateOptions) => {
await EnsureXrmGetter(this._page);
// Cant be awaited here as the promise is not resolved until the page closes
options.openFormResult = this._page.evaluate(async (entityName: string) => {
const xrm = window.oss_FindXrm();
return xrm.Navigation.openForm({ entityName: entityName, useQuickCreateForm: true });
}, options.entityName);
await this.page.waitForSelector("button[id^=quickCreateSaveAndCloseBtn]", { timeout: this.xrmUiTest.settings.timeout });
await this.xrmUiTest.waitForIdleness();
}

export interface QuickCreateOptions extends NavigationSettings {
entityName?: string;
openFormResult: Promise<Xrm.Navigation.OpenFormResult>;
}

`

I await the options.openFormResult after the quick create form has been closed. As an upside I get the id back of the record I just created.

Not super clean, but works for me.

I am encountering an issue with the openQuickCreate method. While it successfully opens the quick forms, the subsequent action of entering values into the form is not functioning as expected.
Can anyone help me here?

See above, you need to modify the library code in question.

I'll publish the fix mentioned by @peterbjorkmarker as a library functions, seems to be commonly used :)

Thanks for the discussion, I'll take care to let the release follow as soon as possible.