Skip to content

Commit

Permalink
fix: label text should be clickable to toggle snapshot highlight (#21122
Browse files Browse the repository at this point in the history
)

* update component

* update test

* update component test

* remove unused label text

* add cursor:pointer styles to label
  • Loading branch information
marktnoonan committed Apr 20, 2022
1 parent ccfee1e commit b8ba111
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 11 deletions.
8 changes: 6 additions & 2 deletions packages/app/cypress/e2e/runner/runner.ui.cy.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { loadSpec } from './support/spec-loader'
import defaultMessages from '@packages/frontend-shared/src/locales/en-US.json'

describe('src/cypress/runner', () => {
describe('tests finish with correct state', () => {
Expand Down Expand Up @@ -110,8 +111,10 @@ describe('src/cypress/runner', () => {
.click()
.should('have.class', 'command-is-pinned')

const { highlightsLabel } = defaultMessages.runner.snapshot

// disable highlights
cy.get('[id="toggle-highlights"]')
cy.findByLabelText(highlightsLabel)
.should('have.attr', 'aria-checked', 'true')
.click()
.should('have.attr', 'aria-checked', 'false')
Expand All @@ -123,7 +126,8 @@ describe('src/cypress/runner', () => {
.click()
.should('have.class', 'command-is-pinned')

cy.get('[id="toggle-highlights"]').should('have.attr', 'aria-checked', 'true')
cy.findByLabelText(highlightsLabel)
.should('have.attr', 'aria-checked', 'true')
})

it('correctly resets named snapshot toggle state when pinning new command', () => {
Expand Down
5 changes: 2 additions & 3 deletions packages/app/src/runner/SnapshotControls.cy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import SnapshotControls from './SnapshotControls.vue'
import { autSnapshot } from '../../cypress/support/fixtures'
import { useSnapshotStore } from './snapshot-store'
import { createEventManager, createTestAutIframe } from '../../cypress/component/support/ctSupport'
import { defaultMessages } from '@cy/i18n'

const snapshotWithSnapshots = { ...autSnapshot }
const snapshotPinned = { ...autSnapshot, snapshots: [] }
Expand Down Expand Up @@ -91,9 +92,7 @@ describe('SnapshotControls', { viewportHeight: 200, viewportWidth: 500 }, () =>

mountSnapshotControls(eventManager, autIframe)
cy.get('body')
.findByText('Highlights')
.should('be.visible')
.findByLabelText('Toggle highlights')
.findByLabelText(defaultMessages.runner.snapshot.highlightsLabel)
.click({ force: true })
})

Expand Down
10 changes: 5 additions & 5 deletions packages/app/src/runner/SnapshotHighlightControls.vue
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
<template>
<div class="rounded flex font-medium bg-gray-900 py-2px px-12px text-gray-200 text-14px leading-20px gap-8px items-center">
<label
class="hidden"
for="toggle-highlights"
>{{ t('runner.snapshot.toggleHighlights') }}</label>
<Switch
name="toggle-highlights"
:value="props.value"
size="sm"
@update="emits('toggle')"
/>
{{ t('runner.snapshot.highlightsLabel') }}
<label
for="toggle-highlights"
class="cursor-pointer"
>{{ t('runner.snapshot.highlightsLabel') }}
</label>
</div>
</template>

Expand Down
1 change: 0 additions & 1 deletion packages/frontend-shared/src/locales/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -637,7 +637,6 @@
"troubleRendering": "if you're having trouble rendering your components properly."
},
"snapshot": {
"toggleHighlights": "Toggle highlights",
"highlightsLabel": "Highlights",
"testsRunningError": "Cannot show Snapshot while tests are running",
"snapshotMissingError": "The snapshot is missing. Displaying current state of the DOM.",
Expand Down

1 comment on commit b8ba111

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on b8ba111 Apr 20, 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.0/linux-x64/10.0-release-b8ba111c404cd20e6aba4579977d1d157c107b5f/cypress.tgz

Please sign in to comment.