Skip to content

Commit

Permalink
fix: fix spec list header, "Create specs" prompt, add workspace recom…
Browse files Browse the repository at this point in the history
…mended apollo extension (#18993)

* chore: add apollographql.vscode-apollo to extensions.json

* fix: show "Create spec" when there are no specs

* fix: display correct specslist header
  • Loading branch information
flotwig authored Nov 20, 2021
1 parent bc73aef commit d65e570
Show file tree
Hide file tree
Showing 5 changed files with 94 additions and 29 deletions.
3 changes: 3 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@

// List of extensions which are recommended for Cypress contributors using VS Code:
"recommendations": [
// Name: Apollo GraphQL
// Description: Rich editor support for GraphQL client and server development that seamlessly integrates with the Apollo platform
"apollographql.vscode-apollo",
// Name: ESLint
// Description: Integrates ESLint JavaScript into VS Code.
"dbaeumer.vscode-eslint",
Expand Down
21 changes: 21 additions & 0 deletions packages/app/cypress/e2e/integration/index.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
describe('Index', () => {
beforeEach(() => {
cy.setupE2E('component-tests')
cy.initializeApp()
})

context('with no specs', () => {
beforeEach(() => {
cy.visitApp()
cy.withCtx((ctx, o) => {
ctx.actions.file.removeFileInProject('cypress/integration/integration-spec.js')
})
})

it('shows "Create your first spec"', () => {
// after removing the default scaffolded spec, we should be prompted to create a first spec
cy.visitApp()
cy.contains('Create your first spec')
})
})
})
2 changes: 1 addition & 1 deletion packages/app/src/pages/Index.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>
<div v-if="query.data.value">
<SpecsList
v-if="query.data.value.currentProject?.specs"
v-if="query.data.value.currentProject?.specs?.edges.length"
:gql="query.data.value"
/>
<CreateSpecPage
Expand Down
88 changes: 62 additions & 26 deletions packages/app/src/specs/SpecsList.spec.tsx
Original file line number Diff line number Diff line change
@@ -1,44 +1,80 @@
import SpecsList from './SpecsList.vue'
import { Specs_SpecsListFragmentDoc, SpecNode_SpecsListFragment } from '../generated/graphql-test'
import { Specs_SpecsListFragmentDoc, SpecNode_SpecsListFragment, TestingTypeEnum } from '../generated/graphql-test'

const rowSelector = '[data-testid=specs-list-row]'
const inputSelector = 'input'

function mountWithTestingType (testingType: TestingTypeEnum) {
cy.mountFragment(Specs_SpecsListFragmentDoc, {
onResult: (ctx) => {
if (!ctx.currentProject) throw new Error('need current project')

ctx.currentProject.currentTestingType = testingType

return ctx
},
render: (gqlVal) => {
return <SpecsList gql={gqlVal} />
},
})
}

let specs: Array<SpecNode_SpecsListFragment> = []

describe('<SpecsList />', { keystrokeDelay: 0 }, () => {
beforeEach(() => {
cy.mountFragment(Specs_SpecsListFragmentDoc, {
onResult: (ctx) => {
specs = ctx.currentProject?.specs?.edges || []

return ctx
},
render: (gqlVal) => {
return <SpecsList gql={gqlVal} />
},
context('when testingType is unset', () => {
beforeEach(() => {
cy.mountFragment(Specs_SpecsListFragmentDoc, {
onResult: (ctx) => {
specs = ctx.currentProject?.specs?.edges || []

return ctx
},
render: (gqlVal) => {
return <SpecsList gql={gqlVal} />
},
})
})
})

it('should filter specs', () => {
const spec = specs[0].node
it('should filter specs', () => {
const spec = specs[0].node

cy.get(inputSelector).type('garbage 🗑', { delay: 0 })
.get(rowSelector)
.should('not.exist')

cy.get(inputSelector).clear().type(spec.relative)
cy.get(rowSelector).first().should('contain', spec.relative.replace(`/${spec.fileName}${spec.specFileExtension}`, ''))
cy.get(rowSelector).last().should('contain', `${spec.fileName}${spec.specFileExtension}`)
})

it('should close directories', () => {
// close all directories
['src', 'packages', 'frontend', '__test__', 'lib', 'tests'].forEach((dir) => {
cy.get('[data-cy="row-directory-depth-0"]').contains(dir).click()
})

cy.get('[data-cy="spec-item"]').should('not.exist')
})
})

cy.get(inputSelector).type('garbage 🗑', { delay: 0 })
.get(rowSelector)
.should('not.exist')
context('when testingType is e2e', () => {
beforeEach(() => {
mountWithTestingType('e2e')
})

cy.get(inputSelector).clear().type(spec.relative)
cy.get(rowSelector).first().should('contain', spec.relative.replace(`/${spec.fileName}${spec.specFileExtension}`, ''))
cy.get(rowSelector).last().should('contain', `${spec.fileName}${spec.specFileExtension}`)
it('should display the e2e testing header', () => {
cy.get('[data-cy="specs-testing-type-header"]').should('have.text', 'E2E Specs')
})
})

it('should close directories', () => {
// close all directories
['src', 'packages', 'frontend', '__test__', 'lib', 'tests'].forEach((dir) => {
cy.get('[data-cy="row-directory-depth-0"]').contains(dir).click()
context('when testingType is component', () => {
beforeEach(() => {
mountWithTestingType('component')
})

// all directories closed; no specs should be showing.
cy.get('[data-cy="spec-item"]').should('not.exist')
it('should display the component testing header', () => {
cy.get('[data-cy="specs-testing-type-header"]').should('have.text', 'Component Specs')
})
})
})
9 changes: 7 additions & 2 deletions packages/app/src/specs/SpecsList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,12 @@
/>

<div class="grid grid-cols-2 children:text-gray-800 children:font-medium">
<div class="flex justify-between items-center">
{{ t('specPage.componentSpecsHeader') }}
<div
class="flex justify-between items-center"
data-cy="specs-testing-type-header"
>
{{ props.gql.currentProject?.currentTestingType === 'component' ?
t('specPage.componentSpecsHeader') : t('specPage.e2eSpecsHeader') }}
</div>
<div class="flex justify-between items-center">
<div>{{ t('specPage.gitStatusHeader') }}</div>
Expand Down Expand Up @@ -113,6 +117,7 @@ fragment Specs_SpecsList on Query {
currentProject {
id
projectRoot
currentTestingType
specs: specs(first: 100) {
edges {
...SpecNode_SpecsList
Expand Down

2 comments on commit d65e570

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on d65e570 Nov 20, 2021

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/9.1.0/circle-10.0-release-d65e57044c0f94a31efc71de91bf34bb432f536a/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on d65e570 Nov 20, 2021

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/9.1.0/circle-10.0-release-d65e57044c0f94a31efc71de91bf34bb432f536a/cypress.tgz

Please sign in to comment.