-
Notifications
You must be signed in to change notification settings - Fork 3.4k
feat: add back selector playground #33073
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
Merged
Merged
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
4dde570
feat: add back selector playground
jennifer-shehane 5fd84e8
update test
jennifer-shehane 8be53d2
changelog entry
jennifer-shehane 07e4d7a
add Studio qualifier
jennifer-shehane 2db4e0e
add snapshot for when the Studio playground is open
jennifer-shehane cd9f84a
add a few more component tests
jennifer-shehane 5708b23
update show highlight
jennifer-shehane 2dc26bf
add defensive cleanup
jennifer-shehane 9836add
rename test
jennifer-shehane 92571ca
disable studio recording when selectorplayground is shown
jennifer-shehane 2f0fbbb
Merge branch 'develop' into add-back-selector-playground
jennifer-shehane e733947
add code to open/close selector playground
jennifer-shehane 82af734
Merge branch 'develop' into add-back-selector-playground
jennifer-shehane 5bb0135
add callback, etc for selector playground to interact with panel + up…
jennifer-shehane f39e19c
removing some tests that are redundant
jennifer-shehane b3db65b
add try catch around autIframe initialization
jennifer-shehane 8ed399f
remove disabledRecording calls since they're unused
jennifer-shehane f97372f
close assertions dropdown when selector playground is opened
jennifer-shehane b3d2b05
add a disabled style that is closer to the other disabled styles
jennifer-shehane 72f2b06
Merge branch 'develop' into add-back-selector-playground
jennifer-shehane cc20775
Merge branch 'develop' into add-back-selector-playground
jennifer-shehane 58ae592
update to use design-system purple-dark-mode button
jennifer-shehane File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -30,18 +30,29 @@ describe('SelectorPlayground', () => { | |
| cy.get('[data-cy="playground-selector"]').should('have.value', 'body') | ||
| }) | ||
|
|
||
| it('toggles enabled', () => { | ||
| it('is enabled when playground is open', () => { | ||
| const selectorPlaygroundStore = useSelectorPlaygroundStore() | ||
|
|
||
| expect(selectorPlaygroundStore.isEnabled).to.be.false | ||
| // Reset to disabled state before mounting | ||
| selectorPlaygroundStore.setEnabled(false) | ||
| selectorPlaygroundStore.setShowingHighlight(false) | ||
|
|
||
| const { autIframe } = mountSelectorPlayground() | ||
| // Create autIframe and set up spies BEFORE mounting, since onMounted will call these methods | ||
| const autIframe = createTestAutIframe() | ||
|
|
||
| cy.spy(autIframe, 'toggleSelectorPlayground') | ||
| cy.spy(autIframe, 'toggleSelectorHighlight') | ||
| cy.spy(selectorPlaygroundStore, 'setShowingHighlight') | ||
|
|
||
| cy.get('[data-cy="playground-toggle"]').click().then(() => { | ||
| mountSelectorPlayground(createEventManager(), autIframe) | ||
|
|
||
| // When the playground component is mounted (visible), it should automatically be enabled | ||
| // and initialize highlighting functionality | ||
| cy.then(() => { | ||
| expect(selectorPlaygroundStore.isEnabled).to.be.true | ||
| expect(autIframe.toggleSelectorPlayground).to.have.been.called | ||
| expect(autIframe.toggleSelectorPlayground).to.have.been.calledWith(true) | ||
jennifer-shehane marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| expect(selectorPlaygroundStore.setShowingHighlight).to.have.been.calledWith(true) | ||
| expect(autIframe.toggleSelectorHighlight).to.have.been.calledWith(true) | ||
| }) | ||
| }) | ||
|
|
||
|
|
@@ -189,4 +200,94 @@ describe('SelectorPlayground', () => { | |
|
|
||
| cy.get('[data-cy="playground-selector"]').should('have.attr', 'autocomplete', 'off') | ||
| }) | ||
|
|
||
| it('triggers highlight on mouseover', () => { | ||
|
Comment on lines
+203
to
+204
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. just added some CT coverage that was never there |
||
| const selectorPlaygroundStore = useSelectorPlaygroundStore() | ||
| const { autIframe } = mountSelectorPlayground() | ||
|
|
||
| cy.spy(autIframe, 'toggleSelectorHighlight') | ||
| cy.spy(selectorPlaygroundStore, 'setShowingHighlight') | ||
|
|
||
| cy.get('[data-cy="playground-selector"]').parent().trigger('mouseover') | ||
|
|
||
| cy.then(() => { | ||
| expect(selectorPlaygroundStore.setShowingHighlight).to.have.been.calledWith(true) | ||
| expect(autIframe.toggleSelectorHighlight).to.have.been.calledWith(true) | ||
| }) | ||
| }) | ||
|
|
||
| it('updates store and triggers highlight when typing', () => { | ||
| const selectorPlaygroundStore = useSelectorPlaygroundStore() | ||
| const { autIframe } = mountSelectorPlayground() | ||
|
|
||
| cy.spy(autIframe, 'toggleSelectorHighlight') | ||
|
|
||
| cy.get('[data-cy="playground-selector"]').clear().type('.test-selector') | ||
|
|
||
| cy.then(() => { | ||
| expect(selectorPlaygroundStore.getSelector).to.eq('.test-selector') | ||
| expect(autIframe.toggleSelectorHighlight).to.have.been.calledWith(true) | ||
| }) | ||
| }) | ||
|
|
||
| it('shows correct selector value when switching methods', () => { | ||
| const selectorPlaygroundStore = useSelectorPlaygroundStore() | ||
|
|
||
| selectorPlaygroundStore.getSelector = '.get-selector' | ||
| selectorPlaygroundStore.containsSelector = '.contains-selector' | ||
|
|
||
| mountSelectorPlayground() | ||
|
|
||
| cy.get('[data-cy="playground-selector"]').should('have.value', '.get-selector') | ||
|
|
||
| cy.get('[aria-label="Selector methods"]').click() | ||
| cy.findByRole('menuitem', { name: 'cy.contains' }).click() | ||
|
|
||
| cy.get('[data-cy="playground-selector"]').should('have.value', '.contains-selector') | ||
|
|
||
| cy.get('[aria-label="Selector methods"]').click() | ||
| cy.findByRole('menuitem', { name: 'cy.get' }).click() | ||
|
|
||
| cy.get('[data-cy="playground-selector"]').should('have.value', '.get-selector') | ||
| }) | ||
|
|
||
| it('has correct input attributes to prevent autocomplete', () => { | ||
| mountSelectorPlayground() | ||
|
|
||
| cy.get('[data-cy="playground-selector"]') | ||
| .should('have.attr', 'autocomplete', 'off') | ||
| .should('have.attr', 'autocapitalize', 'none') | ||
| .should('have.attr', 'autocorrect', 'off') | ||
| .should('have.attr', 'spellcheck', 'false') | ||
| }) | ||
|
|
||
| it('resets show state when component unmounts to prevent inconsistent state', () => { | ||
| const selectorPlaygroundStore = useSelectorPlaygroundStore() | ||
|
|
||
| // Set up initial state: show=true and component is enabled | ||
| selectorPlaygroundStore.setShow(true) | ||
| selectorPlaygroundStore.setEnabled(true) | ||
|
|
||
| const { element } = mountSelectorPlayground() | ||
|
|
||
| // Verify component is visible and state is consistent | ||
| cy.get('#selector-playground').should('be.visible') | ||
| cy.then(() => { | ||
| expect(selectorPlaygroundStore.show).to.be.true | ||
| expect(selectorPlaygroundStore.isEnabled).to.be.true | ||
| }) | ||
|
|
||
| // Unmount the component (simulating navigation or parent unmount) | ||
| // This should trigger onUnmounted which calls setShow(false) | ||
| // In Cypress Vue component testing, cy.mount returns { wrapper, component } | ||
| element.then(({ wrapper }) => { | ||
| wrapper.unmount() | ||
| }) | ||
|
|
||
| // After unmount, show should be false to prevent inconsistent state | ||
| // where show=true but component is not rendered, causing unexpected re-appearance | ||
| cy.then(() => { | ||
| expect(selectorPlaygroundStore.show).to.be.false | ||
| }) | ||
| }) | ||
| }) | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
This isn't used anywhere else in this component