Skip to content

Commit

Permalink
fix: make clicks on type('{enter}') composed (#26395)
Browse files Browse the repository at this point in the history
* fix: make clicks on type('{enter}') composed

Co-authored-by: Mike Plummer <mike-plummer@users.noreply.github.com>

* disable failing type_events driver tests from running in Webkit

* make sure done is only called once

* use test configuration to disable on webkit

* fix changelog

* Update cli/CHANGELOG.md

Co-authored-by: Emily Rohrbough <emilyrohrbough@users.noreply.github.com>

---------

Co-authored-by: Adam Stone-Lord <adams@cypress.io>
Co-authored-by: Mike Plummer <mike-plummer@users.noreply.github.com>
Co-authored-by: Emily Rohrbough <emilyrohrbough@users.noreply.github.com>
Co-authored-by: Ben M <benm@cypress.io>
  • Loading branch information
5 people authored Apr 10, 2023
1 parent 9a42a6f commit 92542ea
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
1 change: 1 addition & 0 deletions cli/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ _Released 04/11/2023 (PENDING)_
- Fixed an issue in the onboarding wizard where project framework & bundler would not be auto-detected when opening directly into component testing mode using the `--component` CLI flag. Fixes [#22777](https://github.com/cypress-io/cypress/issues/22777).
- Updated to use the `SEMAPHORE_GIT_WORKING_BRANCH` [Semphore](https://docs.semaphoreci.com) CI environment variable to correctly associate a Cloud run to the current branch. Previously this was incorrectly associating a run to the target branch. Fixes [#26309](https://github.com/cypress-io/cypress/issues/26309).
- Fix an edge case in Component Testing where a custom `baseUrl` in `tsconfig.json` for Next.js 13.2.0+ is not respected. This was partially fixed in [#26005](https://github.com/cypress-io/cypress/pull/26005), but an edge case was missed. Fixes [#25951](https://github.com/cypress-io/cypress/issues/25951).
- Fixed an issue where `click` events fired on `.type('{enter}')` did not propagate through shadow roots. Fixes [#26392](https://github.com/cypress-io/cypress/issues/26392).

**Misc:**

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ describe('src/cy/commands/actions/type - #type events', () => {
cy.get(':text:first').type('a')
})

it('receives textInput event', (done) => {
// TODO fix this test in Webkit https://github.com/cypress-io/cypress/issues/26438
it('receives textInput event', { browser: '!webkit' }, (done) => {
const $txt = cy.$$(':text:first')

$txt[0].addEventListener('textInput', (e) => {
Expand Down Expand Up @@ -593,7 +594,8 @@ describe('src/cy/commands/actions/type - #type events', () => {
]

targets.forEach((target) => {
it(target, () => {
// TODO fix this test in Webkit https://github.com/cypress-io/cypress/issues/26438
it(target, { browser: '!webkit' }, () => {
cy.get(`#target-${target}`).focus().type('{enter}')

cy.get('li').should('have.length', 4)
Expand All @@ -606,7 +608,8 @@ describe('src/cy/commands/actions/type - #type events', () => {

describe('keydown triggered on another element', () => {
targets.forEach((target) => {
it(target, () => {
// TODO fix this test in Webkit https://github.com/cypress-io/cypress/issues/26438
it(target, { browser: '!webkit' }, () => {
cy.get('#focus-options').select(target)
cy.get('#input-text').focus().type('{enter}')

Expand Down Expand Up @@ -649,6 +652,19 @@ describe('src/cy/commands/actions/type - #type events', () => {
})
})
})

describe('shadow dom', () => {
// https://github.com/cypress-io/cypress/issues/26392
it('propagates through shadow roots', () => {
cy.visit('fixtures/shadow-dom-button.html')

cy.get('cy-test-element').invoke('on', 'click', cy.spy().as('clickSpy'))

cy.get('cy-test-element').shadow().find('button').focus().type('{enter}')

cy.get('@clickSpy').should('have.been.called')
})
})
})

describe(`type(' ') fires click event on button-like elements`, () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/driver/src/cy/commands/actions/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ export default function (Commands, Cypress, cy, state, config) {

const fireClickEvent = (el) => {
const ctor = $dom.getDocumentFromElement(el).defaultView!.PointerEvent
const event = new ctor('click')
const event = new ctor('click', { composed: true })

el.dispatchEvent(event)
}
Expand Down

5 comments on commit 92542ea

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 92542ea Apr 10, 2023

Choose a reason for hiding this comment

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

Circle has built the linux arm64 version of the Test Runner.

Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/12.9.1/linux-arm64/develop-92542ea866efbc0cde31ee337b93f3587c719f99/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 92542ea Apr 10, 2023

Choose a reason for hiding this comment

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

Circle has built the linux x64 version of the Test Runner.

Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/12.9.1/linux-x64/develop-92542ea866efbc0cde31ee337b93f3587c719f99/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 92542ea Apr 10, 2023

Choose a reason for hiding this comment

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

Circle has built the darwin x64 version of the Test Runner.

Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/12.9.1/darwin-x64/develop-92542ea866efbc0cde31ee337b93f3587c719f99/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 92542ea Apr 10, 2023

Choose a reason for hiding this comment

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

Circle has built the darwin arm64 version of the Test Runner.

Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/12.9.1/darwin-arm64/develop-92542ea866efbc0cde31ee337b93f3587c719f99/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 92542ea Apr 10, 2023

Choose a reason for hiding this comment

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

Circle has built the win32 x64 version of the Test Runner.

Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/12.9.1/win32-x64/develop-92542ea866efbc0cde31ee337b93f3587c719f99/cypress.tgz

Please sign in to comment.