-
Notifications
You must be signed in to change notification settings - Fork 5
Frontend js unit tests #676 #36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 1 commit
dc9c4d6
8ab2bad
a9fdec2
8e68b45
e9560a4
c36d6bf
a331a1f
b04cdd2
ca761f9
5d85a87
f40629d
fdd54d9
04644d4
458eb85
1a058b5
2cca710
d84b4da
b3d143c
5f3db1d
e2491ec
8740785
0586f9d
0fa143b
b881a82
211cb29
9fec384
b5c8aaa
3f32f26
45e3c43
97eb8e0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
Pull Request: | ||
https://github.com/codebendercc/codebender.cc/pull/676 | ||
|
||
Selenium_Test_Script | ||
|
||
Homepage Test Caces: | ||
test_sketches_counters.py : Check that the counters of the sketches are correct. | ||
|
||
|
||
Login and visit the new home page. | ||
Create 2 public sketches | ||
Create 2 private sketches | ||
Check that when the page loads, the loading screen appears and message "Loading the Sketches, please wait" is displayed. | ||
Check that the counters: | ||
Public sketches (blue) have the correct value. | ||
Private sketches (purple) have the correct value. | ||
Check that the counter for private projects also appears at the Badges section and has the correct value. | ||
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. | ||
|
||
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). | ||
Change the privite sketch to public | ||
Change the public to private | ||
|
||
|
||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
from codebender_testing.utils import SeleniumTestCase | ||
from selenium import webdriver | ||
from selenium.webdriver.common.by import By | ||
from selenium.webdriver.common.keys import Keys | ||
from selenium.webdriver.support.ui import Select | ||
from selenium.common.exceptions import NoSuchElementException | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unused import There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
from selenium.common.exceptions import NoAlertPresentException | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unused import There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
import unittest, time, re | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
|
||
class TestSketchesCounters(SeleniumTestCase): | ||
|
||
def test_sketches_counters(self): | ||
self.driver = webdriver.Firefox() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Your class is a subclass of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
self.driver.implicitly_wait(30) | ||
self.base_url = "https://staging.codebender.cc/" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Tests should be agnostic of the target site that will run against. You could use the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
self.verificationErrors = [] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This variable seems unused inside the class, so why initialize it? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
self.accept_next_alert = True | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here, unused variable. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
driver = self.driver | ||
driver.get(self.base_url + "/") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This could have been done with: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
driver.find_element_by_id("login_btn").click() | ||
driver.find_element_by_id("username").clear() | ||
driver.find_element_by_id("username").send_keys("demo_user") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We have the credentials of the user at environment variables. We must not hard-code user credentials or API keys. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
driver.find_element_by_id("password").clear() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You are mixing tabs with spaces in your file. Please use spaces only. |
||
driver.find_element_by_id("password").send_keys("testerPASS") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here for password. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
driver.find_element_by_id("_submit").click() | ||
driver.find_element_by_id("create_sketch_btn").click() | ||
|
||
|
||
driver.find_element_by_id("create-sketch-modal-action-button").click() | ||
time.sleep(5) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why you use sleep()? You could have used expected conditions in order to wait for the elements you want. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
driver.find_element_by_id("logo_small").click() | ||
driver.find_element_by_id("create_sketch_btn").click() | ||
driver.find_element_by_id("create-sketch-modal-action-button").click() | ||
time.sleep(5) | ||
driver.find_element_by_id("logo_small").click() | ||
driver.find_element_by_id("create_sketch_btn").click() | ||
driver.find_element_by_xpath("(//input[@name='create-sketch-modal-title'])[2]").click() | ||
driver.find_element_by_id("create-sketch-modal-action-button").click() | ||
time.sleep(5) | ||
driver.find_element_by_id("logo_small").click() | ||
driver.find_element_by_id("create_sketch_btn").click() | ||
driver.find_element_by_xpath("(//input[@name='create-sketch-modal-title'])[2]").click() | ||
driver.find_element_by_id("create-sketch-modal-action-button").click() | ||
time.sleep(5) | ||
driver.find_element_by_id("logo_small").click() | ||
assert driver.find_element_by_id("private-sketches-counter").text=="2" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It would be better to read first the values of the current private/public sketches counters and assert against them. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
assert driver.find_element_by_id("public-sketches-counter").text=="2" | ||
assert driver.find_element_by_id("privateProjectAvailableNumber").text=="0" | ||
assert driver.find_element_by_id("available-private-projects-counter").text=="0/2" | ||
assert "Add more"==driver.find_element_by_link_text("Add more").text | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missed spaces between the equability operator. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
|
||
#Private-->Public | ||
driver.find_element_by_link_text("Edit Info").click() | ||
time.sleep(5) | ||
driver.find_element_by_name("edit-sketch-modal-title").click() | ||
driver.find_element_by_id("edit-sketch-modal-action-button").click() | ||
time.sleep(5) | ||
assert driver.find_element_by_id("private-sketches-counter").text=="1" | ||
assert driver.find_element_by_id("public-sketches-counter").text=="3" | ||
|
||
#Public-->Private | ||
driver.find_element_by_link_text("Edit Info").click() | ||
time.sleep(5) | ||
driver.find_element_by_xpath("(//input[@name='edit-sketch-modal-title'])[2]").click() | ||
driver.find_element_by_id("edit-sketch-modal-action-button").click() | ||
time.sleep(5) | ||
assert driver.find_element_by_id("private-sketches-counter").text=="2" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing space. |
||
assert driver.find_element_by_id("public-sketches-counter").text=="2" | ||
#for x in range(0, 3): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do not leave commented code in your commits. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
# driver.find_element_by_css_selector("i.fa.fa-trash").click() | ||
# driver.find_element_by_css_selector("div.modal-footer.delete-sketch-modal-footer > button.btn.delete-sketch-modal-button").click() | ||
#driver.find_element_by_css_selector("div.modal-footer.delete-sketch-modal-footer > button.btn.btn-danger").click() | ||
|
||
|
||
|
||
driver.find_element_by_id("logout").click() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You should have used the: self.logout() function. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
|
||
|
||
|
||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Multiple new lines on the end of file. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can the use .md extension in the Readme (e.g. Readme.md) so we can write in markdown the documentation.