Skip to content

Commit

Permalink
fix: Allow option values containing quotation marks to be selected (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
davidfurey committed Mar 29, 2024
1 parent c05f3a5 commit 425ba79
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
1 change: 1 addition & 0 deletions cli/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ _Released 4/2/2024 (PENDING)_

- Fixed an issue where Cypress was not executing beyond the first spec in `cypress run` for versions of Firefox 124 and up when a custom user agent was provided. Fixes [#29190](https://github.com/cypress-io/cypress/issues/29190).
- Fixed a bug where fields using arrays in `cypress.config` are not correctly processed. Fixes [#27103](https://github.com/cypress-io/cypress/issues/27103). Fixed in [#27312](https://github.com/cypress-io/cypress/pull/27312).
- Fixed a bug where option values containing quotation marks could not be selected. Fixes [#29213](https://github.com/cypress-io/cypress/issues/29213)

## 13.7.1

Expand Down
16 changes: 16 additions & 0 deletions packages/driver/cypress/e2e/commands/actions/select.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,22 @@ describe('src/cy/commands/actions/select', () => {
})
})

it('can select by value when value contains a quotation mark', () => {
cy.$$('select[name=maps] option:nth-child(3)').attr('value', '"test"')

cy.get('select[name=maps]').select('"test"').then(($select) => {
expect($select[0].selectedOptions[0].text).to.eq('nuke')
})
})

it('can select by index when value contains a quotation mark', () => {
cy.$$('select[name=maps] option:nth-child(3)').attr('value', '"test"')

cy.get('select[name=maps]').select(2).then(($select) => {
expect($select[0].selectedOptions[0].text).to.eq('nuke')
})
})

it('can handle index when all values are identical', () => {
cy.$$('select[name=maps] option').attr('value', 'foo')

Expand Down
2 changes: 1 addition & 1 deletion packages/driver/src/cy/commands/actions/select.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ export default (Commands, Cypress, cy) => {
values.push(value)

// https://github.com/cypress-io/cypress/issues/24739
if (options.$el.find(`option[value="${value}"]`).length > 1) {
if (options.$el.find(`option[value="${value.replace(/"/g, '\\\"')}"]`).length > 1) {
notAllUniqueValues = true
}
}
Expand Down

4 comments on commit 425ba79

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 425ba79 Mar 29, 2024

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/13.7.2/linux-arm64/develop-425ba79e3e2ad3b8bf259ffcf4b0f8eb5cee1b02/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 425ba79 Mar 29, 2024

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/13.7.2/linux-x64/develop-425ba79e3e2ad3b8bf259ffcf4b0f8eb5cee1b02/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 425ba79 Mar 29, 2024

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/13.7.2/darwin-x64/develop-425ba79e3e2ad3b8bf259ffcf4b0f8eb5cee1b02/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 425ba79 Mar 29, 2024

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/13.7.2/darwin-arm64/develop-425ba79e3e2ad3b8bf259ffcf4b0f8eb5cee1b02/cypress.tgz

Please sign in to comment.