Skip to content

WIP: refactoring launchpad & data context #18906

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

Closed
wants to merge 33 commits into from
Closed
Show file tree
Hide file tree
Changes from 32 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
3c362c4
app_data js -> ts
tgriesser Nov 10, 2021
9f58f2c
Test specific app dir, cleanup data pre/post test
tgriesser Nov 10, 2021
203fa25
setupE2E -> openE2E
tgriesser Nov 10, 2021
30ea1d2
prefix tasks with __internal
tgriesser Nov 10, 2021
8ee06f1
cleanup
tgriesser Nov 10, 2021
26a1be7
WIP on refactoring many things
tgriesser Nov 12, 2021
8bdbd1a
Merge branch 'unified-desktop-gui' into tgriesser/chore/e2e-data-clean
tgriesser Nov 12, 2021
16f7984
Merge branch 'tgriesser/chore/e2e-data-clean' into tgriesser/chore/e2…
tgriesser Nov 12, 2021
f6b3cdf
WIP
tgriesser Nov 12, 2021
0bb22f8
WIP
tgriesser Nov 13, 2021
7d23c06
Merge branch '10.0-release' into tgriesser/chore/e2e-data-clean
tgriesser Nov 17, 2021
55e6401
Merge branch '10.0-release' into tgriesser/chore/e2e-data-clean
tgriesser Nov 21, 2021
e83512f
Merge branch '10.0-release' into tgriesser/chore/e2e-data-clean
tgriesser Nov 21, 2021
bee5730
Merge branch 'tgriesser/chore/e2e-data-clean' into tgriesser/chore/e2…
tgriesser Nov 21, 2021
a046e9b
Merge branch '10.0-release' into tgriesser/chore/e2e-data-clean-refactor
tgriesser Nov 22, 2021
ae6dafb
Merge branch '10.0-release' into tgriesser/chore/e2e-data-clean-refactor
tgriesser Nov 23, 2021
9e96634
WIP after merge
tgriesser Nov 23, 2021
74fc1a1
Fix
tgriesser Nov 23, 2021
77e22a7
fix
tgriesser Nov 23, 2021
3d1b5e2
fix
tgriesser Nov 23, 2021
84c1664
fix
tgriesser Nov 23, 2021
2efc775
Merge branch '10.0-release' into tgriesser/chore/e2e-data-clean-refactor
tgriesser Nov 23, 2021
7f7c810
Fix
tgriesser Nov 23, 2021
95646ea
Fixing tests, adding immer
tgriesser Nov 23, 2021
bc7e37b
Fix types
tgriesser Nov 23, 2021
1bd9ffa
More fixes
tgriesser Nov 23, 2021
40d456c
Merge branch '10.0-release' into tgriesser/chore/e2e-data-clean-refactor
tgriesser Nov 29, 2021
c519e7d
WIP standardizing the data layer
tgriesser Nov 29, 2021
d79a5b7
Merge branch '10.0-release' into tgriesser/chore/e2e-data-clean-refactor
tgriesser Nov 29, 2021
c9750f3
wip before sync, not quite there yet
tgriesser Nov 29, 2021
b7d0a38
WIP
tgriesser Nov 30, 2021
3fe0c73
broken WIP
tgriesser Dec 2, 2021
951f391
everything is broken
tgriesser Dec 6, 2021
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
1 change: 1 addition & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ branches:
- develop
- windows-code-signing
- 10.0-release
- 10.0-release-fix-appveyor
- /win*/

# https://www.appveyor.com/docs/lang/nodejs-iojs/
Expand Down
8 changes: 4 additions & 4 deletions circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2524,7 +2524,7 @@ mac-workflow: &mac-workflow
- darwin-create-build-artifacts

workflows:
linux:
<<: *linux-workflow
mac:
<<: *mac-workflow
# linux:
# <<: *linux-workflow
# mac:
# <<: *mac-workflow
7 changes: 3 additions & 4 deletions cli/__snapshots__/cli_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,9 @@ exports['shows help for open --foo 1'] = `
-c, --config <config> sets configuration values. separate multiple
values with a comma. overrides any value in
cypress.config.{ts|js}.
-C, --config-file <config-file> path to JSON file where configuration values
-C, --config-file <config-file> path to script file where configuration values
are set. defaults to
"cypress.config.{ts|js}". pass "false" to
disable.
"cypress.config.{ts|js}".
-d, --detached [bool] runs Cypress application in detached mode
--e2e runs end to end tests
-e, --env <env> sets environment variables. separate
Expand Down Expand Up @@ -72,7 +71,7 @@ exports['shows help for run --foo 1'] = `
--ci-build-id <id> the unique identifier for a run on your CI provider. typically a "BUILD_ID" env var. this value is automatically detected for most CI providers
--component runs component tests
-c, --config <config> sets configuration values. separate multiple values with a comma. overrides any value in cypress.config.{ts|js}.
-C, --config-file <config-file> path to JSON file where configuration values are set. defaults to "cypress.config.{ts|js}". pass "false" to disable.
-C, --config-file <config-file> path to script file where configuration values are set. defaults to "cypress.config.{ts|js}".
--e2e runs end to end tests
-e, --env <env> sets environment variables. separate multiple values with a comma. overrides any value in cypress.config.{ts|js} or cypress.env.json
--group <name> a named group for recorded runs in the Cypress Dashboard
Expand Down
7 changes: 0 additions & 7 deletions cli/__snapshots__/run_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,6 @@ exports['exec run .processRunOptions passes --record option 1'] = [
"my record id"
]

exports['exec run .processRunOptions passes --config-file false option 1'] = [
"--run-project",
null,
"--config-file",
false
]

exports['exec run .processRunOptions defaults to e2e testingType 1'] = [
"--run-project",
null
Expand Down
85 changes: 63 additions & 22 deletions cli/lib/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ const descriptions = {
ciBuildId: 'the unique identifier for a run on your CI provider. typically a "BUILD_ID" env var. this value is automatically detected for most CI providers',
component: 'runs component tests',
config: 'sets configuration values. separate multiple values with a comma. overrides any value in cypress.config.{ts|js}.',
configFile: 'path to JSON file where configuration values are set. defaults to "cypress.config.{ts|js}". pass "false" to disable.',
configFile: 'path to script file where configuration values are set. defaults to "cypress.config.{ts|js}"',
detached: 'runs Cypress application in detached mode',
dev: 'runs cypress in development and bypasses binary check',
e2e: 'runs end to end tests',
Expand Down Expand Up @@ -270,14 +270,32 @@ const addCypressRunCommand = (program) => {
.option('--dev', text('dev'), coerceFalse)
}

const addCypressOpenCommand = (program) => {
return program
.command('open')
.usage('[options]')
.description('Opens Cypress in the interactive GUI.')
.option('-b, --browser <browser-path>', text('browser'))
.option('--component', text('component'))
.option('-c, --config <config>', text('config'))
.option('-C, --config-file <config-file>', text('configFile'))
.option('-d, --detached [bool]', text('detached'), coerceFalse)
.option('--e2e', text('e2e'))
.option('-e, --env <env>', text('env'))
.option('--global', text('global'))
.option('-p, --port <port>', text('port'))
.option('-P, --project <project-path>', text('project'))
.option('--dev', text('dev'), coerceFalse)
}

/**
* Casts known command line options for "cypress run" to their intended type.
* For example if the user passes "--port 5005" the ".port" property should be
* a number 5005 and not a string "5005".
*
* Returns a clone of the original object.
*/
const castCypressRunOptions = (opts) => {
const castCypressOptions = (opts) => {
// only properties that have type "string | false" in our TS definition
// require special handling, because CLI parsing takes care of purely
// boolean arguments
Expand All @@ -287,10 +305,6 @@ const castCypressRunOptions = (opts) => {
castOpts.port = coerceAnyStringToInt(opts.port)
}

if (_.has(opts, 'configFile')) {
castOpts.configFile = coerceFalseOrString(opts.configFile)
}

return castOpts
}

Expand Down Expand Up @@ -325,7 +339,48 @@ module.exports = {

debug('parsed options %o', options)

const casted = castCypressRunOptions(options)
const casted = castCypressOptions(options)

debug('casted options %o', casted)
resolve(casted)
})

debug('parsing args: %o', cliArgs)
program.parse(cliArgs)
})
},

/**
* Parses `cypress open` command line option array into an object
* with options that you can feed into cy.openModeSystemTest test calls
* @example
* const options = parseOpenCommand(['cypress', 'open', '--browser', 'chrome'])
* // options is {browser: 'chrome'}
*/
parseOpenCommand (args) {
return new Promise((resolve, reject) => {
if (!Array.isArray(args)) {
return reject(new Error('Expected array of arguments'))
}

// make a copy of the input arguments array
// and add placeholders where "node ..." would usually be
// also remove "cypress" keyword at the start if present
const cliArgs = args[0] === 'cypress' ? [...args.slice(1)] : [...args]

cliArgs.unshift(null, null)

debug('creating program parser')
const program = createProgram()

addCypressOpenCommand(program)
.action((...fnArgs) => {
debug('parsed Cypress open %o', fnArgs)
const options = parseVariableOpts(fnArgs, cliArgs)

debug('parsed options %o', options)

const casted = castCypressOptions(options)

debug('casted options %o', casted)
resolve(casted)
Expand Down Expand Up @@ -387,21 +442,7 @@ module.exports = {
showVersions(args)
})

program
.command('open')
.usage('[options]')
.description('Opens Cypress in the interactive GUI.')
.option('-b, --browser <browser-path>', text('browser'))
.option('--component', text('component'))
.option('-c, --config <config>', text('config'))
.option('-C, --config-file <config-file>', text('configFile'))
.option('-d, --detached [bool]', text('detached'), coerceFalse)
.option('--e2e', text('e2e'))
.option('-e, --env <env>', text('env'))
.option('--global', text('global'))
.option('-p, --port <port>', text('port'))
.option('-P, --project <project-path>', text('project'))
.option('--dev', text('dev'), coerceFalse)
addCypressOpenCommand(program)
.action((opts) => {
debug('opening Cypress')
require('./exec/open')
Expand Down
74 changes: 47 additions & 27 deletions cli/lib/exec/open.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,42 +4,62 @@ const spawn = require('./spawn')
const verify = require('../tasks/verify')
const { processTestingType } = require('./shared')

module.exports = {
start (options = {}) {
if (!util.isInstalledGlobally() && !options.global && !options.project) {
options.project = process.cwd()
}
/**
* Maps options collected by the CLI
* and forms list of CLI arguments to the server.
*
* Note: there is lightweight validation, with errors
* thrown synchronously.
*
* @returns {string[]} list of CLI arguments
*/
const processOpenOptions = (options = {}) => {
if (!util.isInstalledGlobally() && !options.global && !options.project) {
options.project = process.cwd()
}

const args = []
const args = []

if (options.config) {
args.push('--config', options.config)
}
if (options.config) {
args.push('--config', options.config)
}

if (options.configFile !== undefined) {
args.push('--config-file', options.configFile)
}
if (options.configFile !== undefined) {
args.push('--config-file', options.configFile)
}

if (options.browser) {
args.push('--browser', options.browser)
}
if (options.browser) {
args.push('--browser', options.browser)
}

if (options.env) {
args.push('--env', options.env)
}
if (options.env) {
args.push('--env', options.env)
}

if (options.port) {
args.push('--port', options.port)
}
if (options.port) {
args.push('--port', options.port)
}

if (options.project) {
args.push('--project', options.project)
}
if (options.project) {
args.push('--project', options.project)
}

if (options.global) {
args.push('--global', options.global)
}

args.push(...processTestingType(options))
args.push(...processTestingType(options))

debug('opening from options %j', options)
debug('command line arguments %j', args)
debug('opening from options %j', options)
debug('command line arguments %j', args)

return args
}

module.exports = {
processOpenOptions,
start (options = {}) {
const args = processOpenOptions(options)

function open () {
return spawn.start(args, {
Expand Down
42 changes: 0 additions & 42 deletions cli/test/lib/cypress_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,18 +53,6 @@ describe('cypress', function () {
expect(args).to.deep.eq({ config: JSON.stringify(config) })
})
})

it('passes configFile: false', () => {
const opts = {
configFile: false,
}

return cypress.open(opts)
.then(getStartArgs)
.then((args) => {
expect(args).to.deep.eq(opts)
})
})
})

context('.run fails to write results file', function () {
Expand Down Expand Up @@ -152,18 +140,6 @@ describe('cypress', function () {
return cypress.run().then(snapshot)
})

it('passes configFile: false', () => {
const opts = {
configFile: false,
}

return cypress.run(opts)
.then(getStartArgs)
.then((args) => {
expect(args).to.deep.eq(opts)
})
})

it('rejects if project is an empty string', () => {
return expect(cypress.run({ project: '' })).to.be.rejected
})
Expand Down Expand Up @@ -223,15 +199,6 @@ describe('cypress', function () {
})
})

it('coerces --config-file false to boolean', async () => {
const args = 'cypress run --config-file false'.split(' ')
const options = await cypress.cli.parseRunArguments(args)

expect(options).to.deep.equal({
configFile: false,
})
})

it('coerces --config-file cypress.config.js to string', async () => {
const args = 'cypress run --config-file cypress.config.js'.split(' ')
const options = await cypress.cli.parseRunArguments(args)
Expand All @@ -241,15 +208,6 @@ describe('cypress', function () {
})
})

it('parses config file false', async () => {
const args = 'cypress run --config-file false'.split(' ')
const options = await cypress.cli.parseRunArguments(args)

expect(options).to.deep.equal({
configFile: false,
})
})

it('parses config', async () => {
const args = 'cypress run --config baseUrl=localhost,video=true'.split(' ')
const options = await cypress.cli.parseRunArguments(args)
Expand Down
9 changes: 0 additions & 9 deletions cli/test/lib/exec/open_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,6 @@ describe('exec open', function () {
})
})

it('spawns with --config-file false', function () {
return open.start({ configFile: false })
.then(() => {
expect(spawn.start).to.be.calledWith(
['--config-file', false],
)
})
})

it('spawns with --config-file set', function () {
return open.start({ configFile: 'special-cypress.config.js' })
.then(() => {
Expand Down
17 changes: 0 additions & 17 deletions cli/test/lib/exec/run_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,6 @@ describe('exec run', function () {
snapshot(args)
})

it('passes --config-file false option', () => {
const args = run.processRunOptions({
configFile: false,
})

snapshot(args)
})

it('does not allow setting paradoxical --headed and --headless flags', () => {
os.platform.returns('linux')
process.exit.returns()
Expand Down Expand Up @@ -148,15 +140,6 @@ describe('exec run', function () {
})
})

it('spawns with --config-file false', function () {
return run.start({ configFile: false })
.then(() => {
expect(spawn.start).to.be.calledWith(
['--run-project', process.cwd(), '--config-file', false],
)
})
})

it('spawns with --config-file set', function () {
return run.start({ configFile: 'special-cypress.config.js' })
.then(() => {
Expand Down
Loading