Skip to content

Commit

Permalink
fix: selector playground copy full command (#22097)
Browse files Browse the repository at this point in the history
  • Loading branch information
ZachJW34 committed Jun 6, 2022
1 parent e35b3b0 commit e58ec7a
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 8 deletions.
16 changes: 16 additions & 0 deletions packages/app/src/runner/SpecRunnerHeaderOpenMode.cy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -208,4 +208,20 @@ describe('SpecRunnerHeaderOpenMode', { viewportHeight: 500 }, () => {
cy.get('[data-cy="select-browser"] > button').should('be.disabled')
cy.percySnapshot()
})

it('opens and closes selector playground', () => {
cy.mountFragment(SpecRunnerHeaderFragmentDoc, {
render: (gqlVal) => {
return renderWithGql(gqlVal)
},
})

cy.get('[data-cy="playground-activator"]').click()
cy.get('#selector-playground').should('be.visible')

cy.percySnapshot()

cy.get('[data-cy="playground-activator"]').click()
cy.get('#selector-playground').should('not.exist')
})
})
6 changes: 3 additions & 3 deletions packages/app/src/runner/SpecRunnerHeaderOpenMode.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
:aria-label="t('runner.selectorPlayground.toggle')"
@click="togglePlayground"
>
<i-cy-crosshairs_x16 class="icon-dark-gray-600" />
<i-cy-crosshairs_x16 :class="[selectorPlaygroundStore.show ? 'icon-dark-indigo-500' : 'icon-dark-gray-500']" />
</Button>
<div class="mr-12px max-w-100% grid text-gray-600 items-center truncate">
{{ autStore.url }}
Expand All @@ -34,12 +34,12 @@
<Button
data-cy="playground-activator"
:disabled="isDisabled"
class="border-gray-100 mr-12px"
class="border-gray-100 mr-12px"
variant="outline"
:aria-label="t('runner.selectorPlayground.toggle')"
@click="togglePlayground"
>
<i-cy-crosshairs_x16 class="icon-dark-gray-600" />
<i-cy-crosshairs_x16 :class="[selectorPlaygroundStore.show ? 'icon-dark-indigo-500' : 'icon-dark-gray-500']" />
</Button>
</div>
<SpecRunnerDropdown
Expand Down
5 changes: 2 additions & 3 deletions packages/app/src/runner/aut-iframe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -462,17 +462,16 @@ export class AutIframe {
const $el = this.getElements(Cypress.dom)

const selectorPlaygroundStore = useSelectorPlaygroundStore()
const command = `cy.${selectorPlaygroundStore.method}('${selectorPlaygroundStore.selector}')`

if (!$el) {
return logger.logFormatted({
Command: command,
Command: selectorPlaygroundStore.command,
Yielded: 'Nothing',
})
}

logger.logFormatted({
Command: command,
Command: selectorPlaygroundStore.command,
Elements: $el.length,
Yielded: Cypress.dom.getElements($el),
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ describe('SelectorPlayground', () => {
cy.get('[data-cy="selector-playground-tooltip"]').should('be.visible').contains('Copied!')
cy.percySnapshot('Copy to clipboard click tooltip')

cy.wrap(copyStub).should('have.been.calledWith', '.foo-bar')
cy.wrap(copyStub).should('have.been.calledWith', 'cy.get(\'.foo-bar\')')
})

it('prints elements when selected elements found', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ function printSelected () {
const { copy } = useClipboard({ copiedDuring: 2000 })
const copyToClipboard = () => {
copy(selector.value)
copy(selectorPlaygroundStore.command)
}
</script>

Expand Down
4 changes: 4 additions & 0 deletions packages/app/src/store/selector-playground-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,5 +99,9 @@ export const useSelectorPlaygroundStore = defineStore({

return state.numElements === 1 ? '1 matched element' : `${state.numElements} matched elements`
},

command (state): string {
return `cy.${state.method}('${this.selector}')`
},
},
})

3 comments on commit e58ec7a

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on e58ec7a Jun 6, 2022

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 platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/10.0.4/linux-x64/develop-e58ec7a68894dcf448eeb940f78fa8934c44eadc/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on e58ec7a Jun 6, 2022

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 platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/10.0.4/darwin-x64/develop-e58ec7a68894dcf448eeb940f78fa8934c44eadc/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on e58ec7a Jun 6, 2022

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 platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/10.0.4/win32-x64/develop-e58ec7a68894dcf448eeb940f78fa8934c44eadc/cypress.tgz

Please sign in to comment.