Skip to content

Commit

Permalink
Merge branch 'develop' into matth/fix/issue-17627-hang-fix
Browse files Browse the repository at this point in the history
  • Loading branch information
mjhenkes authored Jul 29, 2022
2 parents 11058d3 + 85ee714 commit 68bb26a
Show file tree
Hide file tree
Showing 9 changed files with 15 additions and 252 deletions.
2 changes: 1 addition & 1 deletion browser-versions.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"chrome:beta": "104.0.5112.57",
"chrome:beta": "104.0.5112.65",
"chrome:stable": "103.0.5060.134"
}
183 changes: 0 additions & 183 deletions packages/server/lib/gui/events.ts

This file was deleted.

8 changes: 2 additions & 6 deletions packages/server/lib/modes/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,11 @@ export = (mode, options) => {
const loadingPromise = ctx.initializeMode()

if (mode === 'run') {
if (options.testingType === 'component') {
return require('./run-ct').run(options, loadingPromise)
}

// run must always be deterministic - if the user doesn't specify
// a testingType, we default to e2e
options.testingType = 'e2e'
options.testingType = options.testingType || 'e2e'

return require('./run-e2e').run(options, loadingPromise)
return require('./run').run(options, loadingPromise)
}

if (mode === 'interactive') {
Expand Down
23 changes: 8 additions & 15 deletions packages/server/lib/modes/interactive.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
import _ from 'lodash'
import os from 'os'
import { app, nativeImage as image } from 'electron'
// eslint-disable-next-line no-duplicate-imports
import type { WebContents } from 'electron'

import * as cyIcons from '@packages/icons'
import * as savedState from '../saved_state'
import menu from '../gui/menu'
import * as Windows from '../gui/windows'
import { makeGraphQLServer } from '@packages/graphql/src/makeGraphQLServer'
import { DataContext, globalPubSub, getCtx, clearCtx } from '@packages/data-context'
import type { LaunchArgs, PlatformName } from '@packages/types'
import { EventEmitter } from 'events'
import { globalPubSub, getCtx, clearCtx } from '@packages/data-context'

// eslint-disable-next-line no-duplicate-imports
import type { WebContents } from 'electron'
import type { LaunchArgs } from '@packages/types'

import debugLib from 'debug'
import Events from '../gui/events'

const debug = debugLib('cypress:server:interactive')

Expand Down Expand Up @@ -153,21 +154,13 @@ export = {
return Windows.open(projectRoot, port, this.getWindowArgs(state))
.then((win) => {
ctx?.actions.electron.setBrowserWindow(win)
Events.start({
...(options as LaunchArgs),
onFocusTests () {
// @ts-ignore
return app.focus({ steal: true }) || win.focus()
},
os: os.platform() as PlatformName,
}, new EventEmitter())

return win
})
})
},

async run (options, ctx: DataContext) {
async run (options: LaunchArgs, _loading: Promise<void>) {
const [, port] = await Promise.all([
app.whenReady(),
makeGraphQLServer(),
Expand Down
9 changes: 0 additions & 9 deletions packages/server/lib/modes/run-ct.ts

This file was deleted.

7 changes: 0 additions & 7 deletions packages/server/lib/modes/run-e2e.js

This file was deleted.

20 changes: 4 additions & 16 deletions packages/server/test/integration/cypress_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ const argsUtil = require(`../../lib/util/args`)
const { fs } = require(`../../lib/util/fs`)
const ciProvider = require(`../../lib/util/ci_provider`)
const settings = require(`../../lib/util/settings`)
const Events = require(`../../lib/gui/events`)
const Windows = require(`../../lib/gui/windows`)
const interactiveMode = require(`../../lib/modes/interactive`)
const runMode = require(`../../lib/modes/run`)
Expand Down Expand Up @@ -1641,7 +1640,6 @@ describe('lib/cypress', () => {
sinon.stub(electron.app, 'on').withArgs('ready').yieldsAsync()
sinon.stub(Windows, 'open').resolves(this.win)
sinon.stub(ServerE2E.prototype, 'startWebsockets')
sinon.spy(Events, 'start')
sinon.stub(electron.ipcMain, 'on')
})

Expand All @@ -1660,21 +1658,11 @@ describe('lib/cypress', () => {
})
})

it('passes options to Events.start', () => {
return cypress.start(['--port=2121', '--config=pageLoadTimeout=1000'])
.then(() => {
expect(Events.start).to.be.calledWithMatch({
config: {
pageLoadTimeout: 1000,
port: 2121,
},
})
})
})

it('passes filtered options to Project#open and sets cli config', async function () {
const open = sinon.stub(ServerE2E.prototype, 'open').resolves([])

sinon.stub(interactiveMode, 'ready')

process.env.CYPRESS_FILE_SERVER_FOLDER = 'foo'
process.env.CYPRESS_BASE_URL = 'http://localhost'
process.env.CYPRESS_port = '2222'
Expand All @@ -1688,7 +1676,7 @@ describe('lib/cypress', () => {
return user.set({ name: 'brian', authToken: 'auth-token-123' })
.then(() => ctx.lifecycleManager.getFullInitialConfig())
.then((json) => {
// this should be overriden by the env argument
// this should be overridden by the env argument
json.baseUrl = 'http://localhost:8080'

const { supportFile, specPattern, excludeSpecPattern, baseUrl, experimentalSessionAndOrigin, slowTestThreshold, ...rest } = json
Expand All @@ -1705,7 +1693,7 @@ describe('lib/cypress', () => {
'--env=baz=baz',
])
}).then(() => {
const options = Events.start.firstCall.args[0]
const options = interactiveMode.ready.firstCall.args[0]

return openProject.create(this.todosPath, { ...options, testingType: 'e2e' }, [])
}).then(() => {
Expand Down
14 changes: 0 additions & 14 deletions packages/server/test/unit/modes/interactive_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ const electron = require('electron')
const DataContext = require('@packages/data-context')
const savedState = require(`../../../lib/saved_state`)
const menu = require(`../../../lib/gui/menu`)
const Events = require(`../../../lib/gui/events`)
const Windows = require(`../../../lib/gui/windows`)
const interactiveMode = require(`../../../lib/modes/interactive`)

Expand Down Expand Up @@ -128,7 +127,6 @@ describe('gui/interactive', () => {
this.state = {}

sinon.stub(menu, 'set')
sinon.stub(Events, 'start')
sinon.stub(Windows, 'open').resolves(this.win)
sinon.stub(Windows, 'trackState')

Expand All @@ -137,18 +135,6 @@ describe('gui/interactive', () => {
sinon.stub(state, 'get').resolves(this.state)
})

it('calls Events.start with options, adding env, onFocusTests, and os', () => {
sinon.stub(os, 'platform').returns('someOs')
const opts = {}

return interactiveMode.ready(opts).then(() => {
expect(Events.start).to.be.called
expect(Events.start.lastCall.args[0].onFocusTests).to.be.a('function')

expect(Events.start.lastCall.args[0].os).to.equal('someOs')
})
})

it('calls menu.set', () => {
return interactiveMode.ready({}).then(() => {
expect(menu.set).to.be.calledOnce
Expand Down
1 change: 0 additions & 1 deletion packages/types/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ export interface LaunchArgs {
projectRoot: string // same as above
testingType: Cypress.TestingType
invokedFromCli: boolean
runAllSpecsInSameBrowserSession?: boolean
onError?: (error: Error) => void
os: PlatformName
exit?: boolean
Expand Down

0 comments on commit 68bb26a

Please sign in to comment.