-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch '10.0-release' into tgriesser/10.0-release/refactor-life…
…cycle * 10.0-release: build: remove syncRemoteGraphQL from codegen chore: fix incorrect type from merge build: allow work with local dashboard (#19376) chore: Test example recipes against chrome (#19362) test(unify): Settings e2e tests (#19324) chore(deps): update dependency ssri to 6.0.2 [security] (#19351) fix: spec from story generation, add deps for install (#19352) chore: Fix server unit tests running on mac by using actual tmp dir (#19350) fix: Add more precise types to Cypress.Commands (#19003) fix: Do not screenshot or trigger the failed event when tests are skipped (#19331) fix (#19262) fix: throw when writing to 'read only' properties of `config` (#18896) fix: close chrome when closing electron (#19322) fix: disable automatic request retries (#19161) chore: refactor cy funcs (#19080) chore(deps): update dependency @ffmpeg-installer/ffmpeg to v1.1.0 🌟 (#19300)
- Loading branch information
Showing
91 changed files
with
2,310 additions
and
1,516 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import defaultMessages from '@packages/frontend-shared/src/locales/en-US.json' | ||
|
||
const extensionInputSelector = `[placeholder="${defaultMessages.components.fileSearch.byExtensionInput}"]` | ||
|
||
describe('Code Generation', () => { | ||
beforeEach(() => { | ||
cy.scaffoldProject('react-code-gen') | ||
cy.openProject('react-code-gen') | ||
cy.startAppServer('component') | ||
cy.visitApp() | ||
}) | ||
|
||
const checkCodeGenCandidates = (specs: string[]) => { | ||
cy.findByTestId('file-match-indicator').contains(`${specs.length} Match${specs.length > 1 ? 'es' : ''}`) | ||
cy.findAllByTestId('file-list-row').should('have.length', specs.length) | ||
.each((row, i) => cy.wrap(row).contains(specs[i])) | ||
} | ||
|
||
it('should generate spec from component', () => { | ||
cy.findByTestId('new-spec-button').click() | ||
cy.findByTestId('create-spec-modal').should('be.visible').within(() => { | ||
cy.contains('Create a new spec').should('be.visible') | ||
cy.get('[data-cy="external"]').should('have.attr', 'href', 'https://on.cypress.io') | ||
}) | ||
|
||
cy.contains('Create from component').click() | ||
const componentGlob = '**/*.{jsx,tsx}' | ||
|
||
cy.findByTestId('file-match-button').contains(componentGlob) | ||
checkCodeGenCandidates(['App.cy.jsx', 'App.jsx', 'index.jsx', 'Button.jsx', 'Button.stories.jsx']) | ||
|
||
cy.intercept('query-ComponentGeneratorStepOne').as('code-gen-candidates') | ||
cy.findByTestId('file-match-button').click() | ||
cy.get(extensionInputSelector).clear().type('**/App.*') | ||
cy.wait('@code-gen-candidates') | ||
|
||
checkCodeGenCandidates(['App.css', 'App.cy.jsx', 'App.jsx']) | ||
|
||
cy.get(extensionInputSelector).clear().type(componentGlob, { parseSpecialCharSequences: false }) | ||
cy.contains('Button.jsx').click() | ||
cy.findByTestId('file-row').contains('src/stories/Button.cy.js').click() | ||
|
||
cy.withCtx(async (ctx) => { | ||
const spec = await (await ctx.project.findSpecs(ctx.currentProject?.projectRoot ?? '', 'component')) | ||
.find((spec) => spec.relative === 'src/stories/Button.cy.jsx') | ||
|
||
expect(spec).to.exist | ||
}) | ||
}) | ||
|
||
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) | ||
checkCodeGenCandidates(['Button.stories.jsx']) | ||
|
||
cy.contains('Button.stories.jsx').click() | ||
cy.findByTestId('file-row').contains('src/stories/Button.stories.cy.js').click() | ||
cy.contains('composeStories') | ||
|
||
cy.withCtx(async (ctx) => { | ||
const spec = await (await ctx.project.findSpecs(ctx.currentProject?.projectRoot ?? '', 'component')) | ||
.find((spec) => spec.relative === 'src/stories/Button.stories.cy.jsx') | ||
|
||
expect(spec).to.exist | ||
}) | ||
}) | ||
}) |
Oops, something went wrong.