diff --git a/common/djangoapps/mitxmako/tests.py b/common/djangoapps/mitxmako/tests.py new file mode 100644 index 0000000000..a1a4fa4582 --- /dev/null +++ b/common/djangoapps/mitxmako/tests.py @@ -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) diff --git a/common/djangoapps/terrain/steps.py b/common/djangoapps/terrain/steps.py index fdab514177..d2be2eeea8 100644 --- a/common/djangoapps/terrain/steps.py +++ b/common/djangoapps/terrain/steps.py @@ -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() diff --git a/common/djangoapps/terrain/ui_helpers.py b/common/djangoapps/terrain/ui_helpers.py index 1a85904135..40b839ae24 100644 --- a/common/djangoapps/terrain/ui_helpers.py +++ b/common/djangoapps/terrain/ui_helpers.py @@ -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() diff --git a/lms/djangoapps/courseware/features/homepage.feature b/lms/djangoapps/courseware/features/homepage.feature index c0c1c32f02..2c354acd49 100644 --- a/lms/djangoapps/courseware/features/homepage.feature +++ b/lms/djangoapps/courseware/features/homepage.feature @@ -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 "" - When I click the link with the text "" - Then I should see that the path is "" + Then I should see a link with the id "" called "" 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 diff --git a/lms/djangoapps/courseware/features/login.feature b/lms/djangoapps/courseware/features/login.feature index 23317b4876..a1b788a7b2 100644 --- a/lms/djangoapps/courseware/features/login.feature +++ b/lms/djangoapps/courseware/features/login.feature @@ -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 "/" diff --git a/lms/djangoapps/courseware/features/login.py b/lms/djangoapps/courseware/features/login.py index bc90ea301c..857b70fa5d 100644 --- a/lms/djangoapps/courseware/features/login.py +++ b/lms/djangoapps/courseware/features/login.py @@ -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) diff --git a/lms/djangoapps/courseware/features/registration.feature b/lms/djangoapps/courseware/features/registration.feature index 5933f860bb..43b04a5ad0 100644 --- a/lms/djangoapps/courseware/features/registration.feature +++ b/lms/djangoapps/courseware/features/registration.feature @@ -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 diff --git a/lms/djangoapps/courseware/features/signup.feature b/lms/djangoapps/courseware/features/signup.feature index b28a6819a1..cfc8b6e924 100644 --- a/lms/djangoapps/courseware/features/signup.feature +++ b/lms/djangoapps/courseware/features/signup.feature @@ -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 diff --git a/lms/djangoapps/courseware/features/signup.py b/lms/djangoapps/courseware/features/signup.py index 5ba385ef54..3dc34d5af8 100644 --- a/lms/djangoapps/courseware/features/signup.py +++ b/lms/djangoapps/courseware/features/signup.py @@ -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 "([^"]*)"$') diff --git a/lms/templates/footer.html b/lms/templates/footer.html index 3fa956c704..daad0a2457 100644 --- a/lms/templates/footer.html +++ b/lms/templates/footer.html @@ -8,27 +8,27 @@