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

Mccalluc/cypress continued #2239

Merged
merged 65 commits into from
Oct 20, 2017
Merged
Show file tree
Hide file tree
Changes from 62 commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
c6b9182
Fresh install of cypress
mccalluc Oct 11, 2017
39ab46d
cypress default config
mccalluc Oct 11, 2017
19037ee
Test homepage
mccalluc Oct 11, 2017
7ce33b8
Test statistics and about
mccalluc Oct 11, 2017
77a047a
Travis ready to go?
mccalluc Oct 11, 2017
31bc98d
Travis ready to go?
mccalluc Oct 11, 2017
f7f9333
Try explore and list, but they do not work
mccalluc Oct 11, 2017
78bda40
Add runserver
mccalluc Oct 11, 2017
47878f6
Wait for server to start
mccalluc Oct 11, 2017
d72508d
Util function in tests / hit right url on travis
mccalluc Oct 11, 2017
9c9b7ab
Remove selenium from travis.yml
mccalluc Oct 11, 2017
d8351e8
Remove all references to selenium
mccalluc Oct 11, 2017
55d6eb9
collectstatic
mccalluc Oct 11, 2017
67eb7ea
Test explore and list
mccalluc Oct 11, 2017
11378de
noinput
mccalluc Oct 11, 2017
33f6e3e
start registration
mccalluc Oct 11, 2017
246b5f4
mkdir static
mccalluc Oct 11, 2017
052d97a
Move grunt up so ui/production is available
mccalluc Oct 12, 2017
65015c6
Try adding --insecure so it will serve static?
mccalluc Oct 12, 2017
96e0769
mkdir not needed now that grunt comes first?
mccalluc Oct 12, 2017
d268abf
Travis is running test, but getting stuck trying to send email
mccalluc Oct 12, 2017
bc4f4ba
These two failed on travis
mccalluc Oct 12, 2017
87b28f2
Account approval and login are tested
mccalluc Oct 12, 2017
6e44277
Util functions done right
mccalluc Oct 12, 2017
e3c8d00
shell_plus > shell
mccalluc Oct 12, 2017
1f49925
Start testing profile page
mccalluc Oct 12, 2017
e2e119c
Try to record cypress runs in travis
mccalluc Oct 16, 2017
f5b28c3
Different IP between dev and travis causing problems
mccalluc Oct 16, 2017
d6c9c62
cypress --record
mccalluc Oct 16, 2017
c5169af
Activate guest user
mccalluc Oct 16, 2017
5b2f449
Load and add to public group
mccalluc Oct 16, 2017
f98537a
Add line to README
mccalluc Oct 16, 2017
513a739
Empty stub tests
mccalluc Oct 16, 2017
17b0652
Change order in travis
mccalluc Oct 16, 2017
3834332
visible_btn util function; link to dashboard
mccalluc Oct 17, 2017
0cfd64b
Fixtures. Make "visible" more flexible.
mccalluc Oct 17, 2017
c63632e
Test sorting and locking
mccalluc Oct 17, 2017
af5d3bf
And check that buttons toggle
mccalluc Oct 17, 2017
9345e58
data sets list test
mccalluc Oct 17, 2017
bc71aff
TODO note
mccalluc Oct 17, 2017
11d15e5
Add params to python utils so we can create a slugged dataset
mccalluc Oct 17, 2017
2e394b5
This will fail on Travis, but is prereq for work with Scott tomorrow
mccalluc Oct 18, 2017
c733257
Temporarily disable
mccalluc Oct 18, 2017
3316c7a
Start preview test
mccalluc Oct 18, 2017
0dadab5
test preview... but IDs are wrong?
mccalluc Oct 18, 2017
a91e784
preview spec with stronger assertions
mccalluc Oct 18, 2017
5e02ecb
fix typo
mccalluc Oct 18, 2017
d6df9c8
Move to before_script
mccalluc Oct 18, 2017
2ad1d18
Remove from readme; move to wiki
mccalluc Oct 18, 2017
dce68c2
Replace hardcoded url with human-readable note
mccalluc Oct 18, 2017
0e11f2a
Flake8 is complaining now: not sure why it was not a problem earlier
mccalluc Oct 18, 2017
9337001
delete the new user we created
mccalluc Oct 18, 2017
1d7884e
Clean up DataSets
mccalluc Oct 18, 2017
8dafb24
Split up grunt, and hopefully this is sufficient for Travis
mccalluc Oct 18, 2017
f865346
Bring back all the selenium code
mccalluc Oct 19, 2017
98d48fc
These cases are now covered by cypress
mccalluc Oct 19, 2017
b980714
TODOs: Replace with cypress, eventually
mccalluc Oct 19, 2017
d4012ba
selenium puppet
mccalluc Oct 19, 2017
e018b4c
slug=None not needed in factory
mccalluc Oct 19, 2017
53ab0ec
Reenable production email. Expecting tests to run, up til the point w…
mccalluc Oct 19, 2017
80372d1
Make selenium_testing a module again
mccalluc Oct 19, 2017
3ef7916
Run in dev mode on travis, so that puppet will use console for email,…
mccalluc Oct 19, 2017
73c899b
New prod_except_email settings
mccalluc Oct 19, 2017
81222f7
tweak prod settings only when running server, as suggested by scott
mccalluc Oct 19, 2017
62bdcc6
On travis, runserver with dev settings (so we will get console email …
mccalluc Oct 20, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ codekit-config.json
/refinery/ui/.tmp/
/refinery/ui/coverage/
/refinery/ui/docs/
/refinery/ui/cypress/screenshots/
/refinery/ui/cypress/videos/
/isa-tab/
/import/
/static/
Expand Down
25 changes: 22 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
sudo: required

language: python
cache: pip
addons:
firefox: "53.0.3"
apt:
packages:
- xvfb
cache:
directories:
- /home/travis/.cache/pip
- /home/travis/.cypress/Cypress

python:
- 2.7
Expand All @@ -28,6 +31,7 @@ install:
- npm --version

- pip install -r requirements.txt --quiet

# Install geckodriver required for selenium testing
- GECKODRIVER_VERSION=v0.17.0
- TAR=geckodriver-$GECKODRIVER_VERSION-linux64.tar
Expand All @@ -40,7 +44,9 @@ env:
global:
# These env vars are available to every build
- PYTHONPATH=$PYTHONPATH:../refinery:../refinery/config
- DJANGO_SETTINGS_MODULE=config.settings.prod
- DJANGO_SETTINGS_MODULE=config.settings.dev
Copy link
Member

Choose a reason for hiding this comment

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

I was thinking of something more along the lines of on line 76:
python manage.py runserver --insecure --settings=config.settings.dev
so that the cypress testing is the one off thing and we can still run our units against prod settings

Copy link
Member

Choose a reason for hiding this comment

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

FYI, unit tests should be unaffected by Django settings because they should only test small pieces of code in isolation.
Also, --insecure is only needed when DEBUG is False.

Copy link
Member Author

@mccalluc mccalluc Oct 19, 2017

Choose a reason for hiding this comment

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

core runserver only has --noreload, --nothreading, --ipv6 and the option to pick a port.

staticfiles runserver adds --insecure.

But I could just reset that envar before runserver?

( DJANGO_SETTINGS_MODULE=config.settings.dev && python manage.py runserver --insecure & )

... but maybe a better option is to make a new settings file that is like prod in all things, except for email?

Copy link
Member

Choose a reason for hiding this comment

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

There is only one Django dev server. It is invoked by the runserver subcommand. If DEBUG is set to True in the settings (e.g., in dev.py) you simply don't need to use --insecure (that mode is insecure by default).
Btw, the docs you've linked to are for Django 1.11 while we are running 1.7 - there often big differences between versions.

# CYPRESS_RECORD_KEY:
- secure: oGdTYh3rnPdG7qVGYq3TgVESypir1btO2kmafumtKR6o+FYmMtb09pe+HtiT6Qfv4pDwnYZ2RTYqsTY4h6POigU5j7qQPSsZ5WkhHt9ybFyt/vfo2B95GaAIFt+8LVjTX5TItyw0/PPUCCUluQ1n8k/NCtSfMb0kIT/CuLrg7N8=

before_script:
# Vagrant is not used on travis: This user is just for the database.
Expand All @@ -59,6 +65,15 @@ before_script:
- npm install --progress false --quiet || ( cat npm-debug.log && false )
- bower install --config.interactive=false --quiet
- cd ../

# Required for cypress tests; TODO: Move to puppet.
# TODO: Start up solr (and neo4j?)
- python manage.py loaddata guest.json
- python manage.py activate_user guest
- python manage.py add_users_to_public_group
- pushd ui && grunt make && popd
- python manage.py collectstatic --noinput -v 0
- python manage.py runserver --insecure &
script:
- set -e # Any error will cause travis to exit early and report a failure.

Expand All @@ -67,13 +82,17 @@ script:
- flake8 --exclude=migrations,ui ..

- echo 'travis_fold:start:grunt'
- pushd ui && grunt && popd
- pushd ui && grunt test && popd
- echo 'travis_fold:end:grunt'

- echo 'travis_fold:start:django-tests'
- coverage run manage.py test
- echo 'travis_fold:end:django-tests'

- echo 'travis_fold:start:cypress'
- pushd ui && node_modules/.bin/cypress run --record && popd
- echo 'travis_fold:end:cypress'

- set +e # Currently, codecov does not always exit with 0, but that should not cause travis to fail.

after_success:
Expand Down
2 changes: 1 addition & 1 deletion deployment/refinery-modules/refinery/manifests/selenium.pp
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@
ensure => 'link',
target => $install_path
}
}
}
2 changes: 2 additions & 0 deletions refinery/config/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,8 @@ def get_setting(name, settings=local_settings, default=None):
# so managers and admins know Refinery is emailing them
EMAIL_SUBJECT_PREFIX = get_setting("EMAIL_SUBJECT_PREFIX")

EMAIL_BACKEND = "django.core.mail.backends.console.EmailBackend"

# for system stability
CELERYD_MAX_TASKS_PER_CHILD = get_setting("CELERYD_MAX_TASKS_PER_CHILD")
CELERY_ROUTES = {"file_store.tasks.import_file": {"queue": "file_import"}}
Expand Down
2 changes: 1 addition & 1 deletion refinery/config/settings/prod.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
TEMPLATE_DEBUG = DEBUG

# Required when DEBUG = False
ALLOWED_HOSTS = get_setting("ALLOWED_HOSTS")
ALLOWED_HOSTS = get_setting("ALLOWED_HOSTS") # NOQA: F405

EMAIL_BACKEND = "django.core.mail.backends.smtp.EmailBackend"
Copy link
Member Author

Choose a reason for hiding this comment

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

@scottx611x : Looking at this again, I remember that we did need to add console.EmailBackend for testing, but in production I'd think we'd still want this?

Copy link
Member

Choose a reason for hiding this comment

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

Yes, both are needed in production.

Copy link
Member

Choose a reason for hiding this comment

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

@hackdna Doesn't the EMAIL_BACKEND in aws.py override this anyways?

We were wondering if this was even needed in prod.py if theres no accompanying SMTP server running by default.

Copy link
Member

Choose a reason for hiding this comment

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

Yes. The purpose of a prod config is to run the site with real users which means you need a real SMTP backend to send email.

Copy link
Member Author

Choose a reason for hiding this comment

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

Talking with Scott, realized that we were probably too fixated on running these tests in production mode. If we we ran it in development mode, the only real difference is that if something did go wrong we'd get the extra debug information, and that's a good thing.

11 changes: 9 additions & 2 deletions refinery/factory_boy/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,17 @@ def make_analyses_with_single_dataset(number_to_create, user_instance):
analysis.save()


def create_dataset_with_necessary_models(create_nodes=True):
def create_dataset_with_necessary_models(
create_nodes=True, user=None, slug=None
):
"""Create Dataset with InvestigationLink, Investigation, Study,
and Assay"""
dataset_uuid = str(uuid_builtin.uuid4())
dataset = DataSetFactory(
uuid=dataset_uuid,
title="Test DataSet - {}".format(dataset_uuid),
name="Test DataSet - {}".format(dataset_uuid)
name="Test DataSet - {}".format(dataset_uuid),
slug=slug
)

investigation_uuid = str(uuid_builtin.uuid4())
Expand Down Expand Up @@ -107,4 +110,8 @@ def create_dataset_with_necessary_models(create_nodes=True):
attribute=attribute
)

if user is not None:
dataset.set_owner(user)
dataset.save()

return dataset
91 changes: 3 additions & 88 deletions refinery/selenium_testing/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@
from core.models import Analysis, DataSet
from factory_boy.utils import make_analyses_with_single_dataset, make_datasets

from .utils import (MAX_WAIT, SeleniumTestBaseGeneric, assert_body_text,
assert_text_within_id, delete_from_ui, login,
wait_until_class_visible, wait_until_id_clickable,
from .utils import (MAX_WAIT, SeleniumTestBaseGeneric, assert_text_within_id,
delete_from_ui, login, wait_until_id_clickable,
wait_until_id_visible)


Expand All @@ -32,91 +31,7 @@ def setUp(self, site_login=True, initialize_guest=True,
create_public_group()


class NoLoginTestCase(RefinerySeleniumTestBase):
"""
Ensure that Refinery looks like it should when there is no currently
logged in user
"""

# RefinerySeleniumTestBase.setUp(): We don't need to login or
# initialize the guest user this time
def setUp(self, site_login=True, initialize_guest=True,
public_group_needed=False):
super(NoLoginTestCase, self).setUp(initialize_guest=False,
site_login=False)

def test_login_not_required(self):
self.browser.get(self.live_server_url)
assert_body_text(
self.browser,
search_array=['Collaboration', 'Statistics', 'About',
'Register', 'Login', 'Launch Pad', 'Data Sets',
'Analyses', 'Workflows']
)

self.browser.find_element_by_link_text('Statistics').click()
assert_body_text(
self.browser,
search_array=[
'Users',
'Groups',
'Files',
'Data Sets',
'Workflows',
'Projects'
]
)

self.browser.find_element_by_link_text('About').click()
assert_body_text(self.browser,
search_array=['Background', 'Contact', 'Funding',
'Team',
'Most Recent Code for this Instance'])
# TODO: All sections are empty right now


class DataSetsPanelTestCase(RefinerySeleniumTestBase):
"""
Ensure that the DataSet upload button and DataSet Preview look like
they're behaving normally
"""

def test_data_set_preview(self):
"""Test DataSet Preview"""

# Create sample Data & refresh page
make_analyses_with_single_dataset(5, self.user)

wait_until_class_visible(self.browser, "title", MAX_WAIT)
self.browser.find_elements_by_class_name("title")[0].click()

search_array = ["SUMMARY", "Description",
"Number of files (total file size)", "Owner",
"ANALYSES", "REFERENCES", "PROTOCOLS",
]
for item in Analysis.objects.filter(name__startswith="Test Analysis"):
search_array.append(item.name)

assert_body_text(self.browser, search_array)

def test_upload_button(self):
"""Test Upload button"""

wait_until_id_clickable(self.browser, "import-button",
MAX_WAIT).click()
assert_body_text(
self.browser,
search_array=[
"Data Set Import",
"Tabular Metadata",
"ISA-Tab Metadata",
"PROVIDE METADATA FILE",
"Download an example tabular metadata file.",
"Must contain column headers in the first row of the table"]
)


class UiDeletionTestCase(RefinerySeleniumTestBase):
class UiDeletionTestCase(RefinerySeleniumTestBase): # TODO: Replace w/ Cypress
"""Ensure proper deletion of DataSets and Analyses from the UI"""

def test_dataset_deletion(self, total_datasets=2):
Expand Down
2 changes: 1 addition & 1 deletion refinery/tool_manager/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -2662,7 +2662,7 @@ def test_workflow_tool_analysis_name(self):
)


class VisualizationToolLaunchTests(ToolManagerTestBase,
class VisualizationToolLaunchTests(ToolManagerTestBase, # TODO: Cypress
SeleniumTestBaseGeneric):
def setUp(self):
# super() will only ever resolve a single class type for a given method
Expand Down
4 changes: 4 additions & 0 deletions refinery/ui/cypress.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"baseUrl": "http://127.0.0.1:8000",
"projectId": "odo3mu"
}
13 changes: 13 additions & 0 deletions refinery/ui/cypress/fixtures/api-v1-data_sets-assays.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"meta": {
"total_count": 1
},
"objects": [
{
"id": 28,
"measurement": null,
"technology": null,
"uuid": "7c532f21-d4c4-40da-83c4-9a72ade5c80f"
}
]
}
14 changes: 14 additions & 0 deletions refinery/ui/cypress/fixtures/api-v1-data_sets-sharing.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"owner": "9bf8da15-9688-4965-aa69-9ed4c31fef83",
"share_list": [
{
"group_id": 189,
"group_name": "group_1508275589185",
"group_uuid": "9acd285d-2599-4c13-a51f-b42551904cb3",
"perms": {
"change": false,
"read": false
}
}
]
}