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

bug(ComponentHarness): TestElement.sendKeys(TestKey.ENTER) is missing Keyboard Event code #27034

Closed
1 task
rstreidt-cisco opened this issue May 4, 2023 · 1 comment · Fixed by #30188
Closed
1 task
Assignees
Labels
area: cdk/testing P2 The issue is important to a large percentage of users, with a workaround

Comments

@rstreidt-cisco
Copy link

rstreidt-cisco commented May 4, 2023

Is this a regression?

  • Yes, this behavior used to work in the previous version

The previous version in which this bug was not present was

No response

Description

When calling sendKey with TestKey.ENTER on a TestElement, the keyboard event that gets generated shows blank for the code property.

Reproduction

Steps to reproduce:

  1. Run sendKeys(TestKey.ENTER) on any TestElement
  2. Check the Keyboard Event code value.

See StackBlitz: https://stackblitz.com/edit/harness-issue-zpusdu?file=src%2Fapp%2Fmy-harness-example.spec.ts

Expected Behavior

Keyboard Event code value should be 'Enter'.

This is from testing out the Enter key on Mozilla's site with Chrome on Windows showing the correct code value:
keyboard-event

Actual Behavior

Keyboard Event code value is ''.

Environment

  • Angular: 15.2.4
  • CDK/Material: 15.2.4
  • Browser(s):
  • Operating System (e.g. Windows, macOS, Ubuntu): Windows
@rstreidt-cisco rstreidt-cisco added the needs triage This issue needs to be triaged by the team label May 4, 2023
@andrewseguin andrewseguin added P2 The issue is important to a large percentage of users, with a workaround area: material/testing area: cdk/testing and removed needs triage This issue needs to be triaged by the team area: material/testing labels May 30, 2023
@crisbeto crisbeto self-assigned this Dec 15, 2024
crisbeto added a commit to crisbeto/material2 that referenced this issue Dec 15, 2024
When the `UnitTestElement` dispatches keyboard event sequences, it sends out fake events which didn't have the `code` property. These changes add mappings for common keys to their codes.

Fixes angular#27034.
crisbeto added a commit that referenced this issue Dec 16, 2024
When the `UnitTestElement` dispatches keyboard event sequences, it sends out fake events which didn't have the `code` property. These changes add mappings for common keys to their codes.

Fixes #27034.

(cherry picked from commit d34d2a2)
@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 16, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: cdk/testing P2 The issue is important to a large percentage of users, with a workaround
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants