Skip to content

Commit 7021a82

Browse files
Merge branch 'develop' into electron-34
2 parents 1e9c1ed + 97531b9 commit 7021a82

File tree

96 files changed

+1219
-272
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

96 files changed

+1219
-272
lines changed

.circleci/workflows.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
version: 2.1
22

33
chrome-stable-version: &chrome-stable-version "134.0.6998.88"
4-
chrome-beta-version: &chrome-beta-version "135.0.7049.3"
4+
chrome-beta-version: &chrome-beta-version "135.0.7049.17"
55
firefox-stable-version: &firefox-stable-version "135.0"
66

77
orbs:

cli/types/cypress.d.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3314,7 +3314,8 @@ declare namespace Cypress {
33143314
socketIoRoute: string
33153315
spec: Cypress['spec'] | null
33163316
specs: Array<Cypress['spec']>
3317-
protocolEnabled: boolean
3317+
isDefaultProtocolEnabled: boolean
3318+
isStudioProtocolEnabled: boolean
33183319
hideCommandLog: boolean
33193320
hideRunnerUi: boolean
33203321
}

packages/app/cypress/e2e/studio/helper.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1-
export function launchStudio ({ specName = 'spec.cy.js', createNewTest = false, cliArgs = [''] } = {}) {
1+
export function launchStudio ({ specName = 'spec.cy.js', createNewTest = false, cliArgs = [''], enableCloudStudio = false } = {}) {
22
cy.scaffoldProject('experimental-studio')
3-
cy.openProject('experimental-studio', cliArgs)
3+
cy.openProject('experimental-studio', cliArgs, {
4+
cloudStudio: enableCloudStudio,
5+
})
6+
47
cy.startAppServer('e2e')
58
cy.visitApp()
69
cy.specsPageIsVisible()

packages/app/cypress/e2e/studio/studio.cy.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,16 @@ describe('Cypress Studio', () => {
2121
})
2222
}
2323

24+
it('loads the cloud studio page', () => {
25+
launchStudio({ specName: 'spec.cy.js', enableCloudStudio: true })
26+
27+
cy.window().then((win) => {
28+
expect(win.Cypress.config('isDefaultProtocolEnabled')).to.be.false
29+
expect(win.Cypress.config('isStudioProtocolEnabled')).to.be.true
30+
expect(win.Cypress.state('isProtocolEnabled')).to.be.true
31+
})
32+
})
33+
2434
it('updates an existing test with an action', () => {
2535
launchStudio()
2636

packages/app/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
"@vitejs/plugin-legacy": "5.4.0",
5252
"@vitejs/plugin-vue": "5.0.4",
5353
"@vitejs/plugin-vue-jsx": "3.1.0",
54-
"@vueuse/core": "7.2.2",
54+
"@vueuse/core": "7.7.1",
5555
"ansi-to-html": "0.7.2",
5656
"bluebird": "3.5.3",
5757
"classnames": "2.3.1",

packages/app/src/runner/event-manager.ts

Lines changed: 56 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -281,18 +281,40 @@ export class EventManager {
281281
this.reporterBus.on('studio:init:test', (testId) => {
282282
this.studioStore.setTestId(testId)
283283

284-
studioInit()
284+
this.ws.emit('studio:init', (error) => {
285+
if (error) {
286+
// eslint-disable-next-line no-console
287+
console.error(error)
288+
}
289+
290+
studioInit()
291+
})
285292
})
286293

287294
this.reporterBus.on('studio:init:suite', (suiteId) => {
288295
this.studioStore.setSuiteId(suiteId)
289296

290-
studioInit()
297+
this.ws.emit('studio:init', (error) => {
298+
if (error) {
299+
// eslint-disable-next-line no-console
300+
console.error(error)
301+
}
302+
303+
studioInit()
304+
})
291305
})
292306

293307
this.reporterBus.on('studio:cancel', () => {
294-
this.studioStore.cancel()
295-
rerun()
308+
this.ws.emit('studio:destroy', (error) => {
309+
if (error) {
310+
// eslint-disable-next-line no-console
311+
console.error(error)
312+
}
313+
314+
this.studioStore.cancel()
315+
// Reloading for now. This is the easiest way to clear out the protocol code from the front end
316+
window.location.reload()
317+
})
296318
})
297319

298320
this.reporterBus.on('studio:remove:command', (commandId) => {
@@ -316,14 +338,31 @@ export class EventManager {
316338
if (err) {
317339
this.reporterBus.emit('test:set:state', this.studioStore.saveError(err), noop)
318340
} else {
319-
this.studioStore.saveSuccess()
341+
this.ws.emit('studio:destroy', (error) => {
342+
if (error) {
343+
// eslint-disable-next-line no-console
344+
console.error(error)
345+
}
346+
347+
this.studioStore.saveSuccess()
348+
// Reloading for now. This is the easiest way to clear out the protocol code from the front end
349+
window.location.reload()
350+
})
320351
}
321352
})
322353
})
323354

324355
this.localBus.on('studio:cancel', () => {
325-
this.studioStore.cancel()
326-
rerun()
356+
this.ws.emit('studio:destroy', (error) => {
357+
if (error) {
358+
// eslint-disable-next-line no-console
359+
console.error(error)
360+
}
361+
362+
this.studioStore.cancel()
363+
// Reloading for now. This is the easiest way to clear out the protocol code from the front end
364+
window.location.reload()
365+
})
327366
})
328367

329368
this.ws.on('aut:destroy:init', () => {
@@ -396,6 +435,14 @@ export class EventManager {
396435
// @ts-ignore
397436
window.Cypress = Cypress
398437

438+
this.studioStore.setup(config)
439+
440+
const isDefaultProtocolEnabled = Cypress.config('isDefaultProtocolEnabled')
441+
const isStudioProtocolEnabled = Cypress.config('isStudioProtocolEnabled')
442+
const isStudioInScope = this.studioStore.isActive || this.studioStore.isLoading
443+
444+
Cypress.state('isProtocolEnabled', isDefaultProtocolEnabled || (isStudioProtocolEnabled && isStudioInScope))
445+
399446
this._addListeners()
400447
}
401448

@@ -421,7 +468,7 @@ export class EventManager {
421468

422469
const hideCommandLog = Cypress.config('hideCommandLog')
423470

424-
this.studioStore.initialize(config)
471+
this.studioStore.initialize()
425472

426473
const runnables = Cypress.runner.normalizeAll(runState.tests, hideCommandLog, testFilter)
427474

@@ -466,7 +513,7 @@ export class EventManager {
466513
_addListeners () {
467514
addTelemetryListeners(Cypress)
468515

469-
if (Cypress.config('protocolEnabled')) {
516+
if (Cypress.state('isProtocolEnabled')) {
470517
addCaptureProtocolListeners(Cypress)
471518
}
472519

packages/app/src/store/studio-store.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ export const useStudioStore = defineStore('studioRecorder', {
185185
this.isFailed = true
186186
},
187187

188-
initialize (config) {
188+
setup (config) {
189189
const studio = this._getUrlParams()
190190

191191
if (studio.testId) {
@@ -203,12 +203,14 @@ export const useStudioStore = defineStore('studioRecorder', {
203203
if (this.testId || this.suiteId) {
204204
this.setAbsoluteFile(config.spec.absolute)
205205
this.startLoading()
206+
}
207+
},
206208

207-
if (this.suiteId) {
208-
getCypress().runner.setOnlySuiteId(this.suiteId)
209-
} else if (this.testId) {
210-
getCypress().runner.setOnlyTestId(this.testId)
211-
}
209+
initialize () {
210+
if (this.suiteId) {
211+
getCypress().runner.setOnlySuiteId(this.suiteId)
212+
} else if (this.testId) {
213+
getCypress().runner.setOnlyTestId(this.testId)
212214
}
213215
},
214216

packages/config/__snapshots__/index.spec.ts.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,8 @@ exports['config/src/index .getDefaultValues returns list of public config keys 1
104104
'socketId': null,
105105
'socketIoCookie': '__socket',
106106
'socketIoRoute': '/__socket',
107-
'protocolEnabled': false,
107+
'isDefaultProtocolEnabled': false,
108+
'isStudioProtocolEnabled': false,
108109
'hideCommandLog': false,
109110
'hideRunnerUi': false,
110111
}
@@ -195,7 +196,8 @@ exports['config/src/index .getDefaultValues returns list of public config keys f
195196
'socketId': null,
196197
'socketIoCookie': '__socket',
197198
'socketIoRoute': '/__socket',
198-
'protocolEnabled': false,
199+
'isDefaultProtocolEnabled': false,
200+
'isStudioProtocolEnabled': false,
199201
'hideCommandLog': false,
200202
'hideRunnerUi': false,
201203
}

packages/config/src/options.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -589,7 +589,12 @@ const runtimeOptions: Array<RuntimeConfigOption> = [
589589
validation: validate.isString,
590590
isInternal: true,
591591
}, {
592-
name: 'protocolEnabled',
592+
name: 'isDefaultProtocolEnabled',
593+
defaultValue: false,
594+
validation: validate.isBoolean,
595+
isInternal: true,
596+
}, {
597+
name: 'isStudioProtocolEnabled',
593598
defaultValue: false,
594599
validation: validate.isBoolean,
595600
isInternal: true,

packages/data-context/src/sources/HtmlDataSource.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ export class HtmlDataSource {
5656
'reporterUrl',
5757
'namespace',
5858
'socketIoRoute',
59-
'protocolEnabled',
59+
'isDefaultProtocolEnabled',
60+
'isStudioProtocolEnabled',
6061
'hideCommandLog',
6162
'hideRunnerUi',
6263
]

packages/driver/cypress/e2e/commands/actions/check.cy.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -632,7 +632,8 @@ describe('src/cy/commands/actions/check', () => {
632632
})
633633
})
634634

635-
it('can turn off logging when protocol is disabled', { protocolEnabled: false }, function () {
635+
it('can turn off logging when protocol is disabled', function () {
636+
cy.state('isProtocolEnabled', false)
636637
cy.on('_log:added', (attrs, log) => {
637638
this.hiddenLog = log
638639
})
@@ -647,7 +648,8 @@ describe('src/cy/commands/actions/check', () => {
647648
})
648649
})
649650

650-
it('can send hidden log when protocol is enabled', { protocolEnabled: true }, function () {
651+
it('can send hidden log when protocol is enabled', function () {
652+
cy.state('isProtocolEnabled', true)
651653
cy.on('_log:added', (attrs, log) => {
652654
this.hiddenLog = log
653655
})
@@ -1294,7 +1296,8 @@ describe('src/cy/commands/actions/check', () => {
12941296
})
12951297
})
12961298

1297-
it('can turn off logging when protocol is disabled', { protocolEnabled: false }, function () {
1299+
it('can turn off logging when protocol is disabled', function () {
1300+
cy.state('isProtocolEnabled', false)
12981301
cy.on('_log:added', (attrs, log) => {
12991302
this.hiddenLog = log
13001303
})
@@ -1309,7 +1312,8 @@ describe('src/cy/commands/actions/check', () => {
13091312
})
13101313
})
13111314

1312-
it('can send hidden log when protocol is enabled', { protocolEnabled: true }, function () {
1315+
it('can send hidden log when protocol is enabled', function () {
1316+
cy.state('isProtocolEnabled', true)
13131317
cy.on('_log:added', (attrs, log) => {
13141318
this.hiddenLog = log
13151319
})

packages/driver/cypress/e2e/commands/actions/clear.cy.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,8 @@ describe('src/cy/commands/actions/type - #clear', () => {
493493
})
494494
})
495495

496-
it('can turn off logging when protocol is disabled', { protocolEnabled: false }, function () {
496+
it('can turn off logging when protocol is disabled', function () {
497+
cy.state('isProtocolEnabled', false)
497498
cy.on('_log:added', (attrs, log) => {
498499
this.hiddenLog = log
499500
})
@@ -507,7 +508,8 @@ describe('src/cy/commands/actions/type - #clear', () => {
507508
})
508509
})
509510

510-
it('can send hidden log when protocol is enabled', { protocolEnabled: true }, function () {
511+
it('can send hidden log when protocol is enabled', function () {
512+
cy.state('isProtocolEnabled', true)
511513
cy.on('_log:added', (attrs, log) => {
512514
this.hiddenLog = log
513515
})

packages/driver/cypress/e2e/commands/actions/click.cy.ts

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2648,7 +2648,8 @@ describe('src/cy/commands/actions/click', () => {
26482648
})
26492649
})
26502650

2651-
it('can turn off logging when protocol is disabled', { protocolEnabled: false }, function () {
2651+
it('can turn off logging when protocol is disabled', function () {
2652+
cy.state('isProtocolEnabled', false)
26522653
cy.on('_log:added', (attrs, log) => {
26532654
this.hiddenLog = log
26542655
})
@@ -2663,7 +2664,8 @@ describe('src/cy/commands/actions/click', () => {
26632664
})
26642665
})
26652666

2666-
it('can send hidden log when protocol is enabled', { protocolEnabled: true }, function () {
2667+
it('can send hidden log when protocol is enabled', function () {
2668+
cy.state('isProtocolEnabled', true)
26672669
cy.on('_log:added', (attrs, log) => {
26682670
this.hiddenLog = log
26692671
})
@@ -3557,7 +3559,8 @@ describe('src/cy/commands/actions/click', () => {
35573559
})
35583560
})
35593561

3560-
it('can turn off logging when protocol is disabled', { protocolEnabled: false }, function () {
3562+
it('can turn off logging when protocol is disabled', function () {
3563+
cy.state('isProtocolEnabled', false)
35613564
cy.on('_log:added', (attrs, log) => {
35623565
this.hiddenLog = log
35633566
})
@@ -3572,7 +3575,8 @@ describe('src/cy/commands/actions/click', () => {
35723575
})
35733576
})
35743577

3575-
it('can send hidden log when protocol is enabled', { protocolEnabled: true }, function () {
3578+
it('can send hidden log when protocol is enabled', function () {
3579+
cy.state('isProtocolEnabled', true)
35763580
cy.on('_log:added', (attrs, log) => {
35773581
this.hiddenLog = log
35783582
})
@@ -3993,7 +3997,8 @@ describe('src/cy/commands/actions/click', () => {
39933997
})
39943998
})
39953999

3996-
it('can turn off logging when protocol is disabled', { protocolEnabled: false }, function () {
4000+
it('can turn off logging when protocol is disabled', function () {
4001+
cy.state('isProtocolEnabled', false)
39974002
cy.on('_log:added', (attrs, log) => {
39984003
this.hiddenLog = log
39994004
})
@@ -4008,7 +4013,8 @@ describe('src/cy/commands/actions/click', () => {
40084013
})
40094014
})
40104015

4011-
it('can send hidden log when protocol is enabled', { protocolEnabled: true }, function () {
4016+
it('can send hidden log when protocol is enabled', function () {
4017+
cy.state('isProtocolEnabled', true)
40124018
cy.on('_log:added', (attrs, log) => {
40134019
this.hiddenLog = log
40144020
})

0 commit comments

Comments
 (0)