Merge pull request #2062 from edx/diana/drupal/lettuce-tests
Fix Lettuce Tests for Drupal site
This commit is contained in:
26
common/djangoapps/mitxmako/tests.py
Normal file
26
common/djangoapps/mitxmako/tests.py
Normal file
@@ -0,0 +1,26 @@
|
||||
from django.test import TestCase
|
||||
from django.test.utils import override_settings
|
||||
from django.core.urlresolvers import reverse
|
||||
from django.conf import settings
|
||||
from mitxmako.shortcuts import marketing_link
|
||||
from mock import patch
|
||||
|
||||
|
||||
class ShortcutsTests(TestCase):
|
||||
"""
|
||||
Test the mitxmako shortcuts file
|
||||
"""
|
||||
|
||||
@override_settings(MKTG_URLS={'ROOT': 'dummy-root', 'ABOUT': '/about-us'})
|
||||
@override_settings(MKTG_URL_LINK_MAP={'ABOUT': 'about_edx'})
|
||||
def test_marketing_link(self):
|
||||
# test marketing site on
|
||||
with patch.dict('django.conf.settings.MITX_FEATURES', {'ENABLE_MKTG_SITE': True}):
|
||||
expected_link = 'dummy-root/about-us'
|
||||
link = marketing_link('ABOUT')
|
||||
self.assertEquals(link, expected_link)
|
||||
# test marketing site off
|
||||
with patch.dict('django.conf.settings.MITX_FEATURES', {'ENABLE_MKTG_SITE': False}):
|
||||
expected_link = reverse('about_edx')
|
||||
link = marketing_link('ABOUT')
|
||||
self.assertEquals(link, expected_link)
|
||||
@@ -122,6 +122,13 @@ def should_see_a_link_called(step, text):
|
||||
assert len(world.browser.find_link_by_text(text)) > 0
|
||||
|
||||
|
||||
@step(r'should see (?:the|a) link with the id "([^"]*)" called "([^"]*)"$')
|
||||
def should_have_link_with_id_and_text(step, link_id, text):
|
||||
link = world.browser.find_by_id(link_id)
|
||||
assert len(link) > 0
|
||||
assert_equals(link.text, text)
|
||||
|
||||
|
||||
@step(r'should see "(.*)" (?:somewhere|anywhere) in (?:the|this) page')
|
||||
def should_see_in_the_page(step, text):
|
||||
assert_in(text, world.css_text('body'))
|
||||
@@ -144,3 +151,8 @@ def i_am_an_edx_user(step):
|
||||
@step(u'User "([^"]*)" is an edX user$')
|
||||
def registered_edx_user(step, uname):
|
||||
world.create_user(uname)
|
||||
|
||||
|
||||
@step(u'All dialogs should be closed$')
|
||||
def dialogs_are_closed(step):
|
||||
assert world.dialogs_closed()
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#pylint: disable=C0111
|
||||
#pylint: disable=W0621
|
||||
|
||||
from lettuce import world, step
|
||||
from lettuce import world
|
||||
import time
|
||||
from urllib import quote_plus
|
||||
from selenium.common.exceptions import WebDriverException
|
||||
@@ -104,6 +104,17 @@ def css_visible(css_selector):
|
||||
return world.browser.find_by_css(css_selector).visible
|
||||
|
||||
|
||||
@world.absorb
|
||||
def dialogs_closed():
|
||||
def are_dialogs_closed(driver):
|
||||
'''
|
||||
Return True when no modal dialogs are visible
|
||||
'''
|
||||
return not css_visible('.modal')
|
||||
wait_for(are_dialogs_closed)
|
||||
return not css_visible('.modal')
|
||||
|
||||
|
||||
@world.absorb
|
||||
def save_the_html(path='/tmp'):
|
||||
u = world.browser.url
|
||||
@@ -111,4 +122,4 @@ def save_the_html(path='/tmp'):
|
||||
filename = '%s.html' % quote_plus(u)
|
||||
f = open('%s/%s' % (path, filename), 'w')
|
||||
f.write(html)
|
||||
f.close
|
||||
f.close()
|
||||
|
||||
@@ -5,29 +5,24 @@ Feature: Homepage for web users
|
||||
|
||||
Scenario: User can see the "Login" button
|
||||
Given I visit the homepage
|
||||
Then I should see a link called "Log In"
|
||||
Then I should see a link called "Log in"
|
||||
|
||||
Scenario: User can see the "Sign up" button
|
||||
Scenario: User can see the "Register Now" button
|
||||
Given I visit the homepage
|
||||
Then I should see a link called "Sign Up"
|
||||
Then I should see a link called "Register Now"
|
||||
|
||||
Scenario Outline: User can see main parts of the page
|
||||
Given I visit the homepage
|
||||
Then I should see a link called "<Link>"
|
||||
When I click the link with the text "<Link>"
|
||||
Then I should see that the path is "<Path>"
|
||||
Then I should see a link with the id "<id>" called "<Link>"
|
||||
|
||||
Examples:
|
||||
| Link | Path |
|
||||
| Find Courses | /courses |
|
||||
| About | /about |
|
||||
| Jobs | /jobs |
|
||||
| Contact | /contact |
|
||||
| id | Link |
|
||||
| about | About |
|
||||
| jobs | Jobs |
|
||||
| faq | FAQ |
|
||||
| contact | Contact|
|
||||
| press | Press |
|
||||
|
||||
Scenario: User can visit the blog
|
||||
Given I visit the homepage
|
||||
When I click the link with the text "Blog"
|
||||
Then I should see that the url is "http://blog.edx.org/"
|
||||
|
||||
# TODO: test according to domain or policy
|
||||
Scenario: User can see the partner institutions
|
||||
|
||||
@@ -7,7 +7,7 @@ Feature: Login in as a registered user
|
||||
Given I am an edX user
|
||||
And I am an unactivated user
|
||||
And I visit the homepage
|
||||
When I click the link with the text "Log In"
|
||||
When I click the link with the text "Log in"
|
||||
And I submit my credentials on the login form
|
||||
Then I should see the login error message "This account has not been activated"
|
||||
|
||||
@@ -15,7 +15,7 @@ Feature: Login in as a registered user
|
||||
Given I am an edX user
|
||||
And I am an activated user
|
||||
And I visit the homepage
|
||||
When I click the link with the text "Log In"
|
||||
When I click the link with the text "Log in"
|
||||
And I submit my credentials on the login form
|
||||
Then I should be on the dashboard page
|
||||
|
||||
@@ -23,5 +23,5 @@ Feature: Login in as a registered user
|
||||
Given I am logged in
|
||||
When I click the dropdown arrow
|
||||
And I click the link with the text "Log Out"
|
||||
Then I should see a link with the text "Log In"
|
||||
Then I should see a link with the text "Log in"
|
||||
And I should see that the path is "/"
|
||||
|
||||
@@ -19,13 +19,13 @@ def i_am_an_activated_user(step):
|
||||
def i_submit_my_credentials_on_the_login_form(step):
|
||||
fill_in_the_login_form('email', 'robot@edx.org')
|
||||
fill_in_the_login_form('password', 'test')
|
||||
login_form = world.browser.find_by_css('form#login_form')
|
||||
login_form.find_by_value('Access My Courses').click()
|
||||
login_form = world.browser.find_by_css('form#login-form')
|
||||
login_form.find_by_name('submit').click()
|
||||
|
||||
|
||||
@step(u'I should see the login error message "([^"]*)"$')
|
||||
def i_should_see_the_login_error_message(step, msg):
|
||||
login_error_div = world.browser.find_by_css('form#login_form #login_error')
|
||||
login_error_div = world.browser.find_by_css('.submission-error.is-shown')
|
||||
assert (msg in login_error_div.text)
|
||||
|
||||
|
||||
@@ -49,6 +49,6 @@ def user_is_an_activated_user(uname):
|
||||
|
||||
|
||||
def fill_in_the_login_form(field, value):
|
||||
login_form = world.browser.find_by_css('form#login_form')
|
||||
login_form = world.browser.find_by_css('form#login-form')
|
||||
form_field = login_form.find_by_name(field)
|
||||
form_field.fill(value)
|
||||
|
||||
@@ -15,4 +15,6 @@ Feature: Register for a course
|
||||
And I visit the dashboard
|
||||
When I click the link with the text "Unregister"
|
||||
And I press the "Unregister" button in the Unenroll dialog
|
||||
Then I should see "Looks like you haven't registered for any courses yet." somewhere in the page
|
||||
Then All dialogs should be closed
|
||||
And I should be on the dashboard page
|
||||
And I should see "Looks like you haven't registered for any courses yet." somewhere in the page
|
||||
|
||||
@@ -5,12 +5,12 @@ Feature: Sign in
|
||||
|
||||
Scenario: Sign up from the homepage
|
||||
Given I visit the homepage
|
||||
When I click the link with the text "Sign Up"
|
||||
When I click the link with the text "Register Now"
|
||||
And I fill in "email" on the registration form with "robot2@edx.org"
|
||||
And I fill in "password" on the registration form with "test"
|
||||
And I fill in "username" on the registration form with "robot2"
|
||||
And I fill in "name" on the registration form with "Robot Two"
|
||||
And I check the checkbox named "terms_of_service"
|
||||
And I check the checkbox named "honor_code"
|
||||
And I press the "Create My Account" button on the registration form
|
||||
And I submit the registration form
|
||||
Then I should see "THANKS FOR REGISTERING!" in the dashboard banner
|
||||
|
||||
@@ -3,17 +3,18 @@
|
||||
|
||||
from lettuce import world, step
|
||||
|
||||
|
||||
@step('I fill in "([^"]*)" on the registration form with "([^"]*)"$')
|
||||
def when_i_fill_in_field_on_the_registration_form_with_value(step, field, value):
|
||||
register_form = world.browser.find_by_css('form#register_form')
|
||||
register_form = world.browser.find_by_css('form#register-form')
|
||||
form_field = register_form.find_by_name(field)
|
||||
form_field.fill(value)
|
||||
|
||||
|
||||
@step('I press the "([^"]*)" button on the registration form$')
|
||||
def i_press_the_button_on_the_registration_form(step, button):
|
||||
register_form = world.browser.find_by_css('form#register_form')
|
||||
register_form.find_by_value(button).click()
|
||||
@step('I submit the registration form$')
|
||||
def i_press_the_button_on_the_registration_form(step):
|
||||
register_form = world.browser.find_by_css('form#register-form')
|
||||
register_form.find_by_name('submit').click()
|
||||
|
||||
|
||||
@step('I check the checkbox named "([^"]*)"$')
|
||||
|
||||
@@ -8,27 +8,27 @@
|
||||
<nav class="nav-colophon">
|
||||
<ol>
|
||||
<li class="nav-colophon-01">
|
||||
<a href="${marketing_link('ABOUT')}">
|
||||
<a id="about" href="${marketing_link('ABOUT')}">
|
||||
About
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-colophon-02">
|
||||
<a href="${marketing_link('JOBS')}">
|
||||
<a id="jobs" href="${marketing_link('JOBS')}">
|
||||
Jobs
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-colophon-03">
|
||||
<a href="${marketing_link('PRESS')}">
|
||||
<a id="press" href="${marketing_link('PRESS')}">
|
||||
Press
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-colophon-04">
|
||||
<a href="${marketing_link('FAQ')}">
|
||||
<a id="faq" href="${marketing_link('FAQ')}">
|
||||
FAQ
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-colophon-05">
|
||||
<a href="${marketing_link('CONTACT')}">
|
||||
<a id="contact" href="${marketing_link('CONTACT')}">
|
||||
Contact
|
||||
</a>
|
||||
</li>
|
||||
|
||||
Reference in New Issue
Block a user