mirror of
https://github.com/cypress-io/cypress.git
synced 2026-03-11 20:09:47 -05:00
fix: do not allow experimentalSessionAndOrigin to be available in CT … (#21588)
* fix: do not allow experimentalSessionAndOrigin to be available in CT per https://github.com/cypress-io/cypress/issues/21573 * remove experimentalSessionAndOrigin config as it is read only * move runner session tests under own system test project to turn on experimentalSessionAndOrigin flag * refactor session ui runner tests to point to runner-session-e2e-specs folder * fix cypress_spec.js to account for experimentalSessionAndOrigin options * remove experimentalSessionAndOrigin from env args
This commit is contained in:
2
cli/types/cypress.d.ts
vendored
2
cli/types/cypress.d.ts
vendored
@@ -3043,7 +3043,7 @@ declare namespace Cypress {
|
||||
viteConfig?: Omit<Exclude<PickConfigOpt<'viteConfig'>, undefined>, 'base' | 'root'>
|
||||
}
|
||||
|
||||
interface ComponentConfigOptions<ComponentDevServerOpts = any> extends Omit<CoreConfigOptions, 'baseUrl'> {
|
||||
interface ComponentConfigOptions<ComponentDevServerOpts = any> extends Omit<CoreConfigOptions, 'baseUrl' | 'experimentalSessionAndOrigin'> {
|
||||
devServer: DevServerFn<ComponentDevServerOpts> | DevServerConfigOptions
|
||||
devServerConfig?: ComponentDevServerOpts
|
||||
}
|
||||
|
||||
@@ -39,7 +39,8 @@ describe('runner/cypress sessions.ui.spec', {
|
||||
|
||||
it('creates new session', () => {
|
||||
loadSpec({
|
||||
filePath: 'sessions/new_session.cy.js',
|
||||
projectName: 'runner-session-e2e-specs',
|
||||
filePath: 'new_session.cy.js',
|
||||
})
|
||||
|
||||
validateSessionsInstrumentPanel(['blank_session'])
|
||||
@@ -62,7 +63,8 @@ describe('runner/cypress sessions.ui.spec', {
|
||||
|
||||
it('creates new session with validation', () => {
|
||||
loadSpec({
|
||||
filePath: 'sessions/new_session_with_validation.cy.js',
|
||||
projectName: 'runner-session-e2e-specs',
|
||||
filePath: 'new_session_with_validation.cy.js',
|
||||
})
|
||||
|
||||
validateSessionsInstrumentPanel(['blank_session'])
|
||||
@@ -95,7 +97,8 @@ describe('runner/cypress sessions.ui.spec', {
|
||||
|
||||
it('creates new session and fails validation', () => {
|
||||
loadSpec({
|
||||
filePath: 'sessions/new_session_and_fails_validation.cy.js',
|
||||
projectName: 'runner-session-e2e-specs',
|
||||
filePath: 'new_session_and_fails_validation.cy.js',
|
||||
})
|
||||
|
||||
validateSessionsInstrumentPanel(['blank_session'])
|
||||
@@ -127,7 +130,8 @@ describe('runner/cypress sessions.ui.spec', {
|
||||
|
||||
it('restores saved session', () => {
|
||||
loadSpec({
|
||||
filePath: 'sessions/restores_saved_session.cy.js',
|
||||
projectName: 'runner-session-e2e-specs',
|
||||
filePath: 'restores_saved_session.cy.js',
|
||||
})
|
||||
|
||||
cy.get('.test').each(($el) => cy.wrap($el).click())
|
||||
@@ -180,7 +184,8 @@ describe('runner/cypress sessions.ui.spec', {
|
||||
|
||||
it('recreates session', () => {
|
||||
loadSpec({
|
||||
filePath: 'sessions/recreates_session.cy.js',
|
||||
projectName: 'runner-session-e2e-specs',
|
||||
filePath: 'recreates_session.cy.js',
|
||||
})
|
||||
|
||||
cy.get('.test').each(($el) => cy.wrap($el).click())
|
||||
@@ -241,7 +246,8 @@ describe('runner/cypress sessions.ui.spec', {
|
||||
|
||||
it('recreates session and fails validation', () => {
|
||||
loadSpec({
|
||||
filePath: 'sessions/recreates_session_and_fails_validation.cy.js',
|
||||
projectName: 'runner-session-e2e-specs',
|
||||
filePath: 'recreates_session_and_fails_validation.cy.js',
|
||||
})
|
||||
|
||||
cy.get('.test').each(($el) => cy.wrap($el).click())
|
||||
@@ -298,7 +304,8 @@ describe('runner/cypress sessions.ui.spec', {
|
||||
|
||||
it('multiple sessions in a test', () => {
|
||||
loadSpec({
|
||||
filePath: 'sessions/multiple_sessions.cy.js',
|
||||
projectName: 'runner-session-e2e-specs',
|
||||
filePath: 'multiple_sessions.cy.js',
|
||||
})
|
||||
|
||||
validateSessionsInstrumentPanel(['user1', 'user2'])
|
||||
|
||||
@@ -19,6 +19,7 @@ export type LoadSpecOptions = {
|
||||
failCount?: number | string
|
||||
pendingCount?: number | string
|
||||
hasPreferredIde?: boolean
|
||||
projectName?: 'runner-e2e-specs' | 'runner-session-e2e-specs'
|
||||
}
|
||||
|
||||
export function loadSpec (options: LoadSpecOptions) {
|
||||
@@ -29,10 +30,11 @@ export function loadSpec (options: LoadSpecOptions) {
|
||||
failCount = '--',
|
||||
hasPreferredIde = false,
|
||||
pendingCount,
|
||||
projectName = 'runner-e2e-specs',
|
||||
} = options
|
||||
|
||||
cy.scaffoldProject('runner-e2e-specs')
|
||||
cy.openProject('runner-e2e-specs')
|
||||
cy.scaffoldProject(projectName)
|
||||
cy.openProject(projectName)
|
||||
cy.startAppServer()
|
||||
|
||||
cy.withCtx((ctx, options) => {
|
||||
|
||||
@@ -209,7 +209,7 @@ const resolvedOptions: Array<ResolvedConfigOption> = [
|
||||
defaultValue: false,
|
||||
validation: validate.isBoolean,
|
||||
isExperimental: true,
|
||||
canUpdateDuringTestTime: true,
|
||||
canUpdateDuringTestTime: false,
|
||||
}, {
|
||||
name: 'experimentalSourceRewriting',
|
||||
defaultValue: false,
|
||||
@@ -637,6 +637,11 @@ export const breakingRootOptions: Array<BreakingOption> = [
|
||||
errorKey: 'CONFIG_FILE_INVALID_ROOT_CONFIG_E2E',
|
||||
isWarning: false,
|
||||
testingTypes: ['e2e'],
|
||||
}, {
|
||||
name: 'experimentalSessionAndOrigin',
|
||||
errorKey: 'CONFIG_FILE_INVALID_ROOT_CONFIG_E2E',
|
||||
isWarning: false,
|
||||
testingTypes: ['e2e'],
|
||||
}, {
|
||||
name: 'excludeSpecPattern',
|
||||
errorKey: 'CONFIG_FILE_INVALID_ROOT_CONFIG',
|
||||
@@ -684,5 +689,10 @@ export const testingTypeBreakingOptions: { e2e: Array<BreakingOption>, component
|
||||
errorKey: 'CONFIG_FILE_INVALID_TESTING_TYPE_CONFIG_COMPONENT',
|
||||
isWarning: false,
|
||||
},
|
||||
{
|
||||
name: 'experimentalSessionAndOrigin',
|
||||
errorKey: 'CONFIG_FILE_INVALID_TESTING_TYPE_CONFIG_COMPONENT',
|
||||
isWarning: false,
|
||||
},
|
||||
],
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@ module.exports = defineConfig({
|
||||
return require('./cypress/plugins/index.js')(on, config)
|
||||
},
|
||||
baseUrl: 'localhost:3000',
|
||||
experimentalSessionAndOrigin: true,
|
||||
},
|
||||
component: {
|
||||
setupNodeEvents(on, config) {},
|
||||
@@ -68,6 +69,7 @@ module.exports = defineConfig({
|
||||
},
|
||||
retries: 2,
|
||||
baseUrl: 'localhost:300',
|
||||
experimentalSessionAndOrigin: true,
|
||||
slowTestThreshold: 500,
|
||||
},
|
||||
component: {
|
||||
|
||||
@@ -434,6 +434,7 @@ export function reduceConfig (cfg: LegacyCypressConfigJson, options: CreateConfi
|
||||
e2e: { ...acc.e2e, supportFile: val },
|
||||
}
|
||||
case 'baseUrl':
|
||||
case 'experimentalSessionAndOrigin':
|
||||
return {
|
||||
...acc,
|
||||
e2e: { ...acc.e2e, [key]: val },
|
||||
|
||||
@@ -60,6 +60,7 @@ describe('cypress.config.js generation', () => {
|
||||
const config: Partial<Cypress.Config> = {
|
||||
e2e: {
|
||||
baseUrl: 'localhost:3000',
|
||||
experimentalSessionAndOrigin: true,
|
||||
},
|
||||
}
|
||||
|
||||
@@ -126,6 +127,7 @@ describe('cypress.config.js generation', () => {
|
||||
const config = {
|
||||
viewportWidth: 300,
|
||||
baseUrl: 'localhost:300',
|
||||
experimentalSessionAndOrigin: true,
|
||||
slowTestThreshold: 500,
|
||||
e2e: {
|
||||
retries: 2,
|
||||
|
||||
@@ -1653,9 +1653,9 @@ describe('lib/cypress', () => {
|
||||
// this should be overriden by the env argument
|
||||
json.baseUrl = 'http://localhost:8080'
|
||||
|
||||
const { supportFile, specPattern, excludeSpecPattern, baseUrl, slowTestThreshold, ...rest } = json
|
||||
const { supportFile, specPattern, excludeSpecPattern, baseUrl, experimentalSessionAndOrigin, slowTestThreshold, ...rest } = json
|
||||
|
||||
return settings.writeForTesting(this.todosPath, { ...rest, e2e: { baseUrl, supportFile, specPattern, excludeSpecPattern } })
|
||||
return settings.writeForTesting(this.todosPath, { ...rest, e2e: { baseUrl, experimentalSessionAndOrigin, supportFile, specPattern, excludeSpecPattern } })
|
||||
}).then(() => {
|
||||
return cypress.start([
|
||||
'--port=2121',
|
||||
@@ -1684,6 +1684,7 @@ describe('lib/cypress', () => {
|
||||
expect(cfg.pageLoadTimeout).to.eq(1000)
|
||||
expect(cfg.port).to.eq(2121)
|
||||
expect(cfg.baseUrl).to.eq('http://localhost')
|
||||
expect(cfg.experimentalSessionAndOrigin).to.be.false
|
||||
expect(cfg.watchForFileChanges).to.be.false
|
||||
expect(cfg.responseTimeout).to.eq(5555)
|
||||
expect(cfg.env.baz).to.eq('baz')
|
||||
|
||||
@@ -408,3 +408,18 @@ Please remove this option or add this as a component testing type property: comp
|
||||
https://on.cypress.io/migration-guide
|
||||
|
||||
`
|
||||
|
||||
exports['e2e config throws an error if experimentalSessionAndOrigin is set on the component level 1'] = `
|
||||
The component.experimentalSessionAndOrigin configuration option is not valid for component testing.
|
||||
|
||||
Please remove this option or add this as an e2e testing type property: e2e.experimentalSessionAndOrigin
|
||||
|
||||
{
|
||||
e2e: {
|
||||
experimentalSessionAndOrigin: '...',
|
||||
}
|
||||
}
|
||||
|
||||
https://on.cypress.io/migration-guide
|
||||
|
||||
`
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
module.exports = {
|
||||
component: {
|
||||
experimentalSessionAndOrigin: true,
|
||||
},
|
||||
}
|
||||
@@ -6,6 +6,7 @@
|
||||
"componentFolder": "src",
|
||||
"testFiles": "**/*.spec.{tsx,js}",
|
||||
"pluginsFile": "cypress/plugins/index.js",
|
||||
"experimentalSessionAndOrigin": true,
|
||||
"e2e": {
|
||||
"defaultCommandTimeout": 10000,
|
||||
"slowTestThreshold": 5000
|
||||
|
||||
@@ -15,6 +15,7 @@ module.exports = defineConfig({
|
||||
slowTestThreshold: 5000,
|
||||
baseUrl: 'http://localhost:3000',
|
||||
specPattern: 'cypress/e2e/**/*.spec.{tsx,js}',
|
||||
experimentalSessionAndOrigin: true,
|
||||
},
|
||||
component: {
|
||||
setupNodeEvents (on, config) {},
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
module.exports = {
|
||||
numTestsKeptInMemory: 0,
|
||||
video: false,
|
||||
e2e: {
|
||||
supportFile: false,
|
||||
experimentalSessionAndOrigin: true,
|
||||
},
|
||||
}
|
||||
@@ -1,5 +1,3 @@
|
||||
Cypress.config('experimentalSessionAndOrigin', true)
|
||||
|
||||
it('t1', () => {
|
||||
cy.session('blank_session', () => {})
|
||||
assert(true)
|
||||
@@ -1,5 +1,3 @@
|
||||
Cypress.config('experimentalSessionAndOrigin', true)
|
||||
|
||||
it('t1', () => {
|
||||
cy.session('user1', () => {
|
||||
window.localStorage.foo = 'val'
|
||||
@@ -1,5 +1,3 @@
|
||||
Cypress.config('experimentalSessionAndOrigin', true)
|
||||
|
||||
it('t1', () => {
|
||||
const setupFn = cy.stub().as('runSetup')
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
Cypress.config('experimentalSessionAndOrigin', true)
|
||||
|
||||
it('t1', () => {
|
||||
const setupFn = cy.stub().as('runSetup')
|
||||
const validateFn = cy.stub().returns(false).as('runValidation')
|
||||
@@ -1,5 +1,3 @@
|
||||
Cypress.config('experimentalSessionAndOrigin', true)
|
||||
|
||||
it('t1', () => {
|
||||
const setupFn = cy.stub().as('runSetup')
|
||||
const validateFn = cy.stub().as('runValidation')
|
||||
@@ -1,5 +1,3 @@
|
||||
Cypress.config('experimentalSessionAndOrigin', true)
|
||||
|
||||
const stub = Cypress.sinon.stub().callsFake(() => {
|
||||
// The validation for t3 will fail, causing the
|
||||
// session to be recreated (rather than load from saved)
|
||||
@@ -1,8 +1,6 @@
|
||||
let setupFn
|
||||
let validateFn
|
||||
|
||||
Cypress.config('experimentalSessionAndOrigin', true)
|
||||
|
||||
before(() => {
|
||||
setupFn = cy.stub().as('runSetup')
|
||||
validateFn = cy.stub().callsFake(() => {
|
||||
@@ -1,8 +1,6 @@
|
||||
let setupFn
|
||||
let validateFn
|
||||
|
||||
Cypress.config('experimentalSessionAndOrigin', true)
|
||||
|
||||
before(() => {
|
||||
setupFn = cy.stub().as('runSetup')
|
||||
validateFn = cy.stub().callsFake(() => {
|
||||
@@ -1,8 +1,6 @@
|
||||
let setupFn
|
||||
let validateFn
|
||||
|
||||
Cypress.config('experimentalSessionAndOrigin', true)
|
||||
|
||||
before(() => {
|
||||
setupFn = cy.stub().as('runSetup')
|
||||
validateFn = cy.stub().as('runValidation')
|
||||
@@ -170,6 +170,18 @@ describe('e2e config', () => {
|
||||
})
|
||||
})
|
||||
|
||||
it('throws an error if experimentalSessionAndOrigin is set on the component level', async function () {
|
||||
await Fixtures.scaffoldProject('invalid-root-level-config')
|
||||
|
||||
return systemTests.exec(this, {
|
||||
project: 'invalid-root-level-config',
|
||||
configFile: 'invalid-component-experimentalSessionAndOrigin-config.js',
|
||||
testingType: 'component',
|
||||
expectedExitCode: 1,
|
||||
snapshot: true,
|
||||
})
|
||||
})
|
||||
|
||||
it('throws an error if indexHtml is set on the root level', async function () {
|
||||
await Fixtures.scaffoldProject('invalid-root-level-config')
|
||||
|
||||
|
||||
Reference in New Issue
Block a user