DevExpress / testcafe-browser-provider-electron

This is the Electron browser provider plugin for TestCafe.
https://testcafe.io
MIT License
49 stars 30 forks source link

setElectronDialogHandler not responding to clicks in app #79

Closed ashmortar closed 3 years ago

ashmortar commented 3 years ago

I'm using electron 10.1.6 and testcafe-browser-provider-electron i've tried both 0.0.16 and 0.0.15 with the same result. Here is my test:

test('create a new experiment', async (t) => {
  await t.expect(newExpSelector().innerText).eql('Start New Experiment');
  await setElectronDialogHandler((type, browserWindow, options) => {
    // browserWindow, options are standard arguments of the opening dialog, you can use it for your purposes
    if (type !== 'save-dialog') {
      return;
    }
    // it returns the file path from the open dialog
    return ['filepath'];
  }, {});
  await t.click(newExpSelector);
  await t.expect(getPageUrl()).contains('/files');
});

but when I click on the selector opens the save-dialog the app just hangs. It doesn't actually matter if call the setElectronDialogHandleror not, when I click the ui element that opens a dialog the app hangs.

ashmortar commented 3 years ago

This actually was due to me requesting the dialog from the main thread via the renderer with ipc.sendSync which worked fine in app with user interactions, but because it is synchronous I believe it blocks execution of the mock handler. Changing to ipc.invoke / ipc.handle resolved the issue.