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

Refactor lifecycle tests and add any missing tests #647

Merged
merged 16 commits into from
Nov 30, 2022

Conversation

ankur22
Copy link
Collaborator

@ankur22 ankur22 commented Nov 10, 2022

Before we attempt to cleanup the lifecycle event code (#593) we need to lock in the current behaviour so that any refactoring does not affect the behaviour.

The tests are:

  • test that waitUntil on load and DOMContentLoaded work as expected when used in goto.
  • test that waitUntil on load, DOMContentLoaded and networkidle work as expected when we navigate to a page with a main and sub frame when used in goto.
  • test that waitUntil on load, DOMContentLoaded and networkidle work as expected when used as an option on WaitForNavigation.
  • test that waitUntil on networkidle timesout if we set it too late after the navigation has completed.

Linked issue: #593

@ankur22 ankur22 force-pushed the refactor/593-lifecycle-tests-refactored branch 2 times, most recently from 75b9107 to c8b56ae Compare November 10, 2022 16:01
@ankur22 ankur22 marked this pull request as draft November 11, 2022 10:04
@ankur22 ankur22 force-pushed the refactor/593-lifecycle-tests-refactored branch 2 times, most recently from 9106a4c to 99980ef Compare November 11, 2022 10:47
@ankur22 ankur22 requested a review from inancgumus November 11, 2022 10:52
@ankur22 ankur22 marked this pull request as ready for review November 11, 2022 10:52
Copy link
Member

@inancgumus inancgumus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent work 👏 Thanks for considering my previous feedback and refactoring this 🙇

I'm approving this PR as it is, and I have some suggestions I want you to consider. All are optional. I believe there are some areas in which we can further decrease duplication and make it more straightforward and maintainable.

Commits:
IMHO, we don't need to make separate commits for minor changes, such as the following. Please consider squashing them

  • Add general lifecycle event guidelines
  • Rename the goto network lifecycle event tests
  • Move general guideline comment to top
  • Refactor ... test commits

It is now clear that the same code exercises the test cases of a table test. And each test case is small enough. A commit for each top-level test is enough. IMO, no need to make a commit for each table test. It is better to squash them into one commit.

The following static/*.html files are nearly identical.

  • prolonged_network_idle.html
  • prolonged_network_idle_10.html
  • reload_lifecycle.html
  • wait_for_nav_lifecycle.html

We can parameterize them for each test case instead of duplicating these files. You can use page.Eval to do that. I found that only the following parts change:

Changing parts:

+ <div id="pingJSText">Waiting...</div>
+ Loop count
+ <script src="/ping.js" async></script>
+ <a href="/home" id="homeLink">Home</a>

Summary :)
As the PR is big, I couldn't validate its functionality. I'll check it out once again when I'm back.

tests/lifecycle_wait_test.go Outdated Show resolved Hide resolved
tests/lifecycle_wait_test.go Outdated Show resolved Hide resolved
tests/lifecycle_wait_test.go Outdated Show resolved Hide resolved
tests/lifecycle_wait_test.go Outdated Show resolved Hide resolved
tests/lifecycle_wait_test.go Outdated Show resolved Hide resolved
tests/lifecycle_wait_test.go Outdated Show resolved Hide resolved
tests/lifecycle_wait_test.go Show resolved Hide resolved
tests/lifecycle_wait_test.go Show resolved Hide resolved
@ankur22 ankur22 force-pushed the refactor/593-lifecycle-tests-refactored branch from 99980ef to acc5906 Compare November 11, 2022 15:36
@ankur22
Copy link
Collaborator Author

ankur22 commented Nov 11, 2022

Thanks for the suggestions! I'll take a look at them 🙂

@ankur22 ankur22 force-pushed the refactor/593-lifecycle-tests-refactored branch from acc5906 to 4f88417 Compare November 11, 2022 15:38
ankur22 added a commit that referenced this pull request Nov 11, 2022
@ankur22 ankur22 force-pushed the refactor/593-lifecycle-tests-refactored branch 2 times, most recently from 840ba23 to 85bac97 Compare November 11, 2022 15:48
ankur22 added a commit that referenced this pull request Nov 11, 2022
@ankur22 ankur22 force-pushed the refactor/593-lifecycle-tests-refactored branch from 85bac97 to 74a5871 Compare November 11, 2022 16:00
We're deduplicating the ping handler to make it simpler to read the
tests.
Deduplicate the ping.js handler in the lifecycle tests.
ankur22 added a commit that referenced this pull request Nov 11, 2022
@ankur22 ankur22 force-pushed the refactor/593-lifecycle-tests-refactored branch from 74a5871 to 74d5402 Compare November 11, 2022 16:00
Deduplicate the home handler in the lifecycle tests.
Deduplicate them and convert them to a table test.
Deduplicate them and convert them to a table test.
These tests ensure that we receive the subframe events before the
lifecycle events for the main/root frame. This will ensure that the
waitUntil only unblocks once all frames are ready.
This is in preparation for the WaitForNavigation lifecycle tests.
ankur22 and others added 4 commits November 11, 2022 16:02
This test locks in the behaviour which highlights that it will timeout
if the function call is made after the navigation has ended.
Co-authored-by: İnanç Gümüş <[email protected]>
@ankur22 ankur22 force-pushed the refactor/593-lifecycle-tests-refactored branch from 74d5402 to 6791e5b Compare November 11, 2022 16:02
Consolidates as much of the test functionality into one html file.
ankur22 added a commit that referenced this pull request Nov 11, 2022
@ankur22 ankur22 force-pushed the refactor/593-lifecycle-tests-refactored branch from 0dd3708 to 215000d Compare November 11, 2022 17:18
@ankur22 ankur22 self-assigned this Nov 11, 2022
@ankur22 ankur22 added the tests label Nov 11, 2022
@ankur22 ankur22 added this to the v0.7.0 milestone Nov 11, 2022
@ankur22 ankur22 merged commit bae3e73 into main Nov 30, 2022
@ankur22 ankur22 deleted the refactor/593-lifecycle-tests-refactored branch November 30, 2022 14:54
@inancgumus inancgumus removed this from the v0.7.0 milestone Dec 5, 2022
@inancgumus inancgumus linked an issue Dec 5, 2022 that may be closed by this pull request
inancgumus added a commit that referenced this pull request Jan 13, 2023
So far, we haven't been testing the lifecycle tests. The test variables
were captured because `t.Parallel`. This fixes it.

Related: #647, #644, #643
inancgumus added a commit that referenced this pull request Jan 13, 2023
So far, we haven't been testing the lifecycle tests. The test variables
were captured because `t.Parallel`. This fixes it.

Related: #647, #644, #643
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Simplify lifecycle events for frames
2 participants