Skip to content

Commit

Permalink
Rename uses of term 'whitelist' (#7782)
Browse files Browse the repository at this point in the history
* Rename non-user facing instances of whitelist

* Rename server option 'whitelist' to 'ignore'

* Update use of whitelist with server to throw instead of warn

* Rename Cypress.Cookies.defaults 'whitelist' option to 'preserve'

* fix circle yml parameter parsing consistent

* compose cloning an external repo and switching to the NEXT_DEV_VERSION branch consistently

* add cypress org to repo parameter

* cd into the right dir before switching branches

* one line git checkout

* simplify passing repo

* cd into the right dir

* clone into the right dir

* oh my cd 101

* replace kitchen sink strings for 5.0.0

Co-authored-by: Brian Mann <[email protected]>
  • Loading branch information
jennifer-shehane and brian-mann authored Jun 30, 2020
1 parent e767bcf commit 639df99
Show file tree
Hide file tree
Showing 28 changed files with 306 additions and 356 deletions.
138 changes: 71 additions & 67 deletions circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,14 @@ commands:
- run:
name: Install latest Google Chrome (stable)
command: |
if [ << parameters.browser >> == "chrome" ]; then
if [ <<parameters.browser>> == "chrome" ]; then
echo "**** Running Chrome tests. Installing latest stable version of Google Chrome. ****"
apt-get update
apt-get install google-chrome-stable -y
echo "**** Location of Google Chrome Installation: "`which google-chrome`" ****"
echo "**** Google Chrome Version: "`google-chrome --version`" ****"
else
echo "**** Not updating Chrome. Running tests in '<< parameters.browser >>' ****"
echo "**** Not updating Chrome. Running tests in '<<parameters.browser>>' ****"
fi
run-driver-integration-tests:
Expand All @@ -105,7 +105,7 @@ commands:
if [[ -v PACKAGES_RECORD_KEY ]]; then
# internal PR
CYPRESS_RECORD_KEY=$PACKAGES_RECORD_KEY \
yarn cypress:run --record --parallel --group 5x-driver-<< parameters.browser >> --browser << parameters.browser >>
yarn cypress:run --record --parallel --group 5x-driver-<<parameters.browser>> --browser <<parameters.browser>>
else
# external PR
TESTFILES=$(circleci tests glob "cypress/integration/**/*_spec.*" | circleci tests split --total=$CIRCLE_NODE_TOTAL)
Expand All @@ -114,7 +114,7 @@ commands:
if [[ -z "$TESTFILES" ]]; then
echo "Empty list of test files"
fi
yarn cypress:run --browser << parameters.browser >> --spec $TESTFILES
yarn cypress:run --browser <<parameters.browser>> --spec $TESTFILES
fi
working_directory: packages/driver
- verify-mocha-results
Expand All @@ -136,7 +136,7 @@ commands:
command: |
CYPRESS_KONFIG_ENV=production \
CYPRESS_RECORD_KEY=$PACKAGES_RECORD_KEY \
yarn workspace @packages/runner cypress:run --record --parallel --group runner-integration-<< parameters.browser >> --browser <<parameters.browser>>
yarn workspace @packages/runner cypress:run --record --parallel --group runner-integration-<<parameters.browser>> --browser <<parameters.browser>>
- store_test_results:
path: /tmp/cypress
- store_artifacts:
Expand All @@ -156,7 +156,7 @@ commands:
- attach_workspace:
at: ~/
- run:
command: yarn workspace @packages/server test ./test/e2e/<< parameters.chunk >>*spec* --browser << parameters.browser >>
command: yarn workspace @packages/server test ./test/e2e/<<parameters.chunk>>*spec* --browser <<parameters.browser>>
- verify-mocha-results
- store_test_results:
path: /tmp/cypress
Expand Down Expand Up @@ -194,15 +194,30 @@ commands:
## by default, assert that at least 1 test ran
default: 0
steps:
- run: yarn verify:mocha:results << parameters.expectedResultCount >>
- run: yarn verify:mocha:results <<parameters.expectedResultCount>>

clone-repo-and-checkout-release-branch:
description: |
Clones an external repo and then checks out the branch that matches NEXT_DEV_VERSION otherwise uses 'master' branch.
parameters:
repo:
description: "Name of the github repo to clone like: cypress-example-kitchensink"
type: string
steps:
- attach_workspace:
at: ~/
- run:
name: "Cloning test project: <<parameters.repo>>"
command: |
git clone --depth 1 --no-single-branch https://github.com/cypress-io/<<parameters.repo>>.git /tmp/<<parameters.repo>>
cd /tmp/<<parameters.repo>> && (git checkout $NEXT_DEV_VERSION || true)
test-binary-against-repo:
description: |
Takes the built binary and NPM package, clones given example repo
and runs the new version of Cypress against it.
parameters:
repo:
description: Name of the repo like "cypress-example-kitchensink"
description: "Name of the github repo to clone like: cypress-example-kitchensink"
type: string
browser:
description: Name of the browser to use, like "electron", "chrome", "firefox"
Expand Down Expand Up @@ -232,18 +247,17 @@ commands:
# make sure the binary and NPM package files are present
- run: ls -l
- run: ls -l cypress.zip cypress.tgz
- run:
name: Cloning project <<parameters.repo>>
command: git clone --depth 1 https://github.com/cypress-io/<<parameters.repo>>.git /tmp/<<parameters.repo>>
- clone-repo-and-checkout-release-branch:
repo: <<parameters.repo>>
- when:
condition: << parameters.pull_request_id >>
condition: <<parameters.pull_request_id>>
steps:
- run:
name: Check out PR << parameters.pull_request_id >>
name: Check out PR <<parameters.pull_request_id>>
working_directory: /tmp/<<parameters.repo>>
command: |
git fetch origin pull/<< parameters.pull_request_id >>/head:pr-<< parameters.pull_request_id >>
git checkout pr-<< parameters.pull_request_id >>
git fetch origin pull/<<parameters.pull_request_id>>/head:pr-<<parameters.pull_request_id>>
git checkout pr-<<parameters.pull_request_id>>
git log -n 2
- run:
command: npm install
Expand All @@ -266,42 +280,42 @@ commands:
command: npm start --if-present
background: true
- when:
condition: << parameters.folder >>
condition: <<parameters.folder>>
steps:
- when:
condition: << parameters.browser >>
condition: <<parameters.browser>>
steps:
- run:
name: Run tests using browser "<< parameters.browser >>"
working_directory: /tmp/<<parameters.repo>>/<< parameters.folder >>
name: Run tests using browser "<<parameters.browser>>"
working_directory: /tmp/<<parameters.repo>>/<<parameters.folder>>
command: |
<<parameters.command>> -- --browser <<parameters.browser>>
- unless:
condition: << parameters.browser >>
condition: <<parameters.browser>>
steps:
- run:
name: Run tests using command
working_directory: /tmp/<<parameters.repo>>/<< parameters.folder >>
working_directory: /tmp/<<parameters.repo>>/<<parameters.folder>>
command: <<parameters.command>>

- store_artifacts:
name: screenshots
path: /tmp/<<parameters.repo>>/<< parameters.folder >>/cypress/screenshots
path: /tmp/<<parameters.repo>>/<<parameters.folder>>/cypress/screenshots
- store_artifacts:
name: videos
path: /tmp/<<parameters.repo>>/<< parameters.folder >>/cypress/videos
path: /tmp/<<parameters.repo>>/<<parameters.folder>>/cypress/videos
- unless:
condition: << parameters.folder >>
condition: <<parameters.folder>>
steps:
- when:
condition: << parameters.browser >>
condition: <<parameters.browser>>
steps:
- run:
name: Run tests using browser "<< parameters.browser >>"
name: Run tests using browser "<<parameters.browser>>"
working_directory: /tmp/<<parameters.repo>>
command: <<parameters.command>> -- --browser <<parameters.browser>>
- unless:
condition: << parameters.browser >>
condition: <<parameters.browser>>
steps:
- run:
name: Run tests using command
Expand Down Expand Up @@ -904,45 +918,39 @@ jobs:
test-kitchensink:
<<: *defaults
steps:
- attach_workspace:
at: ~/
- run:
name: Cloning test project
command: git clone https://github.com/cypress-io/cypress-example-kitchensink.git /tmp/repo
- clone-repo-and-checkout-release-branch:
repo: cypress-example-kitchensink
- run:
name: Install prod dependencies
command: yarn --production
working_directory: /tmp/repo
working_directory: /tmp/cypress-example-kitchensink
- run:
name: Example server
command: yarn start
working_directory: /tmp/repo
working_directory: /tmp/cypress-example-kitchensink
background: true
- run:
name: Run Kitchensink example project
command: yarn cypress:run --project /tmp/repo
command: yarn cypress:run --project /tmp/cypress-example-kitchensink
- store_artifacts:
path: /tmp/repo/cypress/screenshots
path: /tmp/cypress-example-kitchensink/cypress/screenshots
- store_artifacts:
path: /tmp/repo/cypress/videos
path: /tmp/cypress-example-kitchensink/cypress/videos
- store-npm-logs

"test-kitchensink-against-staging":
<<: *defaults
steps:
- attach_workspace:
at: ~/
- run:
name: Cloning test project
command: git clone https://github.com/cypress-io/cypress-example-kitchensink.git /tmp/repo
- clone-repo-and-checkout-release-branch:
repo: cypress-example-kitchensink
- run:
name: Install prod dependencies
command: yarn --production
working_directory: /tmp/repo
working_directory: /tmp/cypress-example-kitchensink
- run:
name: Example server
command: yarn start
working_directory: /tmp/repo
working_directory: /tmp/cypress-example-kitchensink
background: true
- run:
name: Run Kitchensink example project
Expand All @@ -951,24 +959,21 @@ jobs:
CYPRESS_RECORD_KEY=$TEST_KITCHENSINK_RECORD_KEY \
CYPRESS_INTERNAL_ENV=staging \
CYPRESS_video=false \
yarn cypress:run --project /tmp/repo --record
yarn cypress:run --project /tmp/cypress-example-kitchensink --record
- store-npm-logs

"test-against-staging":
<<: *defaults
steps:
- attach_workspace:
at: ~/
- run:
name: Cloning test project
command: git clone https://github.com/cypress-io/cypress-test-tiny.git /tmp/repo
- clone-repo-and-checkout-release-branch:
repo: cypress-test-tiny
- run:
name: Run test project
command: |
CYPRESS_PROJECT_ID=$TEST_TINY_PROJECT_ID \
CYPRESS_RECORD_KEY=$TEST_TINY_RECORD_KEY \
CYPRESS_INTERNAL_ENV=staging \
yarn cypress:run --project /tmp/repo --record
yarn cypress:run --project /tmp/cypress-example-kitchensink --record
- store-npm-logs

build-npm-package:
Expand Down Expand Up @@ -1164,16 +1169,16 @@ jobs:
# make sure we have cypress.zip received
- run: ls -l
- run: ls -l cypress.zip cypress.tgz
- run: mkdir << parameters.wd >>
- run: mkdir <<parameters.wd>>
- run: node --version
- run: npm --version
- run:
name: Create new NPM package ⚗️
working_directory: << parameters.wd >>
working_directory: <<parameters.wd>>
command: npm init -y
- run:
name: Install dependencies 📦
working_directory: << parameters.wd >>
working_directory: <<parameters.wd>>
environment:
CYPRESS_INSTALL_BINARY: /root/cypress/cypress.zip
# let's install Cypress, Jest and any other package that might conflict
Expand All @@ -1183,7 +1188,7 @@ jobs:
typescript jest @types/jest enzyme @types/enzyme
- run:
name: Test types clash ⚔️
working_directory: << parameters.wd >>
working_directory: <<parameters.wd>>
command: |
echo "console.log('hello world')" > hello.ts
npx tsc hello.ts --noEmit
Expand All @@ -1207,16 +1212,16 @@ jobs:
# make sure we have cypress.zip received
- run: ls -l
- run: ls -l cypress.zip cypress.tgz
- run: mkdir << parameters.wd >>
- run: mkdir <<parameters.wd>>
- run: node --version
- run: npm --version
- run:
name: Create new NPM package ⚗️
working_directory: << parameters.wd >>
working_directory: <<parameters.wd>>
command: npm init -y
- run:
name: Install dependencies 📦
working_directory: << parameters.wd >>
working_directory: <<parameters.wd>>
environment:
CYPRESS_INSTALL_BINARY: /root/cypress/cypress.zip
# let's install Cypress, Jest and any other package that might conflict
Expand All @@ -1226,7 +1231,7 @@ jobs:
typescript jest @types/jest enzyme @types/enzyme
- run:
name: Scaffold and test examples 🏗
working_directory: << parameters.wd >>
working_directory: <<parameters.wd>>
environment:
CYPRESS_INTERNAL_FORCE_SCAFFOLD: "1"
command: |
Expand All @@ -1250,27 +1255,27 @@ jobs:
# make sure we have cypress.zip received
- run: ls -l
- run: ls -l cypress.zip cypress.tgz
- run: mkdir << parameters.wd >>
- run: mkdir <<parameters.wd>>
- run: node --version
- run: npm --version
- run:
name: Create new NPM package ⚗️
working_directory: << parameters.wd >>
working_directory: <<parameters.wd>>
command: npm init -y
- run:
name: Install dependencies 📦
working_directory: << parameters.wd >>
working_directory: <<parameters.wd>>
environment:
CYPRESS_INSTALL_BINARY: /root/cypress/cypress.zip
command: |
npm install /root/cypress/cypress.tgz typescript
- run:
name: Scaffold full TypeScript project 🏗
working_directory: << parameters.wd >>
working_directory: <<parameters.wd>>
command: npx @bahmutov/cly@1 init --typescript
- run:
name: Run project tests 🗳
working_directory: << parameters.wd >>
working_directory: <<parameters.wd>>
command: npx cypress run

# install NPM + binary zip and run against staging API
Expand All @@ -1282,9 +1287,8 @@ jobs:
- run: ls -l
# make sure we have the binary and NPM package
- run: ls -l cypress.zip cypress.tgz
- run:
name: Cloning test project
command: git clone https://github.com/cypress-io/cypress-test-tiny.git /tmp/cypress-test-tiny
- clone-repo-and-checkout-release-branch:
repo: cypress-test-tiny
- run:
name: Install Cypress
working_directory: /tmp/cypress-test-tiny
Expand Down
6 changes: 3 additions & 3 deletions cli/types/cypress.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2130,7 +2130,7 @@ declare namespace Cypress {
type Agent<T extends sinon.SinonSpy> = SinonSpyAgent<T> & T

interface CookieDefaults {
whitelist: string | string[] | RegExp | ((cookie: any) => boolean)
preserve: string | string[] | RegExp | ((cookie: any) => boolean)
}

interface Failable {
Expand Down Expand Up @@ -2616,7 +2616,7 @@ declare namespace Cypress {
enable: boolean
force404: boolean
urlMatchingOptions: object
whitelist(xhr: Request): void
ignore(xhr: Request): void
onAnyRequest(route: RouteOptions, proxy: any): void
onAnyResponse(route: RouteOptions, proxy: any): void
onAnyAbort(route: RouteOptions, proxy: any): void
Expand Down Expand Up @@ -4806,7 +4806,7 @@ declare namespace Cypress {

interface Server extends RouteOptions {
enable: boolean
whitelist: (xhr: any) => boolean
ignore: (xhr: any) => boolean
}

interface Viewport {
Expand Down
2 changes: 1 addition & 1 deletion cli/types/tests/kitchen-sink.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ cy.visit('https://www.acme.com/', {

const serverOptions: Partial<Cypress.ServerOptions> = {
delay: 100,
whitelist: () => true
ignore: () => true
}

cy.server(serverOptions)
Expand Down
Loading

0 comments on commit 639df99

Please sign in to comment.