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): add code to keyboard events #30188

Merged
merged 1 commit into from
Dec 16, 2024

Conversation

crisbeto
Copy link
Member

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.

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 crisbeto added the target: patch This PR is targeted for the next patch release label Dec 15, 2024
@crisbeto crisbeto marked this pull request as ready for review December 15, 2024 08:18
@crisbeto crisbeto requested a review from a team as a code owner December 15, 2024 08:18
@crisbeto crisbeto requested review from amysorto and andrewseguin and removed request for a team December 15, 2024 08:18
return `Digit${char}`;
}

return charsToCodes[char] ?? '';
Copy link
Member Author

Choose a reason for hiding this comment

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

Random thought: we could return <unsupported> here instead which would make it more obvious that our code doesn't have a mapping for the specific character.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sounds like a good idea to me, could potentially prevent some bad tests

return `Digit${char}`;
}

return charsToCodes[char] ?? '';
Copy link
Contributor

Choose a reason for hiding this comment

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

Sounds like a good idea to me, could potentially prevent some bad tests

@crisbeto crisbeto removed the request for review from amysorto December 16, 2024 15:57
@crisbeto crisbeto added the action: merge The PR is ready for merge by the caretaker label Dec 16, 2024
@crisbeto crisbeto merged commit d34d2a2 into angular:main Dec 16, 2024
24 of 26 checks passed
crisbeto added a commit that referenced this pull request 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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
action: merge The PR is ready for merge by the caretaker area: cdk/testing target: patch This PR is targeted for the next patch release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bug(ComponentHarness): TestElement.sendKeys(TestKey.ENTER) is missing Keyboard Event code
2 participants