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

fix(cdk/testing): TestElement sendKeys method should throw if no keys have been specified #18271

Merged

Conversation

devversion
Copy link
Member

@devversion devversion commented Jan 23, 2020

Previously, calling sendKeys without any keys resulted in a runtime
exception Cannot read X of undefined error being thrown. This is because
the first element of the passed arguments to sendKeys has been considered
always truthy. This assumption is wrong since arbitrary amount of arguments
can be passed due to the spread parameter.

To ensure consistent and reasonable behavior of this function, we fix
the runtime exception mentioned above, but throw if no keys have been
determined (not necessarily only if the arguments length is zero).

@googlebot googlebot added the cla: yes PR author has agreed to Google's Contributor License Agreement label Jan 23, 2020
@devversion devversion marked this pull request as ready for review January 23, 2020 20:21
@devversion devversion requested a review from mmalerba as a code owner January 23, 2020 20:21
@devversion devversion added the target: patch This PR is targeted for the next patch release label Jan 23, 2020
@devversion devversion force-pushed the fix/cdk-testing-send-keys-do-not-throw branch from 84ebadf to 827c485 Compare January 28, 2020 14:22
@devversion devversion changed the title fix(cdk/testing): TestElement sendKeys method should not throw if no keys have been specified fix(cdk/testing): TestElement sendKeys method should throw if no keys have been specified Jan 28, 2020
@devversion devversion force-pushed the fix/cdk-testing-send-keys-do-not-throw branch from 827c485 to 78b3039 Compare January 28, 2020 14:28
@devversion devversion requested a review from a team as a code owner January 28, 2020 14:28
@mmalerba mmalerba added pr: lgtm action: merge The PR is ready for merge by the caretaker labels Jan 28, 2020
Copy link
Member

@jelbourn jelbourn left a comment

Choose a reason for hiding this comment

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

LGTM

@devversion devversion added the P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent label Jun 8, 2020
@jelbourn
Copy link
Member

@devversion can you rebase?

@devversion devversion force-pushed the fix/cdk-testing-send-keys-do-not-throw branch from 78b3039 to 65b1040 Compare July 29, 2020 09:03
@devversion
Copy link
Member Author

@jelbourn Done

@devversion devversion force-pushed the fix/cdk-testing-send-keys-do-not-throw branch from 65b1040 to 98d0bf5 Compare July 29, 2020 20:53
@mmalerba mmalerba removed the lgtm label Jul 31, 2020
@devversion devversion force-pushed the fix/cdk-testing-send-keys-do-not-throw branch from 98d0bf5 to 43b5665 Compare September 11, 2020 09:43
@josephperrott josephperrott removed the request for review from a team April 29, 2021 15:59
@devversion devversion force-pushed the fix/cdk-testing-send-keys-do-not-throw branch 4 times, most recently from 65ae6e7 to 60b4843 Compare August 23, 2021 11:54
@andrewseguin andrewseguin added needs rebase and removed cla: yes PR author has agreed to Google's Contributor License Agreement labels Dec 28, 2021
@devversion devversion force-pushed the fix/cdk-testing-send-keys-do-not-throw branch from 60b4843 to 4ab10e8 Compare January 31, 2022 13:30
@devversion devversion force-pushed the fix/cdk-testing-send-keys-do-not-throw branch from 4ab10e8 to e66f0f5 Compare January 31, 2022 13:49
… have been specified

Previously, calling `sendKeys` without any keys resulted in a runtime
exception `Cannot read X of undefined` error being thrown. This is because
the first element of the passed arguments to `sendKeys` has been considered
always truthy. This assumption is wrong since arbitrary amount of arguments
can be passed due to the spread parameter.

To ensure consistent and reasonable behavior of this function, we fix
the runtime exception mentioned above, but throw if no keys have been
determined (not necessarily only if the arguments length is zero).
@devversion devversion force-pushed the fix/cdk-testing-send-keys-do-not-throw branch from e66f0f5 to f677cb9 Compare January 31, 2022 16:48
@zarend zarend added the presubmit failures This PR has failures in Google's internal presubmit process and cannot be immediately merged label Feb 4, 2022
@zarend
Copy link
Contributor

zarend commented Feb 4, 2022

Ran presubmit for this last night and got 46 failures. I briefly looked at the failures and most of them are Error: No keys have been specified.. Many of those errors are coming from the autocomplete harness where the autocomplete harness calls sendKeys.

@andrewseguin
Copy link
Contributor

This fails the case where the test called sendKeys(''). In particular it seems to come from cases where the client calls await autocompleteHarness.enterText('');.

Is that a no-op in the code? Does it at least focus or pull up the autocomplete? I tried removing the calls in a couple tests and they continued to pass, so I suspect I could just remove the lines that call it with the empty string unless there's some behavior I'm missing

@crisbeto crisbeto merged commit caf88cc into angular:master Mar 2, 2022
crisbeto pushed a commit that referenced this pull request Mar 2, 2022
… have been specified (#18271)

Previously, calling `sendKeys` without any keys resulted in a runtime
exception `Cannot read X of undefined` error being thrown. This is because
the first element of the passed arguments to `sendKeys` has been considered
always truthy. This assumption is wrong since arbitrary amount of arguments
can be passed due to the spread parameter.

To ensure consistent and reasonable behavior of this function, we fix
the runtime exception mentioned above, but throw if no keys have been
determined (not necessarily only if the arguments length is zero).

(cherry picked from commit caf88cc)
crapStone pushed a commit to Calciumdibromid/CaBr2 that referenced this pull request Mar 8, 2022
This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [@angular/cdk](https://github.com/angular/components) | dependencies | patch | [`13.2.4` -> `13.2.5`](https://renovatebot.com/diffs/npm/@angular%2fcdk/13.2.4/13.2.5) |
| [@angular/material](https://github.com/angular/components) | dependencies | patch | [`13.2.4` -> `13.2.5`](https://renovatebot.com/diffs/npm/@angular%2fmaterial/13.2.4/13.2.5) |

---

### Release Notes

<details>
<summary>angular/components</summary>

### [`v13.2.5`](https://github.com/angular/components/blob/HEAD/CHANGELOG.md#&#8203;1325-satin-sash-2022-03-02)

[Compare Source](angular/components@13.2.4...13.2.5)

##### cdk

| Commit | Type | Description |
| -- | -- | -- |
| [9e34a0f69f](angular/components@9e34a0f) | fix | **drag-drop:** error if preview dimensions are accessed too early ([#&#8203;24498](angular/components#24498)) |
| [9be3c46b01](angular/components@9be3c46) | fix | **testing:** TestElement sendKeys method should throw if no keys have been specified ([#&#8203;18271](angular/components#18271)) |
| [8e57a89cba](angular/components@8e57a89) | perf | **overlay:** add event listeners for overlay dispatchers outside of zone ([#&#8203;24408](angular/components#24408)) |

##### material

| Commit | Type | Description |
| -- | -- | -- |
| [ed2f516401](angular/components@ed2f516) | fix | **autocomplete:** auto-highlighted first option not display correctly if the floating label is disabled ([#&#8203;14507](angular/components#14507)) |
| [502102116e](angular/components@5021021) | fix | **autocomplete:** don't block default arrow keys when using modifiers ([#&#8203;11987](angular/components#11987)) |
| [f31fd3f066](angular/components@f31fd3f) | fix | **autocomplete:** reopen panel on input click ([#&#8203;16020](angular/components#16020)) |
| [5a79042d7d](angular/components@5a79042) | fix | **button-toggle:** use solid border color ([#&#8203;14253](angular/components#14253)) |
| [e2d4eecfcb](angular/components@e2d4eec) | fix | **checkbox:** inconsistent disabled color ([#&#8203;23083](angular/components#23083)) |
| [005ec323de](angular/components@005ec32) | fix | **checkbox:** incorrect text color when placed inside an overlay with a dark theme ([#&#8203;19054](angular/components#19054)) |
| [d7cbd1315f](angular/components@d7cbd13) | fix | **datepicker:** matDatepickerParse error not being added on first invalid value ([#&#8203;11524](angular/components#11524)) |
| [046022f31d](angular/components@046022f) | fix | **datepicker:** use aria-live over cdkAriaLive on period button ([#&#8203;24398](angular/components#24398)) |
| [37f69dbf7e](angular/components@37f69db) | fix | **dialog:** use passed in ComponentFactoryResolver to resolve dialog content ([#&#8203;17710](angular/components#17710)) |
| [2e15f54a9f](angular/components@2e15f54) | fix | **menu:** focus lost if active item is removed ([#&#8203;14039](angular/components#14039)) |
| [ea07fa8e64](angular/components@ea07fa8) | fix | **progress-spinner:** unable to change mode on spinner directive ([#&#8203;14514](angular/components#14514)) |
| [1a498a6a81](angular/components@1a498a6) | fix | **sort:** remove role from header when disabled ([#&#8203;24477](angular/components#24477)) |
| [72019531db](angular/components@7201953) | fix | **tooltip:** don't hide when pointer moves to tooltip ([#&#8203;24475](angular/components#24475)) |

##### material-experimental

| Commit | Type | Description |
| -- | -- | -- |
| [7b85cc077c](angular/components@7b85cc0) | fix | **mdc-button:** density styles being overwritten by structural styles ([#&#8203;22736](angular/components#22736)) |
| [aeb1426e4c](angular/components@aeb1426) | fix | **mdc-chips:** expose avatar harness ([#&#8203;24499](angular/components#24499)) |

#### Special Thanks

Andrew Seguin, Artur Androsovych, Jeri Peier, Kristiyan Kostadinov, Paul Gschwendtner, Yousaf Nawaz and Zach Arend

<!-- CHANGELOG SPLIT MARKER -->

</details>

---

### Configuration

📅 **Schedule**: At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about these updates again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, click this checkbox.

---

This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).

Co-authored-by: cabr2-bot <[email protected]>
Reviewed-on: https://codeberg.org/Calciumdibromid/CaBr2/pulls/1199
Reviewed-by: Epsilon_02 <[email protected]>
Co-authored-by: Calciumdibromid Bot <[email protected]>
Co-committed-by: Calciumdibromid Bot <[email protected]>
@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 Apr 2, 2022
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 P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent presubmit failures This PR has failures in Google's internal presubmit process and cannot be immediately merged target: patch This PR is targeted for the next patch release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants