|
| 1 | +from codebender_testing.utils import SeleniumTestCase |
| 2 | +from selenium import webdriver |
| 3 | +from selenium.webdriver.common.by import By |
| 4 | +from selenium.webdriver.common.keys import Keys |
| 5 | +from codebender_testing import config |
| 6 | +from selenium.webdriver.common.action_chains import ActionChains |
| 7 | +from selenium.webdriver.support import expected_conditions |
| 8 | +from codebender_testing.config import TIMEOUT |
| 9 | +from selenium.webdriver.support.ui import WebDriverWait |
| 10 | +import pytest |
| 11 | + |
| 12 | +class TestSketchesCounters(SeleniumTestCase): |
| 13 | + |
| 14 | + @pytest.fixture(scope="class", autouse=True) |
| 15 | + def open_user_home(self, tester_login): |
| 16 | + """Makes sure we are logged in and are at the user home page |
| 17 | + performing any of these tests.""" |
| 18 | + pass |
| 19 | + |
| 20 | + def test_create_sketch_modal(self): |
| 21 | + # Create a public project. |
| 22 | + createSketchBtn = self.get_element(By.ID, 'create_sketch_btn') |
| 23 | + createSketchBtn.click() |
| 24 | + WebDriverWait(self.driver, TIMEOUT['LOCATE_ELEMENT']).until( |
| 25 | + expected_conditions.visibility_of_element_located( |
| 26 | + (By.CSS_SELECTOR, "#create-sketch-modal") |
| 27 | + ) |
| 28 | + ) |
| 29 | + createBtn = self.get_element( |
| 30 | + By.ID, 'create-sketch-modal-action-button') |
| 31 | + |
| 32 | + createdProject = self.get_element( |
| 33 | + By.ID, 'create-sketch-name').get_attribute('value') |
| 34 | + |
| 35 | + # Check that when the create sketch modal opens, |
| 36 | + # the sketch name input has focus. |
| 37 | + assert self.get_element(By.ID, 'create-sketch-name') == \ |
| 38 | + self.driver.switch_to.active_element |
| 39 | + |
| 40 | + # Check that when the input has focus and you press Enter, |
| 41 | + # the create sketch action is executed. |
| 42 | + self.get_element(By.ID, 'create-sketch-name').send_keys(Keys.ENTER) |
| 43 | + |
| 44 | + self.get_element(By.CSS_SELECTOR, '#create-sketch-modal-action-button .fa-spinner') |
| 45 | + |
| 46 | + # Check that during the sketch creation, |
| 47 | + # the sketch privacy radio buttons are disabled. |
| 48 | + publicRadioButton = self.get_element(By.CSS_SELECTOR, |
| 49 | + '#create-sketch-modal-type-controls [value="public"]') |
| 50 | + privateRadioButton = self.get_element(By.CSS_SELECTOR, |
| 51 | + '#create-sketch-modal-type-controls [value="private"]') |
| 52 | + assert publicRadioButton.get_attribute('disabled') |
| 53 | + assert privateRadioButton.get_attribute('disabled') |
| 54 | + |
| 55 | + WebDriverWait(self.driver, TIMEOUT['LOCATE_ELEMENT']).until( |
| 56 | + expected_conditions.element_to_be_clickable( |
| 57 | + (By.CSS_SELECTOR, "#editor_heading_project_name") |
| 58 | + ) |
| 59 | + ) |
| 60 | + |
| 61 | + # Delete the created project. |
| 62 | + self.open("/") |
| 63 | + self.delete_project(createdProject) |
0 commit comments