diff --git a/packages/app/cypress/e2e/specs.cy.ts b/packages/app/cypress/e2e/specs.cy.ts
index c0a11e1bf9a6..ccba4f444a04 100644
--- a/packages/app/cypress/e2e/specs.cy.ts
+++ b/packages/app/cypress/e2e/specs.cy.ts
@@ -455,177 +455,6 @@ describe('App: Index', () => {
viewportHeight: 768,
viewportWidth: 1024,
}, () => {
- context('project with storybook', () => {
- beforeEach(() => {
- cy.scaffoldProject('no-specs')
- cy.openProject('no-specs')
- cy.startAppServer('component')
- cy.visitApp()
-
- // With no specs present, the page renders two cards, one for creating from found components,
- // another for creating from found stories.
- cy.findAllByTestId('card').eq(0).as('ComponentCard')
- .within(() => {
- cy.findByRole('button', {
- name: defaultMessages.createSpec.component.importFromComponent.header,
- }).should('be.visible')
- .and('not.be.disabled')
-
- cy.contains(defaultMessages.createSpec.component.importFromComponent.description)
- .should('be.visible')
- })
-
- cy.findAllByTestId('card').eq(1).as('StoryCard')
- .within(() => {
- cy.findByRole('button', {
- name: defaultMessages.createSpec.component.importFromStory.header,
- }).should('be.visible')
- .and('not.be.disabled')
-
- cy.contains(defaultMessages.createSpec.component.importFromStory.description)
- .should('be.visible')
- })
- })
-
- it('shows create first spec page with create from component and create from story options', () => {
- cy.findByRole('heading', {
- level: 1,
- name: defaultMessages.createSpec.page.defaultPatternNoSpecs.title,
- }).should('be.visible')
-
- cy.findByTestId('create-spec-page-description')
- .should('be.visible')
- .and('contain', defaultMessages.createSpec.page.defaultPatternNoSpecs.component.description)
-
- cy.get('@ComponentCard').should('be.visible')
- cy.get('@StoryCard').should('be.visible')
-
- cy.findByTestId('no-specs-message')
- .should('be.visible')
- .and('contain', defaultMessages.createSpec.noSpecsMessage)
-
- cy.findByRole('button', { name: defaultMessages.createSpec.viewSpecPatternButton })
- .should('be.visible')
- .and('not.be.disabled')
- .click()
-
- cy.findByRole('dialog', {
- name: defaultMessages.components.specPatternModal.title,
- }).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="spec-pattern"]').contains('**/*.cy.{js,jsx,ts,tsx}')
- })
-
- cy.get('@CloseDialogButton').click()
- cy.findByRole('dialog').should('not.exist')
- })
-
- context('create from story', () => {
- beforeEach(() => {
- cy.get('@StoryCard').click()
-
- cy.findByRole('dialog', {
- name: defaultMessages.createSpec.component.importFromStory.header,
- }).as('CreateFromStoryDialog')
-
- cy.findByRole('button', { name: 'Close' }).as('DialogCloseButton')
- })
-
- it('shows story dialog that can be dismissed with Close (x) button press', () => {
- cy.get('@DialogCloseButton').click()
- cy.findByRole('dialog').should('not.exist')
- })
-
- it('shows input for file extension filter', () => {
- cy.get('@CreateFromStoryDialog').within(() => {
- cy.findByTestId('file-match-indicator').should('contain', '1 Match')
- cy.percySnapshot('Create from story generator')
- cy.findByRole('button', { name: '*.stories.*' }).click()
- cy.percySnapshot('File list search dropdown')
- cy.findByPlaceholderText(defaultMessages.components.fileSearch.byExtensionInput)
- .as('ExtensionInput')
- .clear()
- .type('foobar')
-
- cy.findByTestId('file-match-indicator').should('contain', 'No Matches')
- cy.percySnapshot('No Results')
-
- cy.findByTestId('no-results-clear').click()
-
- cy.get('@ExtensionInput').should('have.value', '*.stories.*')
-
- cy.findByTestId('file-match-indicator').should('contain', '1 Match')
- })
- })
-
- it('shows input for file name filter', () => {
- cy.get('@CreateFromStoryDialog').within(() => {
- cy.findByLabelText('file-name-input').as('FileNameInput')
- .should('have.value', '')
-
- cy.findByTestId('file-match-indicator').should('contain', '1 Match')
-
- cy.get('@FileNameInput')
- .type('foobar')
-
- cy.findByTestId('file-match-indicator').should('contain', 'No Matches')
-
- cy.findByTestId('no-results-clear').click()
-
- cy.findByTestId('file-match-indicator').should('contain', '1 Match')
-
- cy.get('@FileNameInput')
- .type('Button.stories.jsx')
-
- cy.findByTestId('file-match-indicator').should('contain', '1 of 1 Matches')
- cy.percySnapshot()
- })
- })
-
- it('shows success modal when spec is created from story', () => {
- cy.get('@CreateFromStoryDialog').within(() => {
- cy.findAllByTestId('file-list-row').eq(0).as('NewSpecFile')
-
- // TODO: assert visibility of secondary text on hover/focus when
- // item is made keyboard accessible
- // https://cypress-io.atlassian.net/browse/UNIFY-864
- // cy.get('@NewSpecFile).focus()
- // cy.findByText('src/stories/Button.stories.jsx').should('be.visible')
-
- cy.get('@NewSpecFile').click()
- })
-
- cy.percySnapshot()
-
- cy.findByRole('dialog', {
- name: defaultMessages.createSpec.successPage.header,
- }).as('SuccessDialog').within(() => {
- cy.findByRole('button', { name: 'Close' }).should('be.visible')
- cy.contains(getPathForPlatform('src/stories/Button.stories.cy.jsx')).should('be.visible')
-
- cy.findByRole('link', { name: 'Okay, run the spec' })
- .should('have.attr', 'href', `#/${getRunnerHref('src/stories/Button.stories.cy.jsx')}`)
-
- cy.findByRole('button', { name: 'Create another spec' }).click()
- })
-
- // 'Create a new spec' dialog presents with options when user indicates they want to create
- // another spec.
- cy.findByRole('dialog', {
- name: defaultMessages.createSpec.newSpecModalTitle,
- }).within(() => {
- cy.findAllByTestId('card').eq(0)
-
- // the storybook card remains enabled here
- cy.contains('button', defaultMessages.createSpec.component.importFromStory.header)
- .should('not.be.disabled')
- })
- })
- })
- })
-
context('project without storybook', () => {
beforeEach(() => {
cy.scaffoldProject('no-specs-no-storybook')
@@ -646,17 +475,6 @@ describe('App: Index', () => {
cy.contains(defaultMessages.createSpec.component.importFromComponent.description)
.should('be.visible')
})
-
- cy.findAllByTestId('card').eq(1).as('StoryCard')
- .within(() => {
- cy.findByRole('button', {
- name: defaultMessages.createSpec.component.importFromStory.header,
- }).should('be.visible')
- .and('be.disabled')
-
- cy.contains(defaultMessages.createSpec.component.importFromStory.notSetupDescription)
- .should('be.visible')
- })
})
it('shows create first spec page with create from component option', () => {
@@ -669,7 +487,6 @@ describe('App: Index', () => {
.and('contain', defaultMessages.createSpec.page.defaultPatternNoSpecs.component.description)
cy.get('@ComponentCard').should('be.visible')
- cy.get('@StoryCard').should('be.visible')
cy.findByTestId('no-specs-message').should('be.visible')
.and('contain', defaultMessages.createSpec.noSpecsMessage)
@@ -767,10 +584,6 @@ describe('App: Index', () => {
// another spec.
cy.findByRole('dialog', { name: defaultMessages.createSpec.newSpecModalTitle }).within(() => {
cy.findAllByTestId('card').eq(0)
-
- // the storybook card remains disabled here
- cy.contains('button', defaultMessages.createSpec.component.importFromStory.header)
- .should('be.disabled')
})
})
@@ -901,9 +714,6 @@ describe('App: Index', () => {
cy.findByRole('dialog', { name: defaultMessages.createSpec.newSpecModalTitle }).within(() => {
cy.findAllByTestId('card').eq(0)
.and('contain', defaultMessages.createSpec.component.importFromComponent.description)
-
- cy.findAllByTestId('card').eq(1)
- .and('contain', defaultMessages.createSpec.component.importFromStory.description)
})
})
@@ -954,36 +764,6 @@ describe('App: Index', () => {
}).should('have.attr', 'href', `#/${getRunnerHref('src/specs-folder/MyTest.cy.jsx')}`)
})
})
-
- it('shows create first spec page with create from story option', () => {
- cy.findByRole('button', { name: 'New Spec', exact: false }).click()
-
- cy.findByRole('dialog', { name: defaultMessages.createSpec.newSpecModalTitle }).within(() => {
- cy.findAllByTestId('card').eq(1)
- .and('contain', defaultMessages.createSpec.component.importFromStory.description).click()
- })
-
- cy.get('[data-cy=file-list-row]').first().click()
-
- cy.get('input').invoke('val').should('eq', getPathForPlatform('src/stories/Button.stories.cy.jsx'))
- cy.contains(defaultMessages.createSpec.component.importEmptySpec.header)
- cy.contains(defaultMessages.createSpec.component.importEmptySpec.invalidComponentWarning)
- cy.get('input').clear()
- cy.contains(defaultMessages.createSpec.component.importEmptySpec.invalidComponentWarning).should('not.exist')
- cy.contains('button', defaultMessages.createSpec.createSpec).should('be.disabled')
-
- cy.get('input').clear().type(getPathForPlatform('src/specs-folder/Button.stories.cy.jsx'))
- cy.contains('button', defaultMessages.createSpec.createSpec).should('not.be.disabled').click()
- cy.contains('h2', defaultMessages.createSpec.successPage.header)
-
- cy.get('[data-cy="file-row"]').contains(getPathForPlatform('src/specs-folder/Button.stories.cy.jsx')).click()
-
- cy.findByRole('dialog', { name: defaultMessages.createSpec.successPage.header }).as('SuccessDialog').within(() => {
- cy.findByRole('link', {
- name: 'Okay, run the spec',
- }).should('have.attr', 'href', `#/${getRunnerHref('src/specs-folder/Button.stories.cy.jsx')}`)
- })
- })
})
describe('Code Generation', () => {
@@ -1033,30 +813,6 @@ describe('App: Index', () => {
expect(spec).to.exist
}, { path: getPathForPlatform('src/stories/Button.cy.jsx') })
})
-
- it('should generate spec from story', () => {
- cy.findByTestId('new-spec-button').click()
-
- cy.contains('Create from story').click()
- const storyGlob = '*.stories.*'
-
- cy.findByTestId('file-match-button').contains(storyGlob)
- cy.percySnapshot('Story Generator')
- checkCodeGenCandidates(['Button.stories.jsx'])
-
- cy.contains('Button.stories.jsx').click()
- cy.findByTestId('file-row').contains(getPathForPlatform('src/stories/Button.stories.cy.js')).click()
- cy.contains('composeStories')
- cy.contains('ExampleWithLongName')
- cy.percySnapshot('Story Generator Success')
-
- cy.withCtx(async (ctx, o) => {
- const spec = (await ctx.project.findSpecs(ctx.currentProject ?? '', 'component', ['**/*.cy.jsx'], [], []))
- .find((spec) => spec.relative === o.path)
-
- expect(spec).to.exist
- }, { path: getPathForPlatform('src/stories/Button.stories.cy.jsx') })
- })
})
})
})
diff --git a/packages/app/cypress/e2e/specs_list_component.cy.ts b/packages/app/cypress/e2e/specs_list_component.cy.ts
index 0f6a89a83486..98b25f8e9888 100644
--- a/packages/app/cypress/e2e/specs_list_component.cy.ts
+++ b/packages/app/cypress/e2e/specs_list_component.cy.ts
@@ -33,7 +33,6 @@ describe('App: Spec List (Component)', () => {
cy.get('[data-cy="new-spec-button"]').click()
cy.get('[data-cy="standard-modal"]').get('h2').contains('Create a new spec')
cy.get('button').contains('Create from component').should('be.visible')
- cy.get('button').contains('Create from story').should('be.visible')
cy.get('button').get('[aria-label="Close"]').click()
cy.get('[data-cy="standard-modal"]').should('not.exist')
})
diff --git a/packages/app/src/specs/CreateSpecModal.cy.tsx b/packages/app/src/specs/CreateSpecModal.cy.tsx
index e125cf7e193f..6a82e1bc9041 100644
--- a/packages/app/src/specs/CreateSpecModal.cy.tsx
+++ b/packages/app/src/specs/CreateSpecModal.cy.tsx
@@ -21,7 +21,6 @@ describe('', () => {
id: 'super-unique-id',
__typename: 'CodeGenGlobs',
component: '**.vue',
- story: '**/*.stories.*',
},
storybook: null,
currentTestingType: 'component',
@@ -91,7 +90,6 @@ describe('playground', () => {
id: 'super-unique-id',
__typename: 'CodeGenGlobs',
component: '**.vue',
- story: '**/*.stories.*',
},
storybook: null,
currentTestingType: 'component',
diff --git a/packages/app/src/specs/CreateSpecModal.vue b/packages/app/src/specs/CreateSpecModal.vue
index 0f76588ec947..5271d4d381d6 100644
--- a/packages/app/src/specs/CreateSpecModal.vue
+++ b/packages/app/src/specs/CreateSpecModal.vue
@@ -73,7 +73,6 @@ fragment CreateSpecModal on Query {
defaultSpecFileName
...EmptyGenerator
...ComponentGeneratorStepOne_codeGenGlob
- ...StoryGeneratorStepOne_codeGenGlob
}
}
`
diff --git a/packages/app/src/specs/NoSpecsPage.cy.tsx b/packages/app/src/specs/NoSpecsPage.cy.tsx
index f1ed480e1e47..c995c04df559 100644
--- a/packages/app/src/specs/NoSpecsPage.cy.tsx
+++ b/packages/app/src/specs/NoSpecsPage.cy.tsx
@@ -46,8 +46,6 @@ describe('', { viewportHeight: 655, viewportWidth: 1032 }, () =>
cy.contains(text.importFromComponent.header).should('be.visible')
cy.contains(text.importFromComponent.description).should('be.visible')
- cy.contains(text.importFromStory.header).should('be.visible')
- cy.contains(text.importFromStory.notSetupDescription).should('be.visible')
cy.percySnapshot()
})
})
diff --git a/packages/app/src/specs/generators/EmptyGenerator.vue b/packages/app/src/specs/generators/EmptyGenerator.vue
index c7e6065d9170..524fb3f27d19 100644
--- a/packages/app/src/specs/generators/EmptyGenerator.vue
+++ b/packages/app/src/specs/generators/EmptyGenerator.vue
@@ -118,7 +118,7 @@ import PlusButtonIcon from '~icons/cy/add-large_x16.svg'
const props = defineProps<{
title: string
gql: EmptyGeneratorFragment
- type: 'e2e' | 'component' | 'story'
+ type: 'e2e' | 'component'
specFileName: string
erroredCodegenCandidate?: string
}>()
diff --git a/packages/app/src/specs/generators/GeneratorsCommon.tsx b/packages/app/src/specs/generators/GeneratorsCommon.tsx
index efdf85b97468..ad4246d07fcd 100644
--- a/packages/app/src/specs/generators/GeneratorsCommon.tsx
+++ b/packages/app/src/specs/generators/GeneratorsCommon.tsx
@@ -1,6 +1,6 @@
-import type { TestingTypeEnum } from '../../generated/graphql'
+import type { TestingType } from '@packages/types'
export const filters = {
- matchesCT: (testingType: TestingTypeEnum) => testingType === 'component',
- matchesE2E: (testingType: TestingTypeEnum) => testingType === 'e2e',
+ matchesCT: (testingType?: TestingType | null) => testingType === 'component',
+ matchesE2E: (testingType?: TestingType | null) => testingType === 'e2e',
}
diff --git a/packages/app/src/specs/generators/index.ts b/packages/app/src/specs/generators/index.ts
index c1d888e71681..3942cfb468cb 100644
--- a/packages/app/src/specs/generators/index.ts
+++ b/packages/app/src/specs/generators/index.ts
@@ -1,7 +1,6 @@
import { keyBy } from 'lodash'
import type { SpecGenerator, GeneratorId } from './types'
import { ComponentGenerator } from './component'
-import { StoryGenerator } from './story'
import { ScaffoldGenerator } from './scaffold'
import { EmptyGenerator } from './empty'
@@ -11,15 +10,12 @@ export * from './GeneratorsCommon'
export * from './component'
-export * from './story'
-
export * from './scaffold'
export * from './empty'
export const generatorList: SpecGenerator[] = [
ComponentGenerator,
- StoryGenerator,
ScaffoldGenerator,
EmptyGenerator,
]
diff --git a/packages/app/src/specs/generators/story/StoryGenerator.tsx b/packages/app/src/specs/generators/story/StoryGenerator.tsx
deleted file mode 100644
index f215c561a9b2..000000000000
--- a/packages/app/src/specs/generators/story/StoryGenerator.tsx
+++ /dev/null
@@ -1,18 +0,0 @@
-import type { SpecGenerator } from '../types'
-import { filters } from '../GeneratorsCommon'
-import StoryGeneratorStepOne from './StoryGeneratorStepOne.vue'
-import StoryGeneratorCard from './StoryGeneratorCard.vue'
-
-export const StoryGenerator: SpecGenerator = {
- card: StoryGeneratorCard,
- entry: StoryGeneratorStepOne,
- matches: filters.matchesCT,
- disabled: (currentProject) => {
- if (currentProject) {
- return !currentProject.storybook
- }
-
- return false
- },
- id: 'story',
-}
diff --git a/packages/app/src/specs/generators/story/StoryGeneratorCard.vue b/packages/app/src/specs/generators/story/StoryGeneratorCard.vue
deleted file mode 100644
index 797a12d093d7..000000000000
--- a/packages/app/src/specs/generators/story/StoryGeneratorCard.vue
+++ /dev/null
@@ -1,23 +0,0 @@
-
-
-
-
-
diff --git a/packages/app/src/specs/generators/story/StoryGeneratorStepOne.vue b/packages/app/src/specs/generators/story/StoryGeneratorStepOne.vue
deleted file mode 100644
index 22ed3cb79e3c..000000000000
--- a/packages/app/src/specs/generators/story/StoryGeneratorStepOne.vue
+++ /dev/null
@@ -1,198 +0,0 @@
-
-
-
- emits('update:title', value)"
- />
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/packages/app/src/specs/generators/story/index.ts b/packages/app/src/specs/generators/story/index.ts
deleted file mode 100644
index 8c97e739c2ef..000000000000
--- a/packages/app/src/specs/generators/story/index.ts
+++ /dev/null
@@ -1 +0,0 @@
-export * from './StoryGenerator'
diff --git a/packages/app/src/specs/generators/types.ts b/packages/app/src/specs/generators/types.ts
index 064b425b2c83..5cfd6c2fd516 100644
--- a/packages/app/src/specs/generators/types.ts
+++ b/packages/app/src/specs/generators/types.ts
@@ -1,3 +1,4 @@
+import type { TestingType } from '@packages/types'
import type { Component } from 'vue'
export type GeneratorId = 'component' | 'empty' | 'scaffold' | 'story'
@@ -5,7 +6,7 @@ export type GeneratorId = 'component' | 'empty' | 'scaffold' | 'story'
export interface SpecGenerator {
card: Component
entry: Component
- matches: (testingType) => boolean
+ matches: (testingType?: TestingType | null) => boolean
disabled: (currentProject?) => boolean | void
id: GeneratorId
}
diff --git a/packages/data-context/package.json b/packages/data-context/package.json
index 6b13d045dff9..43941c1c44d2 100644
--- a/packages/data-context/package.json
+++ b/packages/data-context/package.json
@@ -9,14 +9,13 @@
"check-ts": "tsc --noEmit && yarn -s tslint",
"clean-deps": "rimraf node_modules",
"tslint": "tslint --config ../ts/tslint.json --project .",
- "clean": "rimraf --glob \"./{src,test}/**/*!(.stories).js\"",
+ "clean": "rimraf --glob \"./{src,test}/**/*.js\"",
"test": "yarn test-unit",
"test-unit": "mocha -r @packages/ts/register --config ./test/.mocharc.js"
},
"dependencies": {
"@babel/code-frame": "7.8.3",
"@babel/parser": "7.13.0",
- "@storybook/csf-tools": "^6.4.0-alpha.38",
"@urql/core": "2.3.1",
"@urql/exchange-execute": "1.1.0",
"@urql/exchange-graphcache": "4.3.3",
diff --git a/packages/data-context/src/actions/ProjectActions.ts b/packages/data-context/src/actions/ProjectActions.ts
index f50df5eeba46..d364f4115e35 100644
--- a/packages/data-context/src/actions/ProjectActions.ts
+++ b/packages/data-context/src/actions/ProjectActions.ts
@@ -372,7 +372,7 @@ export class ProjectActions {
let codeGenOptions = await newSpecCodeGenOptions.getCodeGenOptions()
- if ((codeGenType === 'component' || codeGenType === 'story') && !erroredCodegenCandidate) {
+ if ((codeGenType === 'component') && !erroredCodegenCandidate) {
const filePathAbsolute = path.join(path.parse(codeGenPath).dir, codeGenOptions.fileName)
const filePathRelative = path.relative(this.ctx.currentProject || '', filePathAbsolute)
@@ -416,7 +416,7 @@ export class ProjectActions {
const cfg = await this.ctx.project.getConfig()
if (cfg && this.ctx.currentProject) {
- const testingType = (codeGenType === 'component' || codeGenType === 'story') ? 'component' : 'e2e'
+ const testingType = (codeGenType === 'component') ? 'component' : 'e2e'
await this.setSpecsFoundBySpecPattern({
path: this.ctx.currentProject,
diff --git a/packages/data-context/src/codegen/spec-options.ts b/packages/data-context/src/codegen/spec-options.ts
index eca56c8873ea..db1c4cb933f9 100644
--- a/packages/data-context/src/codegen/spec-options.ts
+++ b/packages/data-context/src/codegen/spec-options.ts
@@ -4,7 +4,6 @@ import type { ParsedPath } from 'path'
import { camelCase, capitalize } from 'lodash'
import type { CodeGenType } from '@packages/graphql/src/gen/nxs.gen'
import type { CodeGenFramework } from '@packages/scaffold-config'
-import { CsfFile, readCsfOrMdx } from '@storybook/csf-tools'
interface CodeGenOptions {
codeGenPath: string
@@ -40,10 +39,6 @@ export class SpecOptions {
return this.getComponentCodeGenOptions()
}
- if (this.options.codeGenType === 'story') {
- return this.getStoryCodeGenOptions()
- }
-
return this.getIntegrationCodeGenOptions()
}
@@ -122,80 +117,6 @@ export class SpecOptions {
}
}
- private async getStoryCodeGenOptions () {
- const frontendFramework = await this.getFrontendFramework()
-
- if (!frontendFramework) {
- throw new Error('Cannot generate a spec without a framework')
- }
-
- const defaultTitle = this.parsedPath.name.split('.')[0] || ''
-
- const csf = await readCsfOrMdx(this.options.erroredCodegenCandidate ?? this.options.codeGenPath, {
- defaultTitle,
- }).then((res) => res.parse())
-
- if ((!csf.meta.title && !csf.meta.component) || !csf.stories.length) {
- throw new Error(`Failed parsing ${this.options.codeGenPath} as CSF`)
- }
-
- const frameworkOptions = this.getFrameworkStoryOptions(
- frontendFramework.codeGenFramework,
- csf,
- )
-
- const options = {
- ...frameworkOptions,
- title: csf.meta.component || csf.meta.title,
- }
-
- return options
- }
-
- private getFrameworkStoryOptions (framework: CodeGenFramework, csf: CsfFile) {
- const storyPath = this.relativePath()
- const removeSpaces = (val: string) => val.replace(/\s+/g, '')
-
- const frameworkOptions = {
- react: {
- imports: [
- 'import React from "react"',
- 'import { mount } from "@cypress/react"',
- 'import { composeStories } from "@storybook/testing-react"',
- `import * as stories from "${storyPath}"`,
- ],
- stories: csf.stories.map((story) => {
- const component = removeSpaces(story.name)
-
- return {
- component,
- mount: `mount(<${component} />)`,
- }
- }),
- fileName: this.getFilename(this.parsedPath.ext),
- },
- vue: {
- imports: [
- 'import { mount } from "@cypress/vue"',
- 'import { composeStories } from "@storybook/testing-vue3"',
- `import * as stories from "${storyPath}"`,
- ],
- stories: csf.stories.map((story) => {
- const component = removeSpaces(story.name)
-
- return {
- component,
- mount: `mount(${component}())`,
- }
- }),
- storyName: this.parsedPath.name,
- fileName: this.getFilename(this.parsedPath.ext),
- },
- } as const
-
- return frameworkOptions[framework]
- }
-
private getFilename (ext: string) {
const { base, dir, name } = this.parsedPath
const cyWithExt = this.options.specFileExtension + ext
diff --git a/packages/data-context/src/codegen/templates.ts b/packages/data-context/src/codegen/templates.ts
index 3c9b51b2431d..f0912518b6c1 100644
--- a/packages/data-context/src/codegen/templates.ts
+++ b/packages/data-context/src/codegen/templates.ts
@@ -5,7 +5,6 @@ const getPath = (dir: string) => path.join(__dirname, dir)
export default {
component: getPath('./templates/component'),
- story: getPath('./templates/story'),
e2e: getPath('./templates/e2e'),
scaffoldIntegration: cypressEx.getPathToE2E(),
} as const
diff --git a/packages/data-context/src/codegen/templates/story/story.ejs b/packages/data-context/src/codegen/templates/story/story.ejs
deleted file mode 100644
index 64db211abafb..000000000000
--- a/packages/data-context/src/codegen/templates/story/story.ejs
+++ /dev/null
@@ -1,17 +0,0 @@
----
-fileName: <%= fileName %>
----
-
-<%- imports.join('\n') %>
-
-const composedStories = composeStories(stories)
-
-describe('<%= title %>', () => {
-<% stories.forEach(({component, mount}, i) => { _%>
- it<%= (i === 0 && stories.length > 1) ? '.only' : '' %>('should render <%= component %>', () => {
- const { <%= component %> } = composedStories
- <%- mount %>
- })
-<%= stories.length - 1 !== i ? '\n' : '' _%>
-<% }); _%>
-})
\ No newline at end of file
diff --git a/packages/data-context/src/sources/ProjectDataSource.ts b/packages/data-context/src/sources/ProjectDataSource.ts
index bbe340b6c129..78b16d47045e 100644
--- a/packages/data-context/src/sources/ProjectDataSource.ts
+++ b/packages/data-context/src/sources/ProjectDataSource.ts
@@ -20,7 +20,6 @@ import assert from 'assert'
import type { DataContext } from '..'
import { toPosix } from '../util/file'
import type { FilePartsShape } from '@packages/graphql/src/schemaTypes/objectTypes/gql-FileParts'
-import { STORIES_GLOB } from '.'
export type SpecWithRelativeRoot = FoundSpec & { relativeToCommonRoot: string }
@@ -373,7 +372,6 @@ export class ProjectDataSource {
return {
component: framework?.glob ?? looseComponentGlob,
- story: STORIES_GLOB,
}
}
diff --git a/packages/data-context/src/sources/StorybookDataSource.ts b/packages/data-context/src/sources/StorybookDataSource.ts
index 9390f448eec3..b52588651c30 100644
--- a/packages/data-context/src/sources/StorybookDataSource.ts
+++ b/packages/data-context/src/sources/StorybookDataSource.ts
@@ -10,8 +10,6 @@ const STORYBOOK_FILES = [
'preview-body.html',
]
-export const STORIES_GLOB = '*.stories.*'
-
export class StorybookDataSource {
constructor (private ctx: DataContext) {}
diff --git a/packages/data-context/test/unit/codegen/code-generator.spec.ts b/packages/data-context/test/unit/codegen/code-generator.spec.ts
index db359a590880..e3e40ef68fa2 100644
--- a/packages/data-context/test/unit/codegen/code-generator.spec.ts
+++ b/packages/data-context/test/unit/codegen/code-generator.spec.ts
@@ -196,61 +196,6 @@ describe('code-generator', () => {
expect(() => babelParse(fileContent)).not.throw()
})
- it('should generate from story template', async () => {
- const fileName = 'Button.stories.jsx'
- const target = path.join(tmpPath, 'story')
- const fileAbsolute = path.join(target, fileName)
- const action: Action = {
- templateDir: templates.story,
- target,
- }
- const codeGenArgs = {
- imports: [
- 'import React from "react"',
- 'import { mount } from "@cypress/react"',
- 'import { composeStories } from "@storybook/testing-react"',
- `import * as stories from "./Button.stories"`,
- ],
- stories: [{ component: 'Primary', mount: 'mount()' }],
- title: 'ButtonStories',
- fileName,
- }
-
- const codeGenResults = await codeGenerator(action, codeGenArgs)
- const expected: CodeGenResults = {
- files: [
- {
- type: 'text',
- status: 'add',
- file: fileAbsolute,
- content: dedent`
- import React from "react"
- import { mount } from "@cypress/react"
- import { composeStories } from "@storybook/testing-react"
- import * as stories from "./Button.stories"
-
- const composedStories = composeStories(stories)
-
- describe('ButtonStories', () => {
- it('should render Primary', () => {
- const { Primary } = composedStories
- mount()
- })
- })`,
- },
- ],
- failed: [],
- }
-
- expect(codeGenResults).deep.eq(expected)
-
- const fileContent = (await fs.readFile(fileAbsolute)).toString()
-
- expect(fileContent).eq(expected.files[0].content)
-
- expect(() => babelParse(fileContent)).not.throw()
- })
-
it('should generate from scaffoldIntegration', async () => {
const target = path.join(tmpPath, 'scaffold-integration')
const action: Action = {
@@ -295,28 +240,6 @@ describe('code-generator', () => {
expect(() => babelParse(codeGenResult.files[0].content)).not.throw()
})
- it('should generate from react story', async () => {
- const target = path.join(tmpPath, 'react-component')
- const action: Action = {
- templateDir: templates.story,
- target,
- }
-
- sinon.stub(ctx.project.frameworkLoader, 'load').resolves(FRONTEND_FRAMEWORKS[0])
-
- const newSpecCodeGenOptions = new SpecOptions(ctx, {
- codeGenPath: path.join(__dirname, 'files', 'react', 'Button.stories.jsx'),
- codeGenType: 'story',
- specFileExtension: '.cy',
- })
-
- let codeGenOptions = await newSpecCodeGenOptions.getCodeGenOptions()
-
- const codeGenResult = await codeGenerator(action, codeGenOptions)
-
- expect(() => babelParse(codeGenResult.files[0].content)).not.throw()
- })
-
it('should generate from vue component', async () => {
const target = path.join(tmpPath, 'vue-component')
const action: Action = {
@@ -338,26 +261,4 @@ describe('code-generator', () => {
expect(() => codeGenResult.files[0].content).not.throw()
})
-
- it('should generate from vue story', async () => {
- const target = path.join(tmpPath, 'vue-component')
- const action: Action = {
- templateDir: templates.story,
- target,
- }
-
- sinon.stub(ctx.project.frameworkLoader, 'load').resolves(FRONTEND_FRAMEWORKS[1])
-
- const newSpecCodeGenOptions = new SpecOptions(ctx, {
- codeGenPath: path.join(__dirname, 'files', 'vue', 'Button.stories.ts'),
- codeGenType: 'story',
- specFileExtension: '.cy',
- })
-
- let codeGenOptions = await newSpecCodeGenOptions.getCodeGenOptions()
-
- const codeGenResult = await codeGenerator(action, codeGenOptions)
-
- expect(() => babelParse(codeGenResult.files[0].content)).not.throw()
- })
})
diff --git a/packages/data-context/test/unit/codegen/files/react/Button.stories.jsx b/packages/data-context/test/unit/codegen/files/react/Button.stories.jsx
deleted file mode 100644
index 30a1db1596d7..000000000000
--- a/packages/data-context/test/unit/codegen/files/react/Button.stories.jsx
+++ /dev/null
@@ -1,47 +0,0 @@
-// @ts-nocheck
-import React from 'react';
-
-import Button from './Button';
-
-// More on default export: https://storybook.js.org/docs/react/writing-stories/introduction#default-export
-export default {
- title: 'Example/Button',
- component: Button,
- // More on argTypes: https://storybook.js.org/docs/react/api/argtypes
- argTypes: {
- backgroundColor: { control: 'color' },
- },
-};
-
-// More on component templates: https://storybook.js.org/docs/react/writing-stories/introduction#using-args
-const Template = (args) => ;
-
-export const Primary = Template.bind({});
-// More on args: https://storybook.js.org/docs/react/writing-stories/args
-Primary.args = {
- primary: true,
- label: 'Button',
-};
-
-export const Secondary = Template.bind({});
-Secondary.args = {
- label: 'Button',
-};
-
-export const Large = Template.bind({});
-Large.args = {
- size: 'large',
- label: 'Button',
-};
-
-export const Small = Template.bind({});
-Small.args = {
- size: 'small',
- label: 'Button',
-};
-
-export const ExampleWithLongName = Template.bind({});
-ExampleWithLongName.args = {
- size: 'small',
- label: 'Button',
-};
diff --git a/packages/data-context/test/unit/codegen/files/vue/Button.stories.ts b/packages/data-context/test/unit/codegen/files/vue/Button.stories.ts
deleted file mode 100644
index 1c0a8f9b8bc4..000000000000
--- a/packages/data-context/test/unit/codegen/files/vue/Button.stories.ts
+++ /dev/null
@@ -1,66 +0,0 @@
-// @ts-nocheck
-import MyButton from './Button.vue'
-
-// More on default export: https://storybook.js.org/docs/vue/writing-stories/introduction#default-export
-export default {
- title: 'Example/Button',
- component: MyButton,
- // More on argTypes: https://storybook.js.org/docs/vue/api/argtypes
- argTypes: {
- backgroundColor: { control: 'color' },
- onClick: {},
- size: {
- control: { type: 'select' },
- options: ['small', 'medium', 'large'],
- },
- },
-}
-
-// More on component templates: https://storybook.js.org/docs/vue/writing-stories/introduction#using-args
-const Template = (args) => {
- return {
- // Components used in your story `template` are defined in the `components` object
- components: { MyButton },
- // The story's `args` need to be mapped into the template through the `setup()` method
- setup () {
- return { args }
- },
- // And then the `args` are bound to your component with `v-bind="args"`
- template: '',
- }
-}
-
-export const Primary = Template.bind({})
-
-// More on args: https://storybook.js.org/docs/vue/writing-stories/args
-Primary.args = {
- primary: true,
- label: 'Button',
-}
-
-export const Secondary = Template.bind({})
-
-Secondary.args = {
- label: 'Button',
-}
-
-export const Large = Template.bind({})
-
-Large.args = {
- size: 'large',
- label: 'Button',
-}
-
-export const Small = Template.bind({})
-
-Small.args = {
- size: 'small',
- label: 'Button',
-}
-
-export const ExampleWithLongName = Template.bind({})
-
-ExampleWithLongName.args = {
- size: 'small',
- label: 'Button',
-}
diff --git a/packages/frontend-shared/cypress/support/mock-graphql/stubgql-Project.ts b/packages/frontend-shared/cypress/support/mock-graphql/stubgql-Project.ts
index 04b7d1bd2e1d..89a50fbeb643 100644
--- a/packages/frontend-shared/cypress/support/mock-graphql/stubgql-Project.ts
+++ b/packages/frontend-shared/cypress/support/mock-graphql/stubgql-Project.ts
@@ -46,7 +46,6 @@ export const createTestCurrentProject = (title: string, currentProject: Partial<
id: 'super-unique-id',
__typename: 'CodeGenGlobs',
component: '**/*.vue',
- story: '**/*.stories.*',
},
currentBrowser: stubBrowsers[0],
browsers: stubBrowsers,
diff --git a/packages/frontend-shared/src/locales/en-US.json b/packages/frontend-shared/src/locales/en-US.json
index b73a037b4f8a..d3b7d3f3c25f 100644
--- a/packages/frontend-shared/src/locales/en-US.json
+++ b/packages/frontend-shared/src/locales/en-US.json
@@ -103,12 +103,6 @@
}
},
"component": {
- "importFromStory": {
- "header": "Create from story",
- "description": "We'll generate a spec file from the Storybook files that you've written for each component in this project.",
- "notSetupDescription": "We cannot import any stories because we couldn't detect Storybook in this project.",
- "chooseAStoryHeader": "Choose a story"
- },
"importFromComponent": {
"header": "Create from component",
"description": "We'll generate an empty spec file which can be used to import and test any component in this project.",
diff --git a/packages/graphql/schemas/schema.graphql b/packages/graphql/schemas/schema.graphql
index 9a655d84421b..397352e9d964 100644
--- a/packages/graphql/schemas/schema.graphql
+++ b/packages/graphql/schemas/schema.graphql
@@ -338,14 +338,12 @@ type CodeGenGlobs implements Node {
"""Relay style Node ID field for the CodeGenGlobs field"""
id: ID!
- story: String!
}
enum CodeGenType {
component
e2e
scaffoldIntegration
- story
}
enum CodeLanguageEnum {
diff --git a/packages/graphql/src/schemaTypes/enumTypes/gql-CodeGenTypeEnum.ts b/packages/graphql/src/schemaTypes/enumTypes/gql-CodeGenTypeEnum.ts
index b0c907435d37..765c34ef614f 100644
--- a/packages/graphql/src/schemaTypes/enumTypes/gql-CodeGenTypeEnum.ts
+++ b/packages/graphql/src/schemaTypes/enumTypes/gql-CodeGenTypeEnum.ts
@@ -2,5 +2,5 @@ import { enumType } from 'nexus'
export const CodeGenTypeEnum = enumType({
name: 'CodeGenType',
- members: ['story', 'component', 'e2e', 'scaffoldIntegration'],
+ members: ['component', 'e2e', 'scaffoldIntegration'],
})
diff --git a/packages/graphql/src/schemaTypes/objectTypes/gql-CodeGenGlobs.ts b/packages/graphql/src/schemaTypes/objectTypes/gql-CodeGenGlobs.ts
index 1f9810babe73..135e21d8c66d 100644
--- a/packages/graphql/src/schemaTypes/objectTypes/gql-CodeGenGlobs.ts
+++ b/packages/graphql/src/schemaTypes/objectTypes/gql-CodeGenGlobs.ts
@@ -6,6 +6,5 @@ export const CodeGenGlobs = objectType({
node: 'component',
definition (t) {
t.nonNull.string('component')
- t.nonNull.string('story')
},
})
diff --git a/yarn.lock b/yarn.lock
index 432875c564d0..31c8ecff239f 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -2971,7 +2971,7 @@
debug "^4.1.0"
globals "^11.1.0"
-"@babel/traverse@^7.0.0", "@babel/traverse@^7.1.0", "@babel/traverse@^7.12.10", "@babel/traverse@^7.12.11", "@babel/traverse@^7.12.9", "@babel/traverse@^7.13.0", "@babel/traverse@^7.16.7", "@babel/traverse@^7.16.8", "@babel/traverse@^7.17.0", "@babel/traverse@^7.17.3", "@babel/traverse@^7.4.3", "@babel/traverse@^7.4.5", "@babel/traverse@^7.6.0", "@babel/traverse@^7.7.0", "@babel/traverse@^7.8.3", "@babel/traverse@^7.9.0":
+"@babel/traverse@^7.0.0", "@babel/traverse@^7.1.0", "@babel/traverse@^7.12.10", "@babel/traverse@^7.12.9", "@babel/traverse@^7.13.0", "@babel/traverse@^7.16.7", "@babel/traverse@^7.16.8", "@babel/traverse@^7.17.0", "@babel/traverse@^7.17.3", "@babel/traverse@^7.4.3", "@babel/traverse@^7.4.5", "@babel/traverse@^7.6.0", "@babel/traverse@^7.7.0", "@babel/traverse@^7.8.3", "@babel/traverse@^7.9.0":
version "7.17.3"
resolved "https://registry.yarnpkg.com/@babel/traverse/-/traverse-7.17.3.tgz#0ae0f15b27d9a92ba1f2263358ea7c4e7db47b57"
integrity sha512-5irClVky7TxRWIRtxlh2WPUUOLhcPN06AGgaQSB8AEwuyEBgJVuJ5imdHm5zxk8w0QS5T+tDfnDxAlhWjpb7cw==
@@ -8834,29 +8834,6 @@
"@storybook/core-client" "6.2.7"
"@storybook/core-server" "6.2.7"
-"@storybook/csf-tools@^6.4.0-alpha.38":
- version "6.4.0-beta.4"
- resolved "https://registry.yarnpkg.com/@storybook/csf-tools/-/csf-tools-6.4.0-beta.4.tgz#87e7afd9050c4b09755106bc5cb3fc31e9a1b271"
- integrity sha512-CctTaXCpmfKQHVXuAyXcHoUXjDYfXTbNGLZkQ3jnceGvf/oMqp7bqennpM7CnnHayk0sOnlppAwnQDABb2RCog==
- dependencies:
- "@babel/core" "^7.12.10"
- "@babel/generator" "^7.12.11"
- "@babel/parser" "^7.12.11"
- "@babel/plugin-transform-react-jsx" "^7.12.12"
- "@babel/preset-env" "^7.12.11"
- "@babel/traverse" "^7.12.11"
- "@babel/types" "^7.12.11"
- "@mdx-js/mdx" "^1.6.22"
- "@storybook/csf" "0.0.2--canary.6aca495.0"
- core-js "^3.8.2"
- fs-extra "^9.0.1"
- global "^4.4.0"
- js-string-escape "^1.0.1"
- lodash "^4.17.20"
- prettier "^2.2.1"
- regenerator-runtime "^0.13.7"
- ts-dedent "^2.0.0"
-
"@storybook/csf@0.0.1":
version "0.0.1"
resolved "https://registry.yarnpkg.com/@storybook/csf/-/csf-0.0.1.tgz#95901507dc02f0bc6f9ac8ee1983e2fc5bb98ce6"
@@ -8864,13 +8841,6 @@
dependencies:
lodash "^4.17.15"
-"@storybook/csf@0.0.2--canary.6aca495.0":
- version "0.0.2--canary.6aca495.0"
- resolved "https://registry.yarnpkg.com/@storybook/csf/-/csf-0.0.2--canary.6aca495.0.tgz#1569819337b0414e6e5575680c96505eda803d0b"
- integrity sha512-SRKP/zXfHQ/tAlqVAysXGyVrYvILwyDuhisXP6hpXW7BHej2BXVxR4LizA5AFpj99j066KbxdHKFMNmrncZEuw==
- dependencies:
- lodash "^4.17.15"
-
"@storybook/node-logger@6.2.7":
version "6.2.7"
resolved "https://registry.yarnpkg.com/@storybook/node-logger/-/node-logger-6.2.7.tgz#2329042e44eba1efcc6bb0689c8566a555d5b0ee"
@@ -35129,7 +35099,7 @@ preserve@^0.2.0:
resolved "https://registry.yarnpkg.com/preserve/-/preserve-0.2.0.tgz#815ed1f6ebc65926f865b310c0713bcb3315ce4b"
integrity sha1-gV7R9uvGWSb4ZbMQwHE7yzMVzks=
-prettier@2.5.1, prettier@^2.2.1:
+prettier@2.5.1:
version "2.5.1"
resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.5.1.tgz#fff75fa9d519c54cf0fce328c1017d94546bc56a"
integrity sha512-vBZcPRUR5MZJwoyi3ZoyQlc1rXeEck8KgeC9AwwOn+exuxLxq5toTRDTSaVrXHxelDMHy9zlicw8u66yxoSUFg==