Skip to content
This repository has been archived by the owner on Jan 30, 2025. It is now read-only.

Async waitForNavigation #467

Merged
merged 20 commits into from
Aug 12, 2022
Merged

Async waitForNavigation #467

merged 20 commits into from
Aug 12, 2022

Conversation

inancgumus
Copy link
Member

@inancgumus inancgumus commented Jul 21, 2022

Please feel free to add additional commits to the PR if you need to and merge it without me.

Note: I would create another PR to fix the problem in k6ext.promise, but since I'll be leaving soon, I wanted to pack it in the same PR.

Closes #440.

@inancgumus inancgumus requested review from imiric and ankur22 July 21, 2022 14:25
@inancgumus inancgumus self-assigned this Jul 21, 2022
@inancgumus inancgumus force-pushed the feat/440-async-waitfornavigation branch 4 times, most recently from 61d50a4 to 39fbbf0 Compare July 22, 2022 14:24
examples/fillform.js Outdated Show resolved Hide resolved
@imiric imiric added the breaking PRs that need to be mentioned in the breaking changes section of the release notes label Jul 27, 2022
Copy link
Contributor

@imiric imiric left a comment

Choose a reason for hiding this comment

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

LGTM, besides the test and examples issues. The async helpers are a nice touch 👍

And a meta comment: some of the commits here could be squashed.

examples/locator_pom.js Outdated Show resolved Hide resolved
tests/frame_manager_test.go Show resolved Hide resolved
tests/frame_manager_test.go Outdated Show resolved Hide resolved
tests/frame_manager_test.go Outdated Show resolved Hide resolved
@ankur22
Copy link
Collaborator

ankur22 commented Jul 28, 2022

LGTM.

@imiric you raise good points on the tests. I also think we should be checking that reject is called when the javascript test fails.

The callback returned from RegisterCallback should not be run as a
goroutine. Since its job is to carry a task to the event loop, the task
should be done in a goroutine first, and then let the task call the
callback within the goroutine.
Since waitForNavigation is async now.
Since the Click and WaitForNavigation are now async, we don't need to
call each in separate goroutines. Instead, we call them in the event
loop, and the event loop will take care of async stuff for us.
@ankur22 ankur22 force-pushed the feat/440-async-waitfornavigation branch from 39fbbf0 to 41ae327 Compare August 8, 2022 09:36
ankur22 added a commit that referenced this pull request Aug 8, 2022
We can now use Promise.all when we interact with an element that causes
a navigation to occur, and so we need to also use waitForNavigation
before carrying on to the next steps in the tests. This helps prevent
race conditions between clicking and waiting.

Resolves: #467 (comment)
We can now use Promise.all when we interact with an element that causes
a navigation to occur, and so we need to also use waitForNavigation
before carrying on to the next steps in the tests. This helps prevent
race conditions between clicking and waiting.

Resolves: #467 (comment)
@ankur22 ankur22 force-pushed the feat/440-async-waitfornavigation branch from 8a9f052 to 886eda5 Compare August 8, 2022 11:55
ankur22 added a commit that referenced this pull request Aug 8, 2022
The test now checks the state of the promise before passing the test.

Resolves: #467 (comment)
ankur22 added a commit that referenced this pull request Aug 8, 2022
The test now checks the state of the promise before passing the test.

Resolves: #467 (comment)
@ankur22 ankur22 force-pushed the feat/440-async-waitfornavigation branch from d37be91 to a68a949 Compare August 8, 2022 16:40
The test now checks the state of the promise before passing the test.

Resolves: #467 (comment)
@ankur22 ankur22 force-pushed the feat/440-async-waitfornavigation branch from a68a949 to 331465f Compare August 8, 2022 16:58
ankur22 added a commit that referenced this pull request Aug 9, 2022
We just want to make sure that the promises actually complete and are
fulfilled before we end the test, so we're checking the state of the
promise in `tb.await` as well as after `tb.await`. There's a chance
that the action has already completed before the first state check, but
the resolve/rejection only occurs `tb.await` returns.

Resolves: #467 (comment)
ankur22 added a commit that referenced this pull request Aug 9, 2022
We just want to make sure that the promises actually complete and are
fulfilled before we end the test, so we're checking the state of the
promise in `tb.await` as well as after `tb.await`. There's a chance
that the action has already completed before the first state check, but
the resolve/rejection only occurs `tb.await` returns.

Resolves: #467 (comment)
@ankur22 ankur22 force-pushed the feat/440-async-waitfornavigation branch from 17f107f to 262eaee Compare August 9, 2022 10:32
@ankur22 ankur22 requested a review from imiric August 9, 2022 10:33
Copy link
Contributor

@imiric imiric left a comment

Choose a reason for hiding this comment

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

Looks good, thanks for the changes @ankur22. I left just a few more minor suggestions.

tests/frame_manager_test.go Outdated Show resolved Hide resolved
tests/frame_manager_test.go Outdated Show resolved Hide resolved
tests/frame_manager_test.go Show resolved Hide resolved
tests/frame_manager_test.go Outdated Show resolved Hide resolved
k6ext/k6test/vu.go Show resolved Hide resolved
ankur22 added a commit that referenced this pull request Aug 11, 2022
We just want to make sure that the promises actually complete and are
fulfilled before we end the test, so we're checking the state of the
promise in `tb.await` as well as after `tb.await`. There's a chance
that the action has already completed before the first state check, but
the resolve/rejection only occurs `tb.await` returns.

Resolves: #467 (comment)
@ankur22 ankur22 force-pushed the feat/440-async-waitfornavigation branch from e63220b to 8b23121 Compare August 11, 2022 15:17
We just want to make sure that the promises actually complete and are
fulfilled before we end the test, so we're checking the state of the
promise in `tb.await` as well as after `tb.await`. There's a chance
that the action has already completed before the first state check, but
the resolve/rejection only occurs `tb.await` returns.

Resolves: #467 (comment)
This will ensure that the envetloop has complete before starting it up
again. We're going to avoid placing lock here, since we want to follow
the eventloop API and not allow multiple threads accessing the one
eventloop.
@ankur22 ankur22 force-pushed the feat/440-async-waitfornavigation branch from 8b23121 to 61b84ee Compare August 11, 2022 15:23
ankur22 added a commit that referenced this pull request Aug 11, 2022
We shouldn't need the CI specific timeout since the test should now
be less flaky and is asynchronous.

Resolves: #467 (comment)
We shouldn't need the CI specific timeout since the test should now
be less flaky and is asynchronous.

Resolves: #467 (comment)
@ankur22 ankur22 force-pushed the feat/440-async-waitfornavigation branch from 1e9fda0 to fac54bd Compare August 11, 2022 15:46
@ankur22 ankur22 requested a review from imiric August 11, 2022 16:12
tests/frame_manager_test.go Outdated Show resolved Hide resolved
@ankur22 ankur22 force-pushed the feat/440-async-waitfornavigation branch from f510cff to 3ea0c25 Compare August 12, 2022 08:41
@ankur22 ankur22 requested a review from imiric August 12, 2022 08:46
Copy link
Contributor

@imiric imiric left a comment

Choose a reason for hiding this comment

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

Great work @inancgumus and @ankur22! 👏

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
breaking PRs that need to be mentioned in the breaking changes section of the release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Async WaitForNavigation
3 participants