From c34f323cadeb727f97354ec5cfc1adef72b8118e Mon Sep 17 00:00:00 2001 From: cmaceves Date: Mon, 30 Mar 2020 09:02:32 -0700 Subject: [PATCH 1/5] update for selenium testing --- code/templates/compoundenrichment.html | 2 +- test-production-integration/test_selenium.py | 54 ++++++++++++++++++++ 2 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 test-production-integration/test_selenium.py diff --git a/code/templates/compoundenrichment.html b/code/templates/compoundenrichment.html index 2b532bb..6f34b79 100644 --- a/code/templates/compoundenrichment.html +++ b/code/templates/compoundenrichment.html @@ -20,7 +20,7 @@

Chemical Enrichment Query Interface

-
+
diff --git a/test-production-integration/test_selenium.py b/test-production-integration/test_selenium.py new file mode 100644 index 0000000..83a91a8 --- /dev/null +++ b/test-production-integration/test_selenium.py @@ -0,0 +1,54 @@ +import time +import json +from selenium import webdriver +from selenium.webdriver.common.by import By +from selenium.webdriver.common.action_chains import ActionChains +from selenium.webdriver.support import expected_conditions as EC +from selenium.webdriver.support.wait import WebDriverWait +from selenium.webdriver.common.keys import Keys +import unittest, time, re +import os + +SERVER_URL = os.environ.get("SERVER_URL", "https://redu.ucsd.edu") + +class TestInterfaceready(unittest.TestCase): + def setUp(self): + options = webdriver.ChromeOptions() + options.add_argument('headless') + self.driver = webdriver.Chrome(options=options) + #self.driver = webdriver.PhantomJS() + self.driver.implicitly_wait(30) + self.vars = {} + + def tearDown(self): + self.driver.quit() + + def test_compound_enrichment(self): + #going to the page + self.driver.get("{}/compoundenrichmentdashboard?compound=ESCITALOPRAM%20OXALATE".format(SERVER_URL)) + #self.driver.get("http://localhost:5006/compoundenrichmentdashboard?compound=ESCITALOPRAM%20OXALATE") + time.sleep(1) + + wait = WebDriverWait(self.driver, 180) + + #waiting for the modal to go aay + wait.until(EC.invisibility_of_element_located((By.ID, 'loadMe'))) + + #waiting for the button to be clickable + wait.until(EC.element_to_be_clickable((By.ID,'querycompound'))) + + #clicking the button + python_button = self.driver.find_element(By.ID, 'querycompound') + python_button.click() + #time.sleep(60) + + try: + alert = self.driver.switch_to.alert + alert.accept() + print("alert present, error") + return 1 + except Exception: + print("no alert, passing") + +if __name__ == "__main__": + unittest.main() From 0adbd14289bdc9f3da2b3a275e0698f87ee5254d Mon Sep 17 00:00:00 2001 From: Mingxun Wang Date: Tue, 31 Mar 2020 15:15:21 -0700 Subject: [PATCH 2/5] adding a test locally --- Makefile | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 Makefile diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..3d6a3f4 --- /dev/null +++ b/Makefile @@ -0,0 +1,4 @@ +test-push: + act -P ubuntu-latest=nektos/act-environments-ubuntu:18.04 +test-schedule: + act schedule -P ubuntu-latest=nektos/act-environments-ubuntu:18.04 From 67ded8628edd44ba559dd8239e6dfa30f6fdaf9d Mon Sep 17 00:00:00 2001 From: Mingxun Wang Date: Tue, 31 Mar 2020 18:35:08 -0700 Subject: [PATCH 3/5] modifying to use real act github --- .github/workflows/productionintegration.yml | 5 ++--- README.md | 6 ++++++ test-production-integration/test_selenium.py | 9 +++++---- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/.github/workflows/productionintegration.yml b/.github/workflows/productionintegration.yml index f77fa06..fc6d987 100644 --- a/.github/workflows/productionintegration.yml +++ b/.github/workflows/productionintegration.yml @@ -18,8 +18,7 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - pip install requests + pip install requests nose2 selenium - name: Test with pytest run: | - pip install nose2 - cd test-production-integration && nose2 -v + cd test-production-integration && nose2 -v test_selenium diff --git a/README.md b/README.md index 3a667e0..18d19dc 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,12 @@ We have unit tests to test the validators. There are several naming conventions: 1. ```invalid_*``` - These are invalid files that fail validation 1. ```invaliddata_*``` - These are valid files that pass validation but fail to match with data in MassIVE +To run all unit tests, we are using act to run github actions locally: + +```make test-push``` + +to simulate a push to the repository and run the full suite of unit tests exactly as we'd run at github. + ## Updating ReDU Data Procedure One of the key steps in ReDU is the updating of the database to include the latest identifications for files within ReDU. These are the following steps: diff --git a/test-production-integration/test_selenium.py b/test-production-integration/test_selenium.py index 23d23dc..e988654 100644 --- a/test-production-integration/test_selenium.py +++ b/test-production-integration/test_selenium.py @@ -15,8 +15,8 @@ class TestInterfaceready(unittest.TestCase): def setUp(self): options = webdriver.ChromeOptions() options.add_argument('headless') - self.driver = webdriver.Chrome(options=options) - #self.driver = webdriver.PhantomJS() + #self.driver = webdriver.Chrome(options=options) + self.driver = webdriver.PhantomJS() self.driver.implicitly_wait(30) self.vars = {} @@ -25,8 +25,9 @@ def tearDown(self): def test_compound_enrichment(self): #going to the page - self.driver.get("{}/compoundenrichmentdashboard?compound=ESCITALOPRAM%20OXALATE".format(SERVER_URL)) - #self.driver.get("http://localhost:5006/compoundenrichmentdashboard?compound=ESCITALOPRAM%20OXALATE") + url = "{}/compoundenrichmentdashboard?compound=ESCITALOPRAM%20OXALATE".format(SERVER_URL) + print(url) + self.driver.get(url) time.sleep(1) wait = WebDriverWait(self.driver, 180) From 5f68f7bd6dc2863b47eb6746f4803a9ea9e3d424 Mon Sep 17 00:00:00 2001 From: Mingxun Wang Date: Tue, 31 Mar 2020 18:35:48 -0700 Subject: [PATCH 4/5] updating readme --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 18d19dc..7b09113 100644 --- a/README.md +++ b/README.md @@ -31,6 +31,10 @@ To run all unit tests, we are using act to run github actions locally: to simulate a push to the repository and run the full suite of unit tests exactly as we'd run at github. +To simulate selenium and production integration tests: + +```make test-schedule``` + ## Updating ReDU Data Procedure One of the key steps in ReDU is the updating of the database to include the latest identifications for files within ReDU. These are the following steps: From bbe4d38ea44ac41a669b2c2badeac45e91870895 Mon Sep 17 00:00:00 2001 From: Mingxun Wang Date: Tue, 31 Mar 2020 18:36:16 -0700 Subject: [PATCH 5/5] adding readme link --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 7b09113..ec13666 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ We have unit tests to test the validators. There are several naming conventions: 1. ```invalid_*``` - These are invalid files that fail validation 1. ```invaliddata_*``` - These are valid files that pass validation but fail to match with data in MassIVE -To run all unit tests, we are using act to run github actions locally: +To run all unit tests, we are using [act](https://github.com/nektos/act) to run github actions locally: ```make test-push```