Skip to content

bug(cdk/testing): The UnitTestElements.hover() does not trigger a mouseover event #24486

Closed
@TimothyGillespie

Description

@TimothyGillespie

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

Currently, the UnitTestElement would trigger a mouseenter event but not a mouseover event. This is unexpected since a mouseover should always trigger alongside a mouseenter. I noticed this when I wrote a harness for a component depending on the mouseover event, and thus required a workaround.

I would gladly contribute a fix. However, tests are required and there seems to be no test infrastructure for UnitTestElement yet, which makes it difficult for me to submit a PR right away.

It seems to me the issue would be resolved by simply adding the line
dispatchMouseEvent(this.element, 'mouseover');
here: https://github.com/angular/components/blob/master/src/cdk/testing/testbed/unit-test-element.ts

Reproduction

Steps to reproduce:

  1. Create a component utilizing mousover.
  2. Create Harness utilizing the hover to trigger the mouseover.
  3. Notice that the test will not work as expected.

Expected Behavior

A mouseover event is triggered when using the hover() method.

Actual Behavior

No mouseover event is triggered when using the hover() method.

Environment

  • Angular: 13.2.4
  • CDK/Material: 13.2.4
  • Browser(s): Jest
  • Operating System (e.g. Windows, macOS, Ubuntu): Fedora and Windows

Metadata

Metadata

Assignees

Labels

P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgentarea: cdk/testing

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions