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

build(deps-dev): update cypress to 5.5.0, improvements for running locally #11603

Merged
merged 8 commits into from
Nov 10, 2020
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
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
18 changes: 11 additions & 7 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -624,32 +624,36 @@ We use [Cypress](https://www.cypress.io/) for integration tests. Tests can be ru

```bash
export SUPERSET_CONFIG=tests.superset_test_config
export SUPERSET_TESTENV=true
export ENABLE_REACT_CRUD_VIEWS=true
export CYPRESS_BASE_URL="http://localhost:8081"
Copy link
Member

@eschutho eschutho Nov 6, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

one piece of feedback that Harrison gave on this, is that this export CYPRESS_BASE_URL needs to be run in the same shell window as the cypress command. Should we move this line down, or else put it on the same line, such as CYPRESS_BASE_URL="http://localhost:8081" npm run cypress-run-chrome

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't export effectively does that for the whole bash session?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but if you open a new tab, window, or pane, it will create a new a new session.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@eschutho true, but the same holds for the other env vars. tox, while a pain, does abstract all of the env vars away from the user.

superset db upgrade
superset init
superset load_test_users
superset load_examples
superset load_examples --load-test-data
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to drop database before? It can be done with modification of cli.py

@with_appcontext
def create_db() -> None:
    """Resets database"""
    db.create_all()


@superset.command()
@with_appcontext
@click.confirmation_option(prompt="Are you sure you want to drop the db?")
def drop_db() -> None:
    """Removes database"""
    db.drop_all()

And then executed:

superset drop_db --yes
superset create_db

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@adam-stasiak definitely see the value in having a drop db (or at least a drop table) function prior to running tests, but I wouldn't necessarily make it mandatory.

superset init
superset run --port 8081
```

Run Cypress tests:

```bash
cd superset-frontend
npm run build
npm run build-instrumented

cd cypress-base
npm install
npm run cypress run

# run tests via headless Chrome browser (requires Chrome 64+)
npm run cypress-run-chrome

# run tests from a specific file
npm run cypress run -- --spec cypress/integration/explore/link.test.js
npm run cypress-run-chrome -- --spec cypress/integration/explore/link.test.js

# run specific file with video capture
npm run cypress run -- --spec cypress/integration/dashboard/index.test.js --config video=true
npm run cypress-run-chrome -- --spec cypress/integration/dashboard/index.test.js --config video=true

# to open the cypress ui
npm run cypress open
npm run cypress-debug

# to point cypress to a url other than the default (http://localhost:8088) set the environment variable before running the script
# e.g., CYPRESS_BASE_URL="http://localhost:9000"
Expand Down
3 changes: 2 additions & 1 deletion superset-frontend/cypress-base/cypress.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"baseUrl": "http://localhost:8088",
"chromeWebSecurity": false,
"defaultCommandTimeout": 5000,
"numTestsKeptInMemory": 0,
"experimentalFetchPolyfill": true,
"requestTimeout": 10000,
"ignoreTestFiles": [
Expand All @@ -13,7 +14,7 @@
"viewportHeight": 1024,
"projectId": "ukwxzo",
"retries": {
"runMode": 2,
"runMode": 1,
"openMode": 0
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,7 @@ describe('Dashboard edit mode', () => {
});

cy.get('[data-test="dashboard-builder-component-pane-tabs-navigation"]')
.within(() => {
cy.get('.ant-tabs-tab').last();
})
.find('.ant-tabs-tab').last()
.click();

// find box plot is available from list
Expand Down
66 changes: 32 additions & 34 deletions superset-frontend/cypress-base/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion superset-frontend/cypress-base/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"description": "run cypress against superset",
"scripts": {
"cypress": "cypress",
"cypress-run-chrome": "cypress run --browser chrome --headless",
"cypress-debug": "cypress open --config watchForFileChanges=true"
},
"author": "Apcahe",
Expand All @@ -14,7 +15,7 @@
"shortid": "^2.2.15"
},
"devDependencies": {
"cypress": "5.0.0",
"cypress": "^5.5.0",
"eslint-plugin-cypress": "^2.11.1"
}
}
9 changes: 6 additions & 3 deletions superset-frontend/cypress_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@ echo "[completed js build steps]"
cd cypress-base
time npm ci
export CYPRESS_BASE_URL="http://localhost:${PORT}"
CYPRESS_PATH='cypress/integration/'${1}'/*'
time npm run cypress run -- --spec "$CYPRESS_PATH" --record false --config video=false

if [ -n "$1" ]; then
CYPRESS_PATH='cypress/integration/'${1}'/*'
time npm run cypress-run-chrome -- --spec "$CYPRESS_PATH" --record false --config video=false || true
else
time npm run cypress-run-chrome -- --record false --config video=false || true
fi
kill %1
63 changes: 44 additions & 19 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
# Remember to start celery workers to run celery tests, e.g.
# celery worker --app=superset.tasks.celery_app:app -Ofair -c 2
[testenv]
basepython = python3.8
ignore_basepython_conflict = true
commands =
superset db upgrade
superset init
Expand All @@ -44,56 +46,79 @@ setenv =
# make sure that directory is accessible by docker
hive: UPLOAD_FOLDER = /tmp/.superset/app/static/uploads/
usedevelop = true
whitelist_externals =
allowlist_externals =
npm
pkill

[testenv:cypress-dashboard]
[testenv:cypress]
setenv =
PYTHONPATH = {toxinidir}
SUPERSET_TESTENV = true
SUPERSET_CONFIG = tests.superset_test_config
SUPERSET_HOME = {envtmpdir}
ENABLE_REACT_CRUD_VIEWS = true
commands =
npm install -g npm@'>=6.5.0'
pip install -e {toxinidir}/
{toxinidir}/superset-frontend/cypress_build.sh dashboard
deps =
-rrequirements/testing.txt
{toxinidir}/superset-frontend/cypress_build.sh
commands_post =
pkill -if "python {envbindir}/flask"
mistercrunch marked this conversation as resolved.
Show resolved Hide resolved

[testenv:cypress-dashboard]
mistercrunch marked this conversation as resolved.
Show resolved Hide resolved
setenv =
PYTHONPATH = {toxinidir}
SUPERSET_TESTENV = true
SUPERSET_CONFIG = tests.superset_test_config
SUPERSET_HOME = {envtmpdir}
ENABLE_REACT_CRUD_VIEWS = true
commands =
npm install -g npm@'>=6.5.0'
pip install -e {toxinidir}/
{toxinidir}/superset-frontend/cypress_build.sh dashboard
commands_post =
pkill -if "python {envbindir}/flask"

[testenv:cypress-explore]
setenv =
PYTHONPATH = {toxinidir}
SUPERSET_TESTENV = true
SUPERSET_CONFIG = tests.superset_test_config
SUPERSET_HOME = {envtmpdir}
ENABLE_REACT_CRUD_VIEWS = true
commands =
npm install -g npm@'>=6.5.0'
pip install -e {toxinidir}/
{toxinidir}/superset-frontend/cypress_build.sh explore
deps =
-rrequirements/testing.txt
commands_post =
pkill -if "python {envbindir}/flask"

[testenv:cypress-sqllab]
setenv =
PYTHONPATH = {toxinidir}
SUPERSET_TESTENV = true
SUPERSET_CONFIG = tests.superset_test_config
SUPERSET_HOME = {envtmpdir}

[testenv:cypress-sqllab]
ENABLE_REACT_CRUD_VIEWS = true
commands =
npm install -g npm@'>=6.5.0'
pip install -e {toxinidir}/
{toxinidir}/superset-frontend/cypress_build.sh sqllab
deps =
-rrequirements/testing.txt
commands_post =
pkill -if "python {envbindir}/flask"

[testenv:cypress-sqllab-backend-persist]
setenv =
PYTHONPATH = {toxinidir}
SUPERSET_TESTENV = true
SUPERSET_CONFIG = tests.superset_test_config
SUPERSET_HOME = {envtmpdir}

[testenv:cypress-sqllab-backend-persist]
ENABLE_REACT_CRUD_VIEWS = true
commands =
npm install -g npm@'>=6.5.0'
pip install -e {toxinidir}/
{toxinidir}/superset-frontend/cypress_build.sh sqllab
deps =
-rrequirements/testing.txt
setenv =
PYTHONPATH = {toxinidir}
SUPERSET_CONFIG = tests.superset_test_config_sqllab_backend_persist
SUPERSET_HOME = {envtmpdir}
commands_post =
pkill -if "python {envbindir}/flask"

[testenv:eslint]
changedir = {toxinidir}/superset-frontend
Expand Down