-
Notifications
You must be signed in to change notification settings - Fork 3.3k
feat: Rename SelectorPlayground API to ElementSelector API #31889
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
feat: Rename SelectorPlayground API to ElementSelector API #31889
Conversation
BREAKING: Rename SelectorPriority API to ElementSelector API
…/github.com/cypress-io/cypress into selector-playground-api-to-element-selector
cypress
|
Project |
cypress
|
Branch Review |
selector-playground-api-to-element-selector
|
Run status |
|
Run duration | 17m 07s |
Commit |
|
Committer | Jennifer Shehane |
View all properties for this run ↗︎ |
Test results | |
---|---|
|
0
|
|
3
|
|
133
|
|
0
|
|
5553
|
View all changes introduced in this branch ↗︎ |
@@ -0,0 +1,86 @@ | |||
/// <reference types="cypress" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Converted to TypeScript - the tests are the same except for removing tests around onElement
@@ -0,0 +1,81 @@ | |||
/// <reference types="cypress" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also converted to TS. The content is the same except for removing onElement
and renaming element_selector
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a couple nits regarding types - looks good!
|
||
const VALID_SELECTOR_PRIORITY_REGEX = /^(data\-.+|id|class|tag|attributes|nth\-child|attribute:(.+)|name)$/ | ||
|
||
export const DEFAULT_SELECTOR_PRIORITIES = [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should the values here match the type we export in cypress.d.ts
- Cypress.SelectorPriority[]
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll take another look at these comments. I added the cypress types after the fact so probably should have looked back at the code to make sure they make sense together.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, this is actually the exact selectorPriority that Cypress will pass by default to the unique-selector, not just the TYPE of selector priorities accepted.
'nth-child', | ||
] as const | ||
|
||
export type SelectorType = string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of this type, we should probably use Cypress.SelectorPriority
, unless we accept strings that are not included in that union.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated the Cypress.SelectorPriority to be used everywhere.
Pausing on merging this until the Studio side updates handling Cypress.ElementSelector to address the test failure. |
Additional details
SelectorPlayground
API toElementSelector
- an error is thrown when users use theSelectorPlayground
API.unique-selector
package to latest - this should bring in smarter selectors and an expanded API.name
andattribute:*
selectors as they are accepted inunique-selector
. Types are now more specific also.Steps to test
experimentalStudio
UI - ensuring it adds selectors properly - accepting selectorPriority.How has the user experience changed?
Cypress.SelectorPlayground errors when called
Can now use

name
attribute inselectorPriority
!Can now use

attribute:*
inselectorPriority
!Current studio selector generation still works!

PR Tasks
cypress-documentation
? Updates for renaming SelectorPlayground to ElementSelector API cypress-documentation#6212type definitions
?