Skip to content

Commit bea5ae2

Browse files
author
konstantina
committed
Updated functions that test upload functionality.
Due to changes in homepage, functions that test upload ino file and upload zip file had to be updated.
1 parent be9b388 commit bea5ae2

File tree

1 file changed

+27
-10
lines changed

1 file changed

+27
-10
lines changed

tests/common/user_home/test_user_home.py

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
from codebender_testing.config import TEST_DATA_INO
55
from codebender_testing.config import TEST_DATA_ZIP
66
from codebender_testing.utils import SeleniumTestCase
7-
7+
from selenium.webdriver.support.ui import WebDriverWait
8+
from selenium.webdriver.support import expected_conditions
89

910
# Name to be used for the new project that is created.
1011
NEW_PROJECT_NAME = 'selenium_TestUserHome'
@@ -23,20 +24,36 @@ def _upload_test(self, dropzone_selector, test_fname, sketch_name=None):
2324
default it is inferred from the file name.
2425
We delete the project if it is successfully uploaded.
2526
"""
26-
try:
27-
upload_name = self.upload_project(dropzone_selector, test_fname, sketch_name)
28-
selector = '#project_list li[data-name="'+ str(upload_name.lower()) +'"]'
29-
project_uploaded = self.get_element(By.CSS_SELECTOR, selector).text.split('\n')[0]
30-
assert upload_name == project_uploaded
31-
finally:
32-
self.delete_project(upload_name)
27+
# Upload the file.
28+
upload_name = self.upload_project(dropzone_selector, test_fname, sketch_name)
29+
# Wait for the success mark to appear before closing the modal.
30+
WebDriverWait(self.driver, 30).until(
31+
expected_conditions.visibility_of_element_located(
32+
(By.CSS_SELECTOR, ".dz-success-mark")
33+
)
34+
)
35+
close_btn = self.get_element(By.CSS_SELECTOR, "#home-upload-sketch-modal .btn-danger")
36+
close_btn.click()
37+
# Check that the uploaded file appears on the homepage.
38+
selector = '#project_list li[data-name="'+ upload_name +'"]'
39+
project_uploaded = self.get_element(By.CSS_SELECTOR, selector).text.split('\n')[0]
40+
assert upload_name == project_uploaded
41+
self.delete_project(upload_name)
3342

3443
def test_upload_project_ino(self):
3544
"""Tests that we can upload a .ino file."""
36-
self._upload_test('#uploadInoModal form', TEST_DATA_INO)
45+
upload_button = self.get_element(By.CSS_SELECTOR, '#sketch-upload-button')
46+
upload_button.click()
47+
sketch_upload_ino = self.get_element(By.CSS_SELECTOR, '#upload-sketch-ino')
48+
sketch_upload_ino.click()
49+
self._upload_test('#dropzoneForm', TEST_DATA_INO)
3750

3851
def test_upload_project_zip(self):
3952
"""Tests that we can successfully upload a zipped project."""
4053
# TODO: how is the project name inferred from the zip file?
4154
# Hardcoding the contents of the zip file feels weird here.
42-
self._upload_test('#uploadFolderZip form', TEST_DATA_ZIP, sketch_name='upload_zip')
55+
upload_button = self.get_element(By.CSS_SELECTOR, '#sketch-upload-button')
56+
upload_button.click()
57+
sketch_upload_zip = self.get_element(By.CSS_SELECTOR, '#upload-sketch-zip')
58+
sketch_upload_zip.click()
59+
self._upload_test('#dropzoneForm', TEST_DATA_ZIP, sketch_name='upload_zip')

0 commit comments

Comments
 (0)