Skip to content

Commit be9b388

Browse files
author
konstantina
committed
Updated test_compile_local_files function due to homepage changes.
This function uploads, compiles and deletes all sketches included in test_data/cb_compile_tester folder using demo_user on staging site.
1 parent 8c4d236 commit be9b388

File tree

1 file changed

+44
-6
lines changed

1 file changed

+44
-6
lines changed

tests/compile_tester/test_compile_tester_projects.py

Lines changed: 44 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,12 @@
77
from codebender_testing.config import COMPILE_TESTER_STAGING_URL
88
from selenium.webdriver.common.by import By
99
from codebender_testing.utils import SeleniumTestCase
10+
from selenium.webdriver.support.ui import WebDriverWait
11+
from selenium.webdriver.support import expected_conditions
1012
import os
1113
import pytest
1214
import time
1315

14-
1516
class TestCompileTester(SeleniumTestCase):
1617

1718
# Here, we require the LIVE_SITE_URL since the compiler tester user
@@ -31,15 +32,50 @@ def test_compile_local_files(self, tester_login):
3132
"""Tests that we can upload all of cb_compile_tester's projects
3233
(stored locally in test_data/cb_compile_tester), compile them,
3334
and finally delete them."""
35+
36+
WebDriverWait(self.driver, 30).until(
37+
expected_conditions.invisibility_of_element_located(
38+
(By.CSS_SELECTOR, "#home-page-loading-screen")
39+
)
40+
)
41+
3442
filenames = os.listdir(COMPILE_TESTER_DIR)
3543
test_files = [os.path.join(COMPILE_TESTER_DIR, name) for name in filenames]
36-
projects = [self.upload_project('#uploadFolderZip form', fname,
37-
os.path.splitext(os.path.basename(fname))[0]) for fname
38-
in test_files]
44+
45+
for test_file in test_files:
46+
# Click the Upload Sketch button.
47+
upload_button = self.get_element(By.CSS_SELECTOR, '#sketch-upload-button')
48+
upload_button.click()
49+
# Click the Upload zip option from the dropdown menu.
50+
sketch_upload_zip = self.get_element(By.CSS_SELECTOR, '#upload-sketch-zip')
51+
sketch_upload_zip.click()
52+
53+
upload_name = self.upload_project('#dropzoneForm',
54+
test_file,
55+
os.path.splitext(os.path.basename(test_file))[0])
56+
# Wait for the success mark to appear.
57+
WebDriverWait(self.driver, 30).until(
58+
expected_conditions.visibility_of_element_located(
59+
(By.CSS_SELECTOR, ".dz-success-mark")
60+
)
61+
)
62+
# Close the modal.
63+
close_btn = self.get_element(By.CSS_SELECTOR, "#home-upload-sketch-modal .btn-danger")
64+
close_btn.click()
65+
# Wait for the modal to close.
66+
WebDriverWait(self.driver, 30).until(
67+
expected_conditions.invisibility_of_element_located(
68+
(By.CSS_SELECTOR, ".modal-backdrop fade")
69+
)
70+
)
71+
selector = '#project_list li[data-name="'+ upload_name +'"]'
72+
project_uploaded = self.get_element(By.CSS_SELECTOR, selector).text.split('\n')[0]
73+
assert upload_name != project_uploaded, "upload_name is different from project_uploaded!"
74+
3975
flag = True
4076
while flag:
4177
uploaded_sketches = self.get_elements(By.CSS_SELECTOR, '#project_list > li')
42-
if len(uploaded_sketches) >= len(projects):
78+
if len(uploaded_sketches) >= len(test_files):
4379
flag = False
4480
break
4581
time.sleep(1)
@@ -48,5 +84,7 @@ def test_compile_local_files(self, tester_login):
4884
iframe=False,
4985
compile_type='sketch',
5086
create_report=True, logfile=COMPILE_TESTER_LOGFILE_STAGING)
51-
for name in projects:
87+
88+
for name in filenames:
89+
name = name.split('.')[0]
5290
self.delete_project(name.replace(" ", "-"))

0 commit comments

Comments
 (0)