3

I have a test in which I try to delete a file. A native dialog appears, and the test asserts whether the text in the dialog contains the string that I expect. Sporadically the test fails for seemingly no reason, and I can't debug it because I can't actually see whether the dialog shows up or not since TestCafé is handling it.

test('Verify that an account owner sees a warning when deleting the winning media in a Completed A/B test', async (t) => {
   const projectTitle = "advancedaccount's First Project";
   const completedMediaName = 'Cmpltd Control'; // winning media

   await t
     .useRole(advancedAccount)
     .click(projectListPage.projectLink.withAttribute('title', projectTitle))
     .click(projectPage.mediaLink.withText(completedMediaName))
     .setNativeDialogHandler(() => false)
     .hover(mediaPage.videoActionsDropdown)
     .click(mediaPage.actions.delete)
     .expect(getLocation()).contains('medias');

  const history = await t.getNativeDialogHistory();

  await t
     .expect(history[0].text).contains('This media is also the winner of an A/B test');
});

Failure diagnostic:

1) TypeError: Cannot read property 'text' of undefined

    54 |    .expect(getLocation()).contains('medias');
    55 |
    56 |  const history = await t.getNativeDialogHistory();
    57 |
    58 |  await t
  > 59 |    .expect(history[0].text).contains('This media is also the winner of an A/B test');
    60 |});
    61 |

Any idea what could be going wrong, or how I can try to get to the bottom of it?

Alex Skorkin
  • 4,264
  • 3
  • 25
  • 47

1 Answers1

3

I see two possible causes of the fact that the history array is empty:

  1. There is a bug on the testcafe side.
  2. Native dialog does not attempt to show up because of a problem on the web application side.

To determine the real cause of the problem we need a link to your web app or a simple project on which we will be able to reproduce this behavior.

aleks-pro
  • 1,659
  • 4
  • 12
  • I'm not sure what an easy way would be to get you access to our app since it's behind user login. What I can tell you is that the native dialog is definitely showing up and is definitely being handled correctly, now that I think about it, because otherwise `.expect(getLocation()).contains('medias')` would be failing. That's my failsafe to make sure that the actions are being taken correctly. It seems that just the history is not working as expected. Is there something wrong with the way that I have ordered things in the test, perhaps? – Samantha Blasbalg Jun 03 '19 at 19:56
  • Please check if the native dialog is always shown on the testing page without TestCafe. To check if the dialog is shown during test execution, you can log or debug your native dialogs' handler in the `setNativeDialogHandler` action `.setNativeDialogHandler(() => { debug; return false; })` – Helen Dikareva Jun 04 '19 at 11:50
  • If the dialog is shown but there is no entry about it in the history, then it's a bug. Please create [a new bug](https://github.com/DevExpress/testcafe/issues/new?template=bug-report.md) in the TestCafe GitHub repo. You will have to fill in a whole template for a bug report including an example to reproduce the behavior: the whole test and the testing page URL. So it would be nice if you provide temporary test credentials to enter your page. – Helen Dikareva Jun 04 '19 at 11:52