From acc743eea8861b8a5b5cda231d69e5caf61ceb4e Mon Sep 17 00:00:00 2001 From: JonahStanley Date: Wed, 5 Jun 2013 15:08:58 -0400 Subject: [PATCH 1/7] Added functionality to bypass alerts This is done with the following steps: 'I confirm all alerts' means that all alert and confirm windows are returned and returned true respectively 'I dismiss all alerts' means that all confirm windows are returned false 'I answer all prompts with "([^"]*)"' means that all prompts are returned with the given string Please note that these settings are on a PER PAGE basis. This means that for best results, the step must be given right before the alert is generated. --- .../studio-overview-togglesection.feature | 26 +++++++++---------- common/djangoapps/terrain/steps.py | 15 +++++++++++ 2 files changed, 27 insertions(+), 14 deletions(-) diff --git a/cms/djangoapps/contentstore/features/studio-overview-togglesection.feature b/cms/djangoapps/contentstore/features/studio-overview-togglesection.feature index c9f5b43dfbc2..3bdf2633d086 100644 --- a/cms/djangoapps/contentstore/features/studio-overview-togglesection.feature +++ b/cms/djangoapps/contentstore/features/studio-overview-togglesection.feature @@ -5,29 +5,27 @@ Feature: Overview Toggle Section Scenario: The default layout for the overview page is to show sections in expanded view Given I have a course with multiple sections - When I navigate to the course overview page - Then I see the "Collapse All Sections" link - And all sections are expanded + When I navigate to the course overview page + Then I see the "Collapse All Sections" link + And all sections are expanded Scenario: Expand /collapse for a course with no sections Given I have a course with no sections - When I navigate to the course overview page - Then I do not see the "Collapse All Sections" link + When I navigate to the course overview page + Then I do not see the "Collapse All Sections" link Scenario: Collapse link appears after creating first section of a course Given I have a course with no sections - When I navigate to the course overview page - And I add a section - Then I see the "Collapse All Sections" link - And all sections are expanded + When I navigate to the course overview page + And I add a section + Then I see the "Collapse All Sections" link + And all sections are expanded - # Skipped because Ubuntu ChromeDriver hangs on alert - @skip Scenario: Collapse link is not removed after last section of a course is deleted Given I have a course with 1 section - And I navigate to the course overview page - When I press the "section" delete icon - And I confirm the alert + And I navigate to the course overview page + When I confirm all alerts + And I press the "section" delete icon Then I see the "Collapse All Sections" link Scenario: Collapsing all sections when all sections are expanded diff --git a/common/djangoapps/terrain/steps.py b/common/djangoapps/terrain/steps.py index 1d9e59cd7203..2fe9692ae45a 100644 --- a/common/djangoapps/terrain/steps.py +++ b/common/djangoapps/terrain/steps.py @@ -159,3 +159,18 @@ def registered_edx_user(step, uname): @step(u'All dialogs should be closed$') def dialogs_are_closed(step): assert world.dialogs_closed() + + +@step('I confirm all alerts') +def i_confirm_with_ok(step): + world.browser.execute_script('window.confirm = function(){return true;} ; window.alert = function(){return;}') + + +@step('I dismiss all alerts') +def i_dismiss_with_ok(step): + world.browser.execute_script('window.confirm = function(){return false;}') + + +@step('I answer all prompts with "([^"]*)"') +def i_answer_prompts_with(step, prompt): + world.browser.execute_script('window.prompt = function(){return %s;}') % prompt From 0548b119a97b7d0cb63218ecdf35c4776d8c5831 Mon Sep 17 00:00:00 2001 From: JonahStanley Date: Wed, 5 Jun 2013 15:21:23 -0400 Subject: [PATCH 2/7] Fixed other scenarios that were skipped --- cms/djangoapps/contentstore/features/section.feature | 6 ++---- cms/djangoapps/contentstore/features/section.py | 4 ++-- cms/djangoapps/contentstore/features/subsection.feature | 6 ++---- 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/cms/djangoapps/contentstore/features/section.feature b/cms/djangoapps/contentstore/features/section.feature index 236cf501fcbe..c738428a43fa 100644 --- a/cms/djangoapps/contentstore/features/section.feature +++ b/cms/djangoapps/contentstore/features/section.feature @@ -26,11 +26,9 @@ Feature: Create Section And I save a new section release date Then the section release date is updated - # Skipped because Ubuntu ChromeDriver hangs on alert - @skip Scenario: Delete section Given I have opened a new course in Studio And I have added a new section - When I press the "section" delete icon - And I confirm the alert + When I confirm all alerts + And I press the "section" delete icon Then the section does not exist diff --git a/cms/djangoapps/contentstore/features/section.py b/cms/djangoapps/contentstore/features/section.py index 9a896d8ebe2e..4a628ff72b0a 100644 --- a/cms/djangoapps/contentstore/features/section.py +++ b/cms/djangoapps/contentstore/features/section.py @@ -69,8 +69,8 @@ def i_see_complete_section_name_with_quote_in_editor(step): @step('the section does not exist$') def section_does_not_exist(step): - css = 'span.section-name-span' - assert world.browser.is_element_not_present_by_css(css) + css = 'h3[data-name="My Section"]' + assert world.is_css_not_present(css) @step('I see a release date for my section$') diff --git a/cms/djangoapps/contentstore/features/subsection.feature b/cms/djangoapps/contentstore/features/subsection.feature index 8bb12467ff6c..0873a3f4281b 100644 --- a/cms/djangoapps/contentstore/features/subsection.feature +++ b/cms/djangoapps/contentstore/features/subsection.feature @@ -32,12 +32,10 @@ Feature: Create Subsection And I reload the page Then I see the correct dates - # Skipped because Ubuntu ChromeDriver hangs on alert - @skip Scenario: Delete a subsection Given I have opened a new course section in Studio And I have added a new subsection And I see my subsection on the Courseware page - When I press the "subsection" delete icon - And I confirm the alert + When I confirm all alerts + And I press the "subsection" delete icon Then the subsection does not exist From d147103be0d5b02799fbd2a27e8b5ccc55915b27 Mon Sep 17 00:00:00 2001 From: JonahStanley Date: Wed, 5 Jun 2013 15:55:12 -0400 Subject: [PATCH 3/7] Fixed tab issue (tabs are now correctly spaces) --- .../studio-overview-togglesection.feature | 80 +++++++++---------- 1 file changed, 40 insertions(+), 40 deletions(-) diff --git a/cms/djangoapps/contentstore/features/studio-overview-togglesection.feature b/cms/djangoapps/contentstore/features/studio-overview-togglesection.feature index 3bdf2633d086..039faf0dd72b 100644 --- a/cms/djangoapps/contentstore/features/studio-overview-togglesection.feature +++ b/cms/djangoapps/contentstore/features/studio-overview-togglesection.feature @@ -1,59 +1,59 @@ Feature: Overview Toggle Section - In order to quickly view the details of a course's section or to scan the inventory of sections + In order to quickly view the details of a course's section or to scan the inventory of sections As a course author I want to toggle the visibility of each section's subsection details in the overview listing - Scenario: The default layout for the overview page is to show sections in expanded view - Given I have a course with multiple sections + Scenario: The default layout for the overview page is to show sections in expanded view + Given I have a course with multiple sections When I navigate to the course overview page Then I see the "Collapse All Sections" link And all sections are expanded - Scenario: Expand /collapse for a course with no sections - Given I have a course with no sections + Scenario: Expand /collapse for a course with no sections + Given I have a course with no sections When I navigate to the course overview page Then I do not see the "Collapse All Sections" link - Scenario: Collapse link appears after creating first section of a course - Given I have a course with no sections + Scenario: Collapse link appears after creating first section of a course + Given I have a course with no sections When I navigate to the course overview page And I add a section Then I see the "Collapse All Sections" link And all sections are expanded - Scenario: Collapse link is not removed after last section of a course is deleted - Given I have a course with 1 section + Scenario: Collapse link is not removed after last section of a course is deleted + Given I have a course with 1 section And I navigate to the course overview page When I confirm all alerts And I press the "section" delete icon - Then I see the "Collapse All Sections" link - - Scenario: Collapsing all sections when all sections are expanded - Given I navigate to the courseware page of a course with multiple sections - And all sections are expanded - When I click the "Collapse All Sections" link - Then I see the "Expand All Sections" link - And all sections are collapsed - - Scenario: Collapsing all sections when 1 or more sections are already collapsed - Given I navigate to the courseware page of a course with multiple sections - And all sections are expanded - When I collapse the first section - And I click the "Collapse All Sections" link - Then I see the "Expand All Sections" link - And all sections are collapsed - - Scenario: Expanding all sections when all sections are collapsed - Given I navigate to the courseware page of a course with multiple sections - And I click the "Collapse All Sections" link - When I click the "Expand All Sections" link - Then I see the "Collapse All Sections" link - And all sections are expanded - - Scenario: Expanding all sections when 1 or more sections are already expanded - Given I navigate to the courseware page of a course with multiple sections - And I click the "Collapse All Sections" link - When I expand the first section - And I click the "Expand All Sections" link - Then I see the "Collapse All Sections" link - And all sections are expanded + Then I see the "Collapse All Sections" link + + Scenario: Collapsing all sections when all sections are expanded + Given I navigate to the courseware page of a course with multiple sections + And all sections are expanded + When I click the "Collapse All Sections" link + Then I see the "Expand All Sections" link + And all sections are collapsed + + Scenario: Collapsing all sections when 1 or more sections are already collapsed + Given I navigate to the courseware page of a course with multiple sections + And all sections are expanded + When I collapse the first section + And I click the "Collapse All Sections" link + Then I see the "Expand All Sections" link + And all sections are collapsed + + Scenario: Expanding all sections when all sections are collapsed + Given I navigate to the courseware page of a course with multiple sections + And I click the "Collapse All Sections" link + When I click the "Expand All Sections" link + Then I see the "Collapse All Sections" link + And all sections are expanded + + Scenario: Expanding all sections when 1 or more sections are already expanded + Given I navigate to the courseware page of a course with multiple sections + And I click the "Collapse All Sections" link + When I expand the first section + And I click the "Expand All Sections" link + Then I see the "Collapse All Sections" link + And all sections are expanded From 260659cfc6e913e99557d25e225970e52c42af1b Mon Sep 17 00:00:00 2001 From: JonahStanley Date: Wed, 5 Jun 2013 15:56:45 -0400 Subject: [PATCH 4/7] Fixed wording in the step --- common/djangoapps/terrain/steps.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/common/djangoapps/terrain/steps.py b/common/djangoapps/terrain/steps.py index 2fe9692ae45a..ce841cc3d87e 100644 --- a/common/djangoapps/terrain/steps.py +++ b/common/djangoapps/terrain/steps.py @@ -166,9 +166,9 @@ def i_confirm_with_ok(step): world.browser.execute_script('window.confirm = function(){return true;} ; window.alert = function(){return;}') -@step('I dismiss all alerts') +@step('I cancel all alerts') def i_dismiss_with_ok(step): - world.browser.execute_script('window.confirm = function(){return false;}') + world.browser.execute_script('window.confirm = function(){return false;} ; window.alert = function(){return;}') @step('I answer all prompts with "([^"]*)"') From f652a5d8c4df3eb25cd06f75101ddf543a996872 Mon Sep 17 00:00:00 2001 From: JonahStanley Date: Wed, 5 Jun 2013 15:57:42 -0400 Subject: [PATCH 5/7] Small wording fix --- common/djangoapps/terrain/steps.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/common/djangoapps/terrain/steps.py b/common/djangoapps/terrain/steps.py index ce841cc3d87e..78d9665cfd73 100644 --- a/common/djangoapps/terrain/steps.py +++ b/common/djangoapps/terrain/steps.py @@ -162,12 +162,12 @@ def dialogs_are_closed(step): @step('I confirm all alerts') -def i_confirm_with_ok(step): +def i_confirm_all_alerts(step): world.browser.execute_script('window.confirm = function(){return true;} ; window.alert = function(){return;}') @step('I cancel all alerts') -def i_dismiss_with_ok(step): +def i_cancel_all_alerts(step): world.browser.execute_script('window.confirm = function(){return false;} ; window.alert = function(){return;}') From d226a21eb0508cded67c87cb4e285efed929df52 Mon Sep 17 00:00:00 2001 From: JonahStanley Date: Wed, 5 Jun 2013 16:01:45 -0400 Subject: [PATCH 6/7] Changed wording to I will --- cms/djangoapps/contentstore/features/section.feature | 2 +- .../features/studio-overview-togglesection.feature | 2 +- cms/djangoapps/contentstore/features/subsection.feature | 2 +- common/djangoapps/terrain/steps.py | 6 +++--- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/cms/djangoapps/contentstore/features/section.feature b/cms/djangoapps/contentstore/features/section.feature index c738428a43fa..80ccb6cc7a93 100644 --- a/cms/djangoapps/contentstore/features/section.feature +++ b/cms/djangoapps/contentstore/features/section.feature @@ -29,6 +29,6 @@ Feature: Create Section Scenario: Delete section Given I have opened a new course in Studio And I have added a new section - When I confirm all alerts + When I will confirm all alerts And I press the "section" delete icon Then the section does not exist diff --git a/cms/djangoapps/contentstore/features/studio-overview-togglesection.feature b/cms/djangoapps/contentstore/features/studio-overview-togglesection.feature index 039faf0dd72b..e746f3629a85 100644 --- a/cms/djangoapps/contentstore/features/studio-overview-togglesection.feature +++ b/cms/djangoapps/contentstore/features/studio-overview-togglesection.feature @@ -24,7 +24,7 @@ Feature: Overview Toggle Section Scenario: Collapse link is not removed after last section of a course is deleted Given I have a course with 1 section And I navigate to the course overview page - When I confirm all alerts + When I will confirm all alerts And I press the "section" delete icon Then I see the "Collapse All Sections" link diff --git a/cms/djangoapps/contentstore/features/subsection.feature b/cms/djangoapps/contentstore/features/subsection.feature index 0873a3f4281b..a11467e3f92e 100644 --- a/cms/djangoapps/contentstore/features/subsection.feature +++ b/cms/djangoapps/contentstore/features/subsection.feature @@ -36,6 +36,6 @@ Feature: Create Subsection Given I have opened a new course section in Studio And I have added a new subsection And I see my subsection on the Courseware page - When I confirm all alerts + When I will confirm all alerts And I press the "subsection" delete icon Then the subsection does not exist diff --git a/common/djangoapps/terrain/steps.py b/common/djangoapps/terrain/steps.py index 78d9665cfd73..c126cae0adbe 100644 --- a/common/djangoapps/terrain/steps.py +++ b/common/djangoapps/terrain/steps.py @@ -161,16 +161,16 @@ def dialogs_are_closed(step): assert world.dialogs_closed() -@step('I confirm all alerts') +@step('I will confirm all alerts') def i_confirm_all_alerts(step): world.browser.execute_script('window.confirm = function(){return true;} ; window.alert = function(){return;}') -@step('I cancel all alerts') +@step('I will cancel all alerts') def i_cancel_all_alerts(step): world.browser.execute_script('window.confirm = function(){return false;} ; window.alert = function(){return;}') -@step('I answer all prompts with "([^"]*)"') +@step('I will answer all prompts with "([^"]*)"') def i_answer_prompts_with(step, prompt): world.browser.execute_script('window.prompt = function(){return %s;}') % prompt From 477f29d5ee4248efb49e3e208e6b227da8259dfe Mon Sep 17 00:00:00 2001 From: JonahStanley Date: Thu, 6 Jun 2013 14:52:35 -0400 Subject: [PATCH 7/7] Added docstring specifying when this method must be called --- common/djangoapps/terrain/steps.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/common/djangoapps/terrain/steps.py b/common/djangoapps/terrain/steps.py index c126cae0adbe..6e512982b7a1 100644 --- a/common/djangoapps/terrain/steps.py +++ b/common/djangoapps/terrain/steps.py @@ -163,14 +163,29 @@ def dialogs_are_closed(step): @step('I will confirm all alerts') def i_confirm_all_alerts(step): + """ + Please note: This method must be called RIGHT BEFORE an expected alert + Window variables are page local and thus all changes are removed upon navigating to a new page + In addition, this method changes the functionality of ONLY future alerts + """ world.browser.execute_script('window.confirm = function(){return true;} ; window.alert = function(){return;}') @step('I will cancel all alerts') def i_cancel_all_alerts(step): + """ + Please note: This method must be called RIGHT BEFORE an expected alert + Window variables are page local and thus all changes are removed upon navigating to a new page + In addition, this method changes the functionality of ONLY future alerts + """ world.browser.execute_script('window.confirm = function(){return false;} ; window.alert = function(){return;}') @step('I will answer all prompts with "([^"]*)"') def i_answer_prompts_with(step, prompt): + """ + Please note: This method must be called RIGHT BEFORE an expected alert + Window variables are page local and thus all changes are removed upon navigating to a new page + In addition, this method changes the functionality of ONLY future alerts + """ world.browser.execute_script('window.prompt = function(){return %s;}') % prompt