Skip to content

Commit

Permalink
fix: Correct pluralization in Spec Pattern (#22773)
Browse files Browse the repository at this point in the history
* fix: Correct pluralization in Spec Pattern

* update failing e2e tests

Co-authored-by: Zachary Williams <ZachJW34@gmail.com>
Co-authored-by: Lachlan Miller <lachlan.miller.1990@outlook.com>
  • Loading branch information
3 people authored Jul 19, 2022
1 parent 89acf9c commit 2aa7b93
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 12 deletions.
6 changes: 3 additions & 3 deletions packages/app/cypress/e2e/specs.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ describe('App: Specs', () => {
}).should('be.visible').within(() => {
cy.validateExternalLink({ name: 'Need help', href: 'https://on.cypress.io/test-type-options' })
cy.findByRole('button', { name: 'Close' }).should('be.visible').as('CloseDialogButton')
cy.get('[data-cy="file-match-indicator"]').contains('0 Matches')
cy.get('[data-cy="file-match-indicator"]').contains('No Matches')
cy.get('[data-cy="spec-pattern"]').contains('cypress/e2e/**/*.cy.{js,jsx,ts,tsx}')
})

Expand Down Expand Up @@ -320,7 +320,7 @@ describe('App: Specs', () => {
.should('be.visible')
.and('contain', defaultMessages.createSpec.page.customPatternNoSpecs.description.split('{0}')[0])

cy.findByTestId('file-match-indicator').should('contain', '0 Matches')
cy.findByTestId('file-match-indicator').should('contain', 'No Matches')
cy.findByRole('button', { name: 'cypress.config.js' })
cy.findByTestId('spec-pattern').should('contain', 'src/**/*.{cy,spec}.{js,jsx}')

Expand Down Expand Up @@ -652,7 +652,7 @@ describe('App: Specs', () => {
.should('be.visible')
.and('contain', defaultMessages.createSpec.page.customPatternNoSpecs.description.split('{0}')[0])

cy.findByTestId('file-match-indicator').should('contain', '0 Matches')
cy.findByTestId('file-match-indicator').should('contain', 'No Matches')
cy.findByRole('button', { name: 'cypress.config.js' })
cy.findByTestId('spec-pattern').should('contain', 'src/specs-folder/*.cy.{js,jsx}')

Expand Down
34 changes: 33 additions & 1 deletion packages/app/src/components/SpecPatterns.cy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ describe('<SpecPatterns />', () => {
cy.get('[data-cy="file-match-indicator"]').contains('50 Matches')
})

it('renders component spec pattern should not show matches', () => {
it('renders component spec pattern should not show matches verbiage', () => {
cy.mountFragment(SpecPatternsFragmentDoc, {
onResult: (res) => {
if (!res) {
Expand All @@ -46,4 +46,36 @@ describe('<SpecPatterns />', () => {
cy.get('[data-cy="spec-pattern"]').contains('**/*.cy.{js,jsx,ts,tsx}')
cy.get('[data-cy="file-match-indicator"]').should('contain', 'specPattern')
})

it('displays `No Matches` when specs are empty', () => {
cy.mountFragment(SpecPatternsFragmentDoc, {
onResult: (res) => {
if (!res) {
return
}

res.currentTestingType = 'component'
res.specs = []
},
render: (gql) => <div class="p-16px"><SpecPatterns gql={gql}/></div>,
})

cy.get('[data-cy="file-match-indicator"]').contains('No Matches')
})

it('displays `1 Match` when specs has 1 element', () => {
cy.mountFragment(SpecPatternsFragmentDoc, {
onResult: (res) => {
if (!res) {
return
}

res.currentTestingType = 'component'
res.specs = res.specs.slice(0, 1) || []
},
render: (gql) => <div class="p-16px"><SpecPatterns gql={gql}/></div>,
})

cy.get('[data-cy="file-match-indicator"]').contains('1 Match')
})
})
10 changes: 3 additions & 7 deletions packages/app/src/components/SpecPatterns.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,7 @@
<div class="flex p-16px items-center justify-between">
<FileMatchIndicator :variant="props.variant">
<span v-if="props.variant === 'info'">specPattern</span>
<i18n-t
v-else
scope="global"
keypath="components.specPattern.matches"
>
{{ props.gql.specs.length }}
</i18n-t>
<span v-else>{{ t('components.specPattern.matches', props.gql.specs.length) }}</span>
</FileMatchIndicator>
<OpenConfigFileInIDE
v-slot="{onClick}"
Expand Down Expand Up @@ -41,6 +35,7 @@
<script lang="ts" setup>
import { computed } from 'vue'
import { gql } from '@urql/core'
import { useI18n } from 'vue-i18n'
import type { SpecPatternsFragment } from '../generated/graphql'
import OpenConfigFileInIDE from '@packages/frontend-shared/src/gql-components/OpenConfigFileInIDE.vue'
import FileMatchIndicator from './FileMatchIndicator.vue'
Expand All @@ -58,6 +53,7 @@ fragment SpecPatterns on CurrentProject {
}
`
const { t } = useI18n()
const props = defineProps<{
gql: SpecPatternsFragment
variant?: 'default' | 'info'
Expand Down
2 changes: 1 addition & 1 deletion packages/frontend-shared/src/locales/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"dismissAriaLabel": "Dismiss"
},
"specPattern": {
"matches": "{0} Matches"
"matches": "No Matches | {n} Match | {n} Matches"
},
"specPatternModal": {
"title": "Spec pattern settings"
Expand Down

5 comments on commit 2aa7b93

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 2aa7b93 Jul 19, 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.3.1/linux-x64/develop-2aa7b93ea1f891bf96e0baf1fb1b426827519562/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 2aa7b93 Jul 19, 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 arm64 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.3.1/linux-arm64/develop-2aa7b93ea1f891bf96e0baf1fb1b426827519562/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 2aa7b93 Jul 19, 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 arm64 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.3.1/darwin-arm64/develop-2aa7b93ea1f891bf96e0baf1fb1b426827519562/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 2aa7b93 Jul 19, 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.3.1/darwin-x64/develop-2aa7b93ea1f891bf96e0baf1fb1b426827519562/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 2aa7b93 Jul 19, 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.3.1/win32-x64/develop-2aa7b93ea1f891bf96e0baf1fb1b426827519562/cypress.tgz

Please sign in to comment.