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: pass list of browsers to plugins file #5068

Merged
merged 84 commits into from
Nov 19, 2019
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
84 commits
Select commit Hold shift + click to select a range
740294d
WIP: pass list of browsers to plugins file
bahmutov Aug 30, 2019
a97c94d
pass browsers to the plugins and use returned list
bahmutov Aug 30, 2019
20828ba
fix server unit tests
bahmutov Aug 30, 2019
6b42c47
Merge branch 'develop' into pass-list-of-browsers-to-config-5067
bahmutov Sep 10, 2019
79f5d31
Merge branch 'develop' into pass-list-of-browsers-to-config-5067
bahmutov Sep 10, 2019
ae8ddf9
Merge branch 'develop' into pass-list-of-browsers-to-config-5067
jennifer-shehane Oct 16, 2019
4eeeb82
Merge branch 'develop' into pass-list-of-browsers-to-config-5067
bahmutov Oct 18, 2019
84631c2
Merge branch 'develop' into pass-list-of-browsers-to-config-5067
bahmutov Oct 22, 2019
1a47629
Merge branch 'develop' into pass-list-of-browsers-to-config-5067
bahmutov Oct 22, 2019
7a8b48f
adding returned list of browsers validation
bahmutov Oct 22, 2019
8421600
Merge branch 'develop' into pass-list-of-browsers-to-config-5067
bahmutov Oct 23, 2019
fe616a7
Merge branch 'develop' into pass-list-of-browsers-to-config-5067
bahmutov Oct 23, 2019
9e37e63
Merge branch 'develop' into pass-list-of-browsers-to-config-5067
bahmutov Oct 25, 2019
ab9dbbd
Merge branch 'pass-list-of-browsers-to-config-5067' of github.com:cyp…
bahmutov Oct 25, 2019
e67eee9
Merge branch 'develop' into pass-list-of-browsers-to-config-5067
bahmutov Oct 30, 2019
531ff20
Merge branch 'develop' into pass-list-of-browsers-to-config-5067
bahmutov Nov 4, 2019
b758243
Merge branch 'pass-list-of-browsers-to-config-5067' of github.com:cyp…
bahmutov Nov 4, 2019
733e7a7
worked more on browser list validation
bahmutov Nov 5, 2019
9ff4a41
update logic to only check if passed browsers
bahmutov Nov 5, 2019
372534b
wip: updating unit tests
bahmutov Nov 5, 2019
fdd7bca
add more tests
bahmutov Nov 5, 2019
1982475
update integration tests
bahmutov Nov 6, 2019
6a6add6
add browsers list to the configuration spec
bahmutov Nov 6, 2019
a616d1b
update blacklist hosts display test
bahmutov Nov 6, 2019
f919abc
Merge branch 'develop' into pass-list-of-browsers-to-config-5067
bahmutov Nov 6, 2019
c714b0c
resolve browsers by default
bahmutov Nov 6, 2019
0bc418a
Merge branch 'pass-list-of-browsers-to-config-5067' of github.com:cyp…
bahmutov Nov 6, 2019
3d13637
do not set browsers as CLI by default
bahmutov Nov 6, 2019
8544c71
update code to not fail all tests when the list of browsers is the de…
bahmutov Nov 6, 2019
61c8501
Merge branch 'develop' into pass-list-of-browsers-to-config-5067
bahmutov Nov 7, 2019
5f41937
debug log:
bahmutov Nov 7, 2019
b8842ef
Merge branch 'pass-list-of-browsers-to-config-5067' of github.com:cyp…
bahmutov Nov 7, 2019
7cf45d7
detect browsers first when running project
bahmutov Nov 7, 2019
5f92b40
if passed browser, only search in the browsers resolved by the plugins
bahmutov Nov 7, 2019
7b93625
allow browser path to be any string
bahmutov Nov 7, 2019
fb7529e
Merge branch 'develop' into pass-list-of-browsers-to-config-5067
bahmutov Nov 7, 2019
6194d9d
update integration test
bahmutov Nov 7, 2019
6d97556
Merge branch 'pass-list-of-browsers-to-config-5067' of github.com:cyp…
bahmutov Nov 7, 2019
80e05fe
Merge branch 'develop' into pass-list-of-browsers-to-config-5067
bahmutov Nov 8, 2019
68fc292
Merge branch 'develop' into pass-list-of-browsers-to-config-5067
bahmutov Nov 8, 2019
258915c
add e2e test for filtering browsers in the plugins file
bahmutov Nov 8, 2019
0d4fbd7
Merge branch 'develop' into pass-list-of-browsers-to-config-5067
bahmutov Nov 12, 2019
1530374
allow browser major to be a number
bahmutov Nov 12, 2019
97470c9
parse majorVersion for detected browser
bahmutov Nov 12, 2019
057314d
Update packages/server/lib/browsers/utils.coffee
bahmutov Nov 12, 2019
fcabbf7
Update packages/server/lib/browsers/index.coffee
bahmutov Nov 12, 2019
ed73d38
Update packages/server/lib/browsers/index.coffee
bahmutov Nov 12, 2019
ff5d735
remove unnecessary TODO
bahmutov Nov 12, 2019
1ed65d5
convert major version for Electron browser
bahmutov Nov 12, 2019
f6ede4d
update Electron port in integration test
bahmutov Nov 12, 2019
21132ab
change config spec to expect a number
bahmutov Nov 12, 2019
e683e36
browsers values are collapsed by default
andrew-codes Nov 13, 2019
66b0493
use react-inspector for config viewer
andrew-codes Nov 13, 2019
c33a71a
Merge branch 'develop' into pass-list-of-browsers-to-config-5067
andrew-codes Nov 13, 2019
cbd798b
address PR feedback
andrew-codes Nov 14, 2019
987ba31
account for slight delay of rendering the config
andrew-codes Nov 14, 2019
f533faf
correct test assertion
andrew-codes Nov 14, 2019
a862822
additional PR feedback
andrew-codes Nov 14, 2019
1a44662
missing color on plugins legend item
andrew-codes Nov 14, 2019
d626d66
Merge branch 'develop' into pass-list-of-browsers-to-config-5067
andrew-codes Nov 14, 2019
e986396
Wrap config in curly braces & style updates
andrew-codes Nov 14, 2019
26908eb
use parseFloat
bahmutov Nov 15, 2019
ca76fb6
prevent jumping when mousing over values
andrew-codes Nov 15, 2019
97de1c6
Updated css so config doesn't jump around on hover or expand
jennifer-shehane Nov 15, 2019
0e50e1b
Merge remote-tracking branch 'origin/pass-list-of-browsers-to-config-…
jennifer-shehane Nov 15, 2019
bcebccf
minor tweaks
andrew-codes Nov 15, 2019
a91b935
add e2e test for catching invalid viewportWidth in cypress.json file
bahmutov Nov 15, 2019
0902c5c
validate config values returned from plugins, closes #5712
bahmutov Nov 15, 2019
d616cd3
Merge branch 'develop' into pass-list-of-browsers-to-config-5067
bahmutov Nov 18, 2019
07f9f75
Update packages/server/lib/browsers/index.coffee
brian-mann Nov 18, 2019
3cb2ae5
Update packages/server/lib/browsers/utils.coffee
brian-mann Nov 18, 2019
86f7ffc
Update packages/server/lib/browsers/index.coffee
brian-mann Nov 18, 2019
d260d7d
move browsers validation to regular flow
bahmutov Nov 18, 2019
073770e
remove using old config validation
bahmutov Nov 18, 2019
41d3712
add plugins e2e test that returns empty browsers list
bahmutov Nov 18, 2019
55bcf0c
add e2e test for invalid browser object returned from plugin
bahmutov Nov 18, 2019
4562ff1
Merge branch 'pass-list-of-browsers-to-config-5067' of github.com:cyp…
bahmutov Nov 18, 2019
47f733f
add data-driven unit tests for validating one browser object
bahmutov Nov 18, 2019
7e8cd82
update unit tests
bahmutov Nov 18, 2019
4b700e3
remove moved tests
bahmutov Nov 18, 2019
652b89f
update a few unit tests
bahmutov Nov 18, 2019
c5c53ef
update integration test
bahmutov Nov 18, 2019
19e01c5
Merge branch 'develop' into pass-list-of-browsers-to-config-5067
bahmutov Nov 18, 2019
ecb3a03
Merge branch 'develop' into pass-list-of-browsers-to-config-5067
bahmutov Nov 19, 2019
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
32 changes: 30 additions & 2 deletions packages/server/lib/config.coffee
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
_ = require("lodash")
R = require("ramda")
path = require("path")
Promise = require("bluebird")
deepDiff = require("return-deep-diff")
Expand Down Expand Up @@ -46,6 +47,7 @@ folders = toWords """
videosFolder
"""

# Public configuration properties, like "cypress.json" fields
configKeys = toWords """
animationDistanceThreshold fileServerFolder
baseUrl fixturesFolder
Expand All @@ -72,12 +74,18 @@ configKeys = toWords """
waitForAnimations
"""

# Deprecated and retired public configuration properties
breakingConfigKeys = toWords """
videoRecording
screenshotOnHeadlessFailure
trashAssetsBeforeHeadlessRuns
"""

# Internal configuration properties the user should be able to overwrite
systemConfigKeys = toWords """
browsers
"""

CONFIG_DEFAULTS = {
port: null
hosts: null
Expand Down Expand Up @@ -208,7 +216,8 @@ module.exports = {
getConfigKeys: -> configKeys

whitelist: (obj = {}) ->
_.pick(obj, configKeys.concat(breakingConfigKeys))
propertyNames = configKeys.concat(breakingConfigKeys).concat(systemConfigKeys)
_.pick(obj, propertyNames)

get: (projectRoot, options = {}) ->
Promise.all([
Expand Down Expand Up @@ -244,6 +253,7 @@ module.exports = {
resolved = {}

_.extend config, _.pick(options, "morgan", "isTextTerminal", "socketId", "report", "browsers")
debug("merged config with options, got %o", config)

_
.chain(@whitelist(options))
Expand Down Expand Up @@ -309,6 +319,9 @@ module.exports = {
## diff the overrides with cfg
## including nested objects (env)
diffs = deepDiff(cfg, overrides, true)
debug("config diffs %o", diffs)

userBrowserList = diffs && diffs.browsers && R.clone(diffs.browsers)
flotwig marked this conversation as resolved.
Show resolved Hide resolved

setResolvedOn = (resolvedObj, obj) ->
_.each obj, (val, key) ->
Expand All @@ -327,9 +340,24 @@ module.exports = {
## and change the resolved values of cfg
## to point to the plugin
setResolvedOn(cfg.resolved, diffs)
debug("resolved config object %o", cfg.resolved)

## merge cfg into overrides
_.defaultsDeep(diffs, cfg)
resolved = _.defaultsDeep(diffs, cfg)

## Take a special care with some system properties the
## user should be able to modify. For example, if the plugins file
## modifes detected browsers, the _.defaultsDeep merges it back
## and we need to use the user's value

# do not allow user to delete "browsers" list - otherwise how to run tests?
flotwig marked this conversation as resolved.
Show resolved Hide resolved
if Array.isArray(userBrowserList)
debug("using user supplied list of browsers %o", userBrowserList)
resolved.browsers = userBrowserList
flotwig marked this conversation as resolved.
Show resolved Hide resolved

debug("resolved config with defaults %o", resolved)

return resolved

resolveConfigValues: (config, defaults, resolved = {}) ->
## pick out only the keys found in configKeys
Expand Down
5 changes: 5 additions & 0 deletions packages/server/lib/plugins/child/run_plugins.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// this module is responsible for loading the plugins file
// and running the exported function to register event handlers
// and executing any tasks that the plugin registers
const _ = require('lodash')
const debug = require('debug')('cypress:server:plugins:child')
const Promise = require('bluebird')
Expand Down Expand Up @@ -146,6 +149,8 @@ module.exports = (ipc, pluginsFile) => {
}

ipc.on('load', (config) => {
debug('plugins load file "%s"', pluginsFile)
debug('passing config %o', config)
load(ipc, config, pluginsFile)
})

Expand Down
6 changes: 4 additions & 2 deletions packages/server/lib/project.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,11 @@ class Project extends EE
.then (cfg) =>
@_initPlugins(cfg, options)
.then (modifiedCfg) ->
debug("plugin config yielded:", modifiedCfg)
debug("plugin config yielded: %o", modifiedCfg)

return config.updateWithPluginValues(cfg, modifiedCfg)
updatedConfig = config.updateWithPluginValues(cfg, modifiedCfg)
debug("updated config: %o", modifiedCfg)
return updatedConfig
.then (cfg) =>
@server.open(cfg, @, options.onWarning)
.spread (port, warning) =>
Expand Down