Skip to content

Commit a9fdec2

Browse files
committed
Updated script-Added new steps
1 parent 8ab2bad commit a9fdec2

File tree

2 files changed

+118
-38
lines changed

2 files changed

+118
-38
lines changed

tests/common/sketches_counters/Readme.txt

Lines changed: 0 additions & 26 deletions
This file was deleted.

tests/common/sketches_counters/test_sketches_counters.py

Lines changed: 118 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,21 @@
55
from selenium.webdriver.support.ui import Select
66
from codebender_testing import config
77
from codebender_testing.config import STAGING_SITE_URL
8+
from selenium.webdriver.common.action_chains import ActionChains
89
import os
910
import time
1011
import pytest
1112

1213
class TestSketchesCounters(SeleniumTestCase):
14+
1315
def test_sketches_counters(self):
1416
self.driver.implicitly_wait(30)
1517
driver = self.driver
1618
self.open("/")
17-
1819
#Login and visit the new home page.
1920
credentials = {
20-
'username': os.environ.get('CODEBENDER_TEST_USER'),
21-
'password': os.environ.get('CODEBENDER_TEST_PASS'),
21+
'username': os.environ.get('CODEBENDER_TEST_USER'),
22+
'password': os.environ.get('CODEBENDER_TEST_PASS'),
2223
}
2324
driver.find_element_by_id("login_btn").click()
2425
driver.find_element_by_id("username").clear()
@@ -27,9 +28,8 @@ def test_sketches_counters(self):
2728
driver.find_element_by_id("password").send_keys(credentials['password'])
2829
driver.find_element_by_id("_submit").click()
2930

30-
#check that there are not any sketches.
31-
assert driver.find_element_by_id("private-sketches-counter").text == "0"
32-
assert driver.find_element_by_id("public-sketches-counter").text == "0"
31+
assert driver.find_element_by_id("private-sketches-counter").text=="0"
32+
assert driver.find_element_by_id("public-sketches-counter").text=="0"
3333

3434
#Create 2 public sketches and Create 2 private sketches
3535
driver.find_element_by_id("create_sketch_btn").click()
@@ -52,16 +52,98 @@ def test_sketches_counters(self):
5252
driver.find_element_by_id("logo_small").click()
5353

5454
#Check that the counters have the correct value.
55-
assert driver.find_element_by_id("private-sketches-counter").text == "2"
56-
assert driver.find_element_by_id("public-sketches-counter").text == "2"
55+
assert driver.find_element_by_id("private-sketches-counter").text=="2"
56+
assert driver.find_element_by_id("public-sketches-counter").text=="2"
5757

58-
#Check that the counter for private projects also appears at the Badges section and has the correct value.
59-
assert driver.find_element_by_id("privateProjectAvailableNumber").text == "0"
60-
assert driver.find_element_by_id("available-private-projects-counter").text == "0/2"
58+
#Check that the counter for private projects also appears at the Badges section and has the correct value.
59+
assert driver.find_element_by_id("privateProjectAvailableNumber").text=="0"
60+
assert driver.find_element_by_id("available-private-projects-counter").text=="0/2"
6161

62-
#Check that if your account has private projects (e.g. 2) and all yor projects are public,counter for available private sketches should be 0/number of total private sketches(e.g.0/2) and the link to the private sketches should be Add more.
62+
#Check that if your account has private projects (e.g. 2) and all yor projects are public, counter for available private sketches should be 0/number of total private sketches(e.g. 0/2) and the link to the private sketches should be Add more.
6363
assert "Add more" == driver.find_element_by_link_text("Add more").text
6464

65+
#Check that All, Public and Private buttons work, clicking on each of them and verifying
66+
#that the correct number of sketches is viewed each time
67+
#Check "All button"
68+
self.get_element(By.XPATH, "//div[@id='filter-options']/label[2]").click()
69+
sketches = self.find_all('#project_list >li')
70+
assert len(sketches) == 4
71+
#Check "Public button"
72+
self.get_element(By.XPATH, "//div[@id='filter-options']/label[2]").click()
73+
sketches = self.find_all('#project_list >li .cb-icon-globe-inv')
74+
assert len(sketches) == 2
75+
#Check "Private button"
76+
self.get_element(By.XPATH, "//div[@id='filter-options']/label[3]").click()
77+
sketches = self.find_all('#project_list >li .fa-lock')
78+
assert len(sketches) == 2
79+
self.get_element(By.XPATH, "//div[@id='filter-options']/label[2]").click()
80+
81+
#ToDo Check that the number of private projects available is updated each time that you make a change (e.g from private to public and vice versa).
82+
83+
#Check that the counter for available private sketches also appears at the upload sketch modal (ino, zip, multiple zip) and at the create and edit sketch modal.
84+
self.get_element(By.ID, "sketch-upload-button").click()
85+
self.get_element(By.ID, "upload-sketch-ino").click()
86+
assert self.get_element(By.ID, "upload-sketch-modal-available-private-projects").text == "0/2"
87+
driver.find_element_by_xpath("//div[4]/div[3]/button").click()
88+
89+
self.get_element(By.ID, "sketch-upload-button").click()
90+
self.get_element(By.ID, "upload-sketch-zip").click()
91+
assert self.get_element(By.ID, "upload-sketch-modal-available-private-projects").text == "0/2"
92+
driver.find_element_by_xpath("//div[4]/div[3]/button").click()
93+
94+
self.get_element(By.ID, "sketch-upload-button").click()
95+
self.get_element(By.ID, "upload-sketch-folder-zip").click()
96+
assert self.get_element(By.ID, "upload-sketch-modal-available-private-projects").text == "0/2"
97+
driver.find_element_by_xpath("//div[4]/div[3]/button").click()
98+
99+
self.get_element(By.ID, "create_sketch_btn").click()
100+
assert self.get_element(By.ID, "create-sketch-modal-available-private-projects").text == "0/2"
101+
driver.find_element_by_xpath("//button[2]").click()
102+
103+
#Open the create sketch modal and try to create a new project without providing a name.
104+
#The Create button should be disabled.
105+
self.get_element(By.ID, "create_sketch_btn").click()
106+
self.get_element(By.ID, "create-sketch-name").clear()
107+
self.get_element(By.ID, "create-sketch-name").send_keys(Keys.CONTROL + "a")
108+
self.get_element(By.ID, "create-sketch-name").send_keys(Keys.DELETE)
109+
assert not self.get_element(By.ID, "create-sketch-modal-action-button").is_enabled()
110+
driver.find_element_by_xpath("//button[2]").click()
111+
112+
113+
#Check that sketch name is auto-generated as: Untitled Sketch CURRENT_DATE.
114+
self.get_element(By.ID, "create_sketch_btn").click()
115+
current_date_text= "Untitled Sketch " + time.strftime("%Y-%m-%d")
116+
assert self.get_element(By.ID, "create-sketch-name").get_attribute("value") == current_date_text
117+
driver.find_element_by_xpath("//button[2]").click()
118+
119+
#Check that when you create the sketch you are redirected into the editor.
120+
self.get_element(By.ID, "create_sketch_btn").click()
121+
self.get_element(By.ID, "create-sketch-modal-action-button").click()
122+
self.get_element(By.ID, "cb_cf_flash_btn")
123+
self.get_element(By.ID, "logo_small").click()
124+
125+
#Check that short description
126+
#Write short description with 17 characters
127+
self.get_element(By.ID, "create_sketch_btn").click()
128+
self.get_element(By.ID, "create-sketch-modal-sort-description").click()
129+
self.get_element(By.ID, "create-sketch-modal-sort-description").send_keys("short description")
130+
assert self.get_element(By.ID, "create-sketch-modal-sort-description-count").text == "123"
131+
driver.find_element_by_xpath("//button[2]").click()
132+
133+
#Write short description with 140 characters
134+
self.get_element(By.ID, "create_sketch_btn").click()
135+
self.get_element(By.ID, "create-sketch-modal-sort-description").click()
136+
self.get_element(By.ID, "create-sketch-modal-sort-description").send_keys("shortdescriptionshortdescriptionshortdescriptionshortdescriptionshortdescriptionshortdescriptionshortdescriptionshortdescriptionshortdescrip")
137+
assert self.get_element(By.ID, "create-sketch-modal-sort-description-count").text == "0"
138+
driver.find_element_by_xpath("//button[2]").click()
139+
140+
#Write short description with 153 characters
141+
self.get_element(By.ID, "create_sketch_btn").click()
142+
self.get_element(By.ID, "create-sketch-modal-sort-description").click()
143+
self.get_element(By.ID, "create-sketch-modal-sort-description").send_keys("short descriptionshort descriptionshort descriptionshort descriptionshort descriptionshort descriptionshort descriptionshort descriptionshort description")
144+
assert self.get_element(By.ID, "create-sketch-modal-sort-description-count").text == "-13"
145+
driver.find_element_by_xpath("//button[2]").click()
146+
65147
class TestDeleteAllSketches(SeleniumTestCase):
66148

67149
@pytest.mark.requires_url(STAGING_SITE_URL)
@@ -75,4 +157,28 @@ def test_delete(self, tester_login):
75157
self.delete_project(project)
76158
except:
77159
print 'No sketches found'
160+
161+
#Create Clone
162+
self.get_element(By.ID,"create_sketch_btn").click()
163+
self.get_element(By.ID,"create-sketch-modal-action-button").click()
164+
self.get_element(By.ID, "save")
165+
self.get_element(By.ID,"logo_small").click()
166+
self.get_element(By.XPATH, "//div[4]/a[2]/i").click()
167+
self.get_element(By.ID, "save")
168+
self.get_element(By.ID,"logo_small").click()
169+
170+
class TestDeleteAllSketches(SeleniumTestCase):
171+
172+
@pytest.mark.requires_url(STAGING_SITE_URL)
173+
def test_delete(self, tester_login):
174+
try:
175+
sketches = self.find_all('#project_list > li .sketch-block-title > a')
176+
projects = []
177+
for sketch in sketches:
178+
projects.append(sketch.text)
179+
for project in projects:
180+
self.delete_project(project)
181+
except:
182+
print 'No sketches found'
183+
78184
self.logout()

0 commit comments

Comments
 (0)