Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add experimentalStudio flag back #23506

Merged
merged 8 commits into from
Aug 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions cli/types/cypress.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2866,10 +2866,15 @@ declare namespace Cypress {
*/
experimentalModifyObstructiveThirdPartyCode: boolean
/**
* Generate and save commands directly to your test suite by interacting with your app as an end user would.
Copy link
Contributor Author

@lmiller1990 lmiller1990 Aug 23, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This description was incorrect, drive-by fix.

* Enables AST-based JS/HTML rewriting. This may fix issues caused by the existing regex-based JS/HTML replacement algorithm.
* @default false
*/
experimentalSourceRewriting: boolean
/**
* Generate and save commands directly to your test suite by interacting with your app as an end user would.
* @default false
*/
experimentalStudio: boolean
/**
* Number of times to retry a failed test.
* If a number is set, tests will retry in both runMode and openMode.
Expand Down Expand Up @@ -3059,7 +3064,7 @@ declare namespace Cypress {
viteConfig?: Omit<Exclude<PickConfigOpt<'viteConfig'>, undefined>, 'base' | 'root'>
}

interface ComponentConfigOptions<ComponentDevServerOpts = any> extends Omit<CoreConfigOptions, 'baseUrl' | 'experimentalSessionAndOrigin'> {
interface ComponentConfigOptions<ComponentDevServerOpts = any> extends Omit<CoreConfigOptions, 'baseUrl' | 'experimentalSessionAndOrigin' | 'experimentalStudio'> {
devServer: DevServerFn<ComponentDevServerOpts> | DevServerConfigOptions
devServerConfig?: ComponentDevServerOpts
/**
Expand Down
3 changes: 3 additions & 0 deletions packages/config/__snapshots__/index.spec.ts.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ exports['config/src/index .getDefaultValues returns list of public config keys 1
"experimentalModifyObstructiveThirdPartyCode": false,
"experimentalSourceRewriting": false,
"experimentalSingleTabRunMode": false,
"experimentalStudio": false,
"fileServerFolder": "",
"fixturesFolder": "cypress/fixtures",
"excludeSpecPattern": "*.hot-update.js",
Expand Down Expand Up @@ -121,6 +122,7 @@ exports['config/src/index .getDefaultValues returns list of public config keys f
"experimentalModifyObstructiveThirdPartyCode": false,
"experimentalSourceRewriting": false,
"experimentalSingleTabRunMode": false,
"experimentalStudio": false,
"fileServerFolder": "",
"fixturesFolder": "cypress/fixtures",
"excludeSpecPattern": "*.hot-update.js",
Expand Down Expand Up @@ -199,6 +201,7 @@ exports['config/src/index .getPublicConfigKeys returns list of public config key
"experimentalModifyObstructiveThirdPartyCode",
"experimentalSourceRewriting",
"experimentalSingleTabRunMode",
"experimentalStudio",
"fileServerFolder",
"fixturesFolder",
"excludeSpecPattern",
Expand Down
13 changes: 12 additions & 1 deletion packages/config/src/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ const BREAKING_OPTION_ERROR_KEY: Readonly<AllCypressErrorNames[]> = [
'EXPERIMENTAL_SESSION_SUPPORT_REMOVED',
'EXPERIMENTAL_SINGLE_TAB_RUN_MODE',
'EXPERIMENTAL_SHADOW_DOM_REMOVED',
'EXPERIMENTAL_STUDIO_REMOVED',
'FIREFOX_GC_INTERVAL_REMOVED',
'NODE_VERSION_DEPRECATION_SYSTEM',
'NODE_VERSION_DEPRECATION_BUNDLED',
Expand Down Expand Up @@ -222,6 +221,12 @@ const driverConfigOptions: Array<DriverConfigOption> = [
validation: validate.isBoolean,
isExperimental: true,
requireRestartOnChange: 'server',
}, {
name: 'experimentalStudio',
defaultValue: false,
validation: validate.isBoolean,
isExperimental: true,
requireRestartOnChange: 'server',
}, {
name: 'fileServerFolder',
defaultValue: '',
Expand Down Expand Up @@ -669,6 +674,12 @@ export const testingTypeBreakingOptions: { e2e: Array<BreakingOption>, component
errorKey: 'CONFIG_FILE_INVALID_TESTING_TYPE_CONFIG_COMPONENT',
isWarning: false,
},
{
name: 'experimentalStudio',
errorKey: 'EXPERIMENTAL_STUDIO_E2E_ONLY',
isWarning: false,
testingTypes: ['component'],
},
{
name: 'testIsolation',
errorKey: 'CONFIG_FILE_INVALID_TESTING_TYPE_CONFIG_COMPONENT',
Expand Down
2 changes: 2 additions & 0 deletions packages/config/test/project/utils.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1042,6 +1042,7 @@ describe('config/src/project/utils', () => {
experimentalInteractiveRunEvents: { value: false, from: 'default' },
experimentalSessionAndOrigin: { value: false, from: 'default' },
experimentalSingleTabRunMode: { value: false, from: 'default' },
experimentalStudio: { value: false, from: 'default' },
experimentalSourceRewriting: { value: false, from: 'default' },
fileServerFolder: { value: '', from: 'default' },
fixturesFolder: { value: 'cypress/fixtures', from: 'default' },
Expand Down Expand Up @@ -1134,6 +1135,7 @@ describe('config/src/project/utils', () => {
experimentalInteractiveRunEvents: { value: false, from: 'default' },
experimentalSessionAndOrigin: { value: false, from: 'default' },
experimentalSingleTabRunMode: { value: false, from: 'default' },
experimentalStudio: { value: false, from: 'default' },
experimentalSourceRewriting: { value: false, from: 'default' },
env: {
foo: {
Expand Down
1 change: 0 additions & 1 deletion packages/driver/cypress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { defineConfig } from 'cypress'

export default defineConfig({
'projectId': 'ypt4pf',
// @ts-ignore - https://github.com/cypress-io/cypress/issues/23338
'experimentalStudio': true,
'hosts': {
'*.foobar.com': '127.0.0.1',
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions packages/errors/src/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1091,6 +1091,12 @@ export const AllCypressErrors = {

If you have feedback about the experiment, please join the discussion here: http://on.cypress.io/single-tab-run-mode`
},
EXPERIMENTAL_STUDIO_E2E_ONLY: () => {
return errTemplate`\
The ${fmt.highlight(`experimentalStudio`)} experiment is currently only supported for End to End Testing.

If you have feedback about the experiment, please join the discussion here: http://on.cypress.io/studio-beta`
},
FIREFOX_GC_INTERVAL_REMOVED: () => {
return errTemplate`\
The ${fmt.highlight(`firefoxGcInterval`)} configuration option was removed in ${fmt.cypressVersion(`8.0.0`)}. It was introduced to work around a bug in Firefox 79 and below.
Expand Down
6 changes: 6 additions & 0 deletions packages/errors/test/unit/visualSnapshotErrors_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1200,5 +1200,11 @@ describe('visual error templates', () => {
default: [],
}
},

EXPERIMENTAL_STUDIO_E2E_ONLY: () => {
return {
default: [],
}
},
})
})
4 changes: 4 additions & 0 deletions packages/frontend-shared/src/locales/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,10 @@
"experimentalSourceRewriting": {
"name": "Source Rewriting",
"description": "Enables AST-based JS/HTML rewriting. This may fix issues caused by the existing regex-based JS/HTML replacement algorithm. See [#5273](https://github.com/cypress-io/cypress/issues/5273) for details."
},
"experimentalStudio": {
"name": "Studio",
"description": "Generate and save commands directly to your test suite by interacting with your app as an end user would."
}
},
"device": {
Expand Down
1 change: 1 addition & 0 deletions packages/graphql/schemas/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -765,6 +765,7 @@ enum ErrorTypeEnum {
EXPERIMENTAL_SESSION_SUPPORT_REMOVED
EXPERIMENTAL_SHADOW_DOM_REMOVED
EXPERIMENTAL_SINGLE_TAB_RUN_MODE
EXPERIMENTAL_STUDIO_E2E_ONLY
EXPERIMENTAL_STUDIO_REMOVED
EXTENSION_NOT_LOADED
FIREFOX_COULD_NOT_CONNECT
Expand Down
71 changes: 36 additions & 35 deletions packages/launchpad/cypress/e2e/config-warning.cy.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
const THIRTY_SECONDS = 1000 * 30

describe('baseUrl', () => {
it('should show baseUrl warning if Cypress cannot connect to provided baseUrl', () => {
cy.scaffoldProject('config-with-base-url-warning')
Expand Down Expand Up @@ -88,50 +90,49 @@ describe('experimentalSingleTabRunMode', () => {
})
})

// TODO: Figure out this. experimentalStudio is back, but must be nested under E2E? Or, does
// a top level experimentalStudio get applied, but only to E2E?
describe.skip('experimentalStudio', () => {
it('should show experimentalStudio warning if Cypress detects experimentalStudio config has been set', () => {
cy.scaffoldProject('experimental-studio')
cy.openProject('experimental-studio')
describe('experimentalStudio', () => {
it('is not a valid config for component testing', () => {
cy.scaffoldProject('experimentalSingleTabRunMode')
cy.openProject('experimentalSingleTabRunMode')
cy.visitLaunchpad()
cy.withCtx(async (ctx) => {
await ctx.actions.file.writeFileInProject('cypress.config.js', `
const { defineConfig } = require('cypress')

module.exports = defineConfig({
component: {
experimentalStudio: true,
devServer: {
bundler: 'webpack',
},
},
})`)
})

cy.get('[data-cy="warning-alert"]').contains('Warning: Experimental Studio Removed')
cy.get('[data-cy-testingtype="e2e"]').click()
cy.get('[data-cy="warning-alert"]').contains('Warning: Experimental Studio Removed')
cy.get('[data-cy-testingtype="component"]').click()
cy.findByTestId('alert-body').contains('The experimentalStudio experiment is currently only supported for End to End Testing.')
})

it('should not continually show experimentalStudio warning in the same project', () => {
cy.scaffoldProject('experimental-studio')
cy.openProject('experimental-studio')
cy.visitLaunchpad()

cy.get('[data-cy="warning-alert"]').contains('Warning: Experimental Studio Removed')
cy.findAllByLabelText(cy.i18n.components.modal.dismiss).first().click()
cy.get('[data-cy="warning-alert"]').should('not.exist')
it('is a valid config for e2e testing', { defaultCommandTimeout: THIRTY_SECONDS }, () => {
cy.scaffoldProject('e2e')
cy.openProject('e2e')
cy.withCtx(async (ctx) => {
await ctx.actions.file.writeFileInProject('cypress.config.js', await ctx.actions.file.readFileInProject('cypress.config.js'))
})
await ctx.actions.file.writeFileInProject('cypress.config.js', `
const { defineConfig } = require('cypress')

cy.get('[data-cy="loading-spinner"]')
cy.get('h1').should('contain', 'Welcome to Cypress!')
cy.get('[data-cy="warning-alert"]').should('not.exist')
})
module.exports = defineConfig({
experimentalStudio: true,
e2e: {
experimentalStudio: true
},
})
`)
})

it('should show experimentalStudio warning when opening project and going back', () => {
cy.scaffoldProject('experimental-studio')
cy.addProject('experimental-studio')
cy.openGlobalMode()
cy.visitLaunchpad()
cy.contains('experimental-studio').click()
cy.get('[data-cy="warning-alert"]').contains('Warning: Experimental Studio Removed')
cy.findAllByLabelText(cy.i18n.components.modal.dismiss).first().click()
cy.get('[data-cy="warning-alert"]').should('not.exist')
cy.get('a').contains('Projects').click()
cy.contains('[data-cy="project-card"]', 'experimental-studio').click()

cy.get('[data-cy-testingtype="e2e"]').click()
cy.get('[data-cy="warning-alert"]').contains('Warning: Experimental Studio Removed')
cy.get('h1').contains('Initializing Config').should('not.exist')
cy.get('h1').contains('Choose a Browser')
})
})

Expand Down