7
7
from codebender_testing .config import COMPILE_TESTER_STAGING_URL
8
8
from selenium .webdriver .common .by import By
9
9
from codebender_testing .utils import SeleniumTestCase
10
+ from selenium .webdriver .support .ui import WebDriverWait
11
+ from selenium .webdriver .support import expected_conditions
10
12
import os
11
13
import pytest
12
14
import time
13
15
14
-
15
16
class TestCompileTester (SeleniumTestCase ):
16
17
17
18
# Here, we require the LIVE_SITE_URL since the compiler tester user
@@ -31,15 +32,50 @@ def test_compile_local_files(self, tester_login):
31
32
"""Tests that we can upload all of cb_compile_tester's projects
32
33
(stored locally in test_data/cb_compile_tester), compile them,
33
34
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
+
34
42
filenames = os .listdir (COMPILE_TESTER_DIR )
35
43
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
+
39
75
flag = True
40
76
while flag :
41
77
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 ):
43
79
flag = False
44
80
break
45
81
time .sleep (1 )
@@ -48,5 +84,7 @@ def test_compile_local_files(self, tester_login):
48
84
iframe = False ,
49
85
compile_type = 'sketch' ,
50
86
create_report = True , logfile = COMPILE_TESTER_LOGFILE_STAGING )
51
- for name in projects :
87
+
88
+ for name in filenames :
89
+ name = name .split ('.' )[0 ]
52
90
self .delete_project (name .replace (" " , "-" ))
0 commit comments