moribvndvs / ng2-idle

Responding to idle users in Angular (not AngularJS) applications.
https://moribvndvs.github.io/ng2-idle
Apache License 2.0
315 stars 128 forks source link

Protractor E2E Tests Hang #71

Closed wesley-trantham closed 6 years ago

wesley-trantham commented 6 years ago

I'm submitting a ... (check one with "x")

[x ] bug report => search github for a similar issue or PR before submitting
[ ] feature request
[ ] support request => Please do not submit support request here, instead see https://github.com/HackedByChinese/ng2-idle/blob/master/CONTRIBUTING.md#getting-help

Current behavior

After adding idle.watch() my E2E tests in protractor hang.

Expected behavior

E2E tests should run successfully and just as fast as before introducing idle.

Minimal reproduction of the problem with instructions

https://github.com/wesley-trantham/idle-protractor-example

What is the motivation / use case for changing the behavior?

I want my E2E tests to run against the exact copy of production code. While my first thought is to turn idle off for my autoe2e* users, that defeats the purpose of testing the same code that my users will see.

Please tell us about your environment:

Windows 7, VSCode, NPM, Angular CLI, Protractor

wesley-trantham commented 6 years ago

I've written what will fix the initial issue of E2E tests not running. https://github.com/wesley-trantham/ng2-idle/tree/bug/e2e-support-protractor-waitforangular

I will admit this isn't the full expected fix. My E2E tests have doubled in run time, which is better than hanging, but still undesirable.

I've tracked that down to being caused by every interrupt restarting the watch. The fix for that, I imagine, would be to refactor the watch to run the full duration, then check to see when the last interrupt was called. If an interrupt was not called, time out, otherwise add the idle time to the last interrupt time and setInterval to fire again at that point.

I'm slowly working on attempting to make that work, but that is a larger change and I'm half afraid of the breaking changes it could introduce. I'd like some feedback to make sure I'm on the right track.

wesley-trantham commented 6 years ago

I should also admit that I'm not entirely sure how to write unit tests for this, as really the existing ones should still work. Adding an E2E suite sounds like a good idea, I'm trying to think of the best way to go about doing so.

wesley-trantham commented 6 years ago

Rework of setInterval is in this branch https://github.com/wesley-trantham/ng2-idle/tree/bug/e2e-protractor-speed. FYI - found that this did not fix my issue, but I have tracked it down to somewhere on how interrupts work.

wesley-trantham commented 6 years ago

It turns out that simply listening to keydown slows down protractor, I'm not able to figure out why, yet, at least. I will be making a PR for https://github.com/wesley-trantham/ng2-idle/tree/bug/e2e-support-protractor-waitforangular soon.

moribvndvs commented 6 years ago

Fixed by #74