Skip to content

feat(cdk/testing): support modifiers for clicking on a TestElement #20758

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

Merged
merged 7 commits into from
Dec 14, 2020

Conversation

wwjhu
Copy link
Contributor

@wwjhu wwjhu commented Oct 9, 2020

Adds the ability to provide modifier keys when clicking on a TestElement.

@google-cla google-cla bot added the cla: yes PR author has agreed to Google's Contributor License Agreement label Oct 9, 2020
@wwjhu wwjhu force-pushed the test-element-click-modifiers branch from 522382d to a410ddf Compare October 9, 2020 14:56
@wwjhu wwjhu requested a review from a team as a code owner October 9, 2020 15:07
@mmalerba
Copy link
Contributor

mmalerba commented Nov 9, 2020

@wwjhu apologies, I missed this PR while I was out on vacation. It looks good, though it does need to be rebased now.

@wwjhu wwjhu force-pushed the test-element-click-modifiers branch from 1da8510 to f15de07 Compare November 10, 2020 16:05
@wwjhu
Copy link
Contributor Author

wwjhu commented Nov 10, 2020

Rebased.

@wwjhu
Copy link
Contributor Author

wwjhu commented Nov 10, 2020

Given the rightClick that landed in #20400, do you think the modifiers should be added to rightClick as well?

@mmalerba
Copy link
Contributor

Yeah I think that would make sense, people will expect the method signatures to be the same

dispatchMouseEvent(this.element, name, clientX, clientY, button);
await this._stabilize();
dispatchMouseEvent(this.element, 'mouseup', clientX, clientY, button, modifiers);
dispatchMouseEvent(this.element, name, clientX, clientY, button, modifiers);
Copy link
Contributor

Choose a reason for hiding this comment

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

why was await this._stabilize() removed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

_stabilize is already called from the public entry points click and rightClick that use this private helper. It's not necessary to call it more often.

Copy link
Contributor

Choose a reason for hiding this comment

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

can we add a second await this._stabilize() to click to maintain the same behavior that it has currently? I tried presubmitting and it seems maybe some people were depending on that quirk. You can leave a TODO to clean it up later, just don't want it to block this

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Obviously I can, but that second await this._stabilize() was recently added in #20400 which makes that there cannot be many people, if any at all, relying on it

Copy link
Contributor

Choose a reason for hiding this comment

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

It's possible the failures I saw were not related to this line. I'll do some more digging and let you know

Copy link
Contributor

Choose a reason for hiding this comment

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

I confirmed that removing that call to this._stabilize() was indeed the culprit. It'll need to be investigated, but shouldn't block this PR. Can you add it back with a comment to investigate why removing it breaks some tests in g3?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will do

Copy link
Contributor

@mmalerba mmalerba left a comment

Choose a reason for hiding this comment

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

LGTM

@mmalerba mmalerba added action: merge The PR is ready for merge by the caretaker target: minor This PR is targeted for the next minor release labels Nov 10, 2020
@wwjhu wwjhu force-pushed the test-element-click-modifiers branch from 090bece to 190c03f Compare November 11, 2020 16:15
@wwjhu
Copy link
Contributor Author

wwjhu commented Nov 11, 2020

Rebased.

wwjhu added 6 commits December 7, 2020 13:36
Adds the ability to provide modifier keys when clicking on a TestElement
Update API golden files for cdk/testing.
Update API golden files for ProtractorElement and UnitTestElement.
Adds the ability to provide modifier keys when right clicking on a TestElement
Indentation and space changes based on review.
@wwjhu wwjhu force-pushed the test-element-click-modifiers branch from 190c03f to f59a50b Compare December 7, 2020 12:41
@wwjhu
Copy link
Contributor Author

wwjhu commented Dec 7, 2020

Rebased.

The call to _stabilize should not be needed since the callers will
already do that themselves. Nevertheless it breaks some tests in g3
without it. It needs to be investigated why removing breaks those
tests.
@mmalerba mmalerba merged commit e70e5dd into angular:master Dec 14, 2020
@wwjhu wwjhu deleted the test-element-click-modifiers branch December 15, 2020 13:17
wagnermaciel pushed a commit to wagnermaciel/components that referenced this pull request Jan 14, 2021
…ngular#20758)

* feat(cdk/testing): support modifiers for clicking on a TestElement

Adds the ability to provide modifier keys when clicking on a TestElement

* feat(cdk/testing): update cdk/testing public API

Update API golden files for cdk/testing.

* feat(cdk/testing): update cdk/testing public API

Update API golden files for ProtractorElement and UnitTestElement.

* feat(cdk/testing): support modifiers for right clicking on a TestElement

Adds the ability to provide modifier keys when right clicking on a TestElement

* feat(cdk/testing): update cdk/testing public API

Update API golden files

* feat(cdk/testing): chore: fix spacing

Indentation and space changes based on review.

* feat(cdk/testing): re-add stabilize call

The call to _stabilize should not be needed since the callers will
already do that themselves. Nevertheless it breaks some tests in g3
without it. It needs to be investigated why removing breaks those
tests.
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Jan 15, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker cla: yes PR author has agreed to Google's Contributor License Agreement target: minor This PR is targeted for the next minor release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants