From 3c5ea89b898a05194da6364ca27fbdd2cd60ce00 Mon Sep 17 00:00:00 2001 From: David Mirabile Date: Fri, 4 Aug 2017 12:40:08 -0600 Subject: [PATCH] spec: add additional specs to the planner specs update: code review update: add a force click function to the code update: update the comments on the force click function Change-Id: I6a7b2a631a6039cf86d721310038a76a2e72c17f Reviewed-on: https://gerrit.instructure.com/121602 Tested-by: Jenkins Reviewed-by: Jon Jensen Product-Review: Jon Jensen QA-Review: Jon Jensen --- .../student_planner_page_object_model.rb | 3 +++ spec/selenium/Falcor/student_planner_spec.rb | 17 +++++++------ .../custom_selenium_actions.rb | 25 +++++++++++++++++++ 3 files changed, 37 insertions(+), 8 deletions(-) diff --git a/spec/selenium/Falcor/student_planner_page_object_model.rb b/spec/selenium/Falcor/student_planner_page_object_model.rb index 01a5d27d830..deae9ecd1c5 100644 --- a/spec/selenium/Falcor/student_planner_page_object_model.rb +++ b/spec/selenium/Falcor/student_planner_page_object_model.rb @@ -70,6 +70,7 @@ module PlannerPageObject get '/' click_dashboard_settings select_list_view + wait_for_planner_load end def validate_link_to_url(object, url_type) # should pass the type of object as a string @@ -90,6 +91,8 @@ module PlannerPageObject end def wait_for_planner_load + wait_for_dom_ready + wait_for_ajaximations todo_modal_button end diff --git a/spec/selenium/Falcor/student_planner_spec.rb b/spec/selenium/Falcor/student_planner_spec.rb index 334c9ea1f80..0505a2454ac 100644 --- a/spec/selenium/Falcor/student_planner_spec.rb +++ b/spec/selenium/Falcor/student_planner_spec.rb @@ -69,7 +69,6 @@ describe "student planner" do it "shows submitted tag for assignments that have submissions", priority: "1", test_id: 3263151 do @assignment.submit_homework(@student1, submission_type: "online_text_entry", body: "Assignment submitted") go_to_list_view - wait_for_planner_load # Student planner shows submitted assignments as completed. Expand to see the assignment expand_completed_item @@ -96,6 +95,15 @@ describe "student planner" do scroll_to(f('.PlannerApp').find_element(:xpath, "//span[text()[contains(.,'Unnamed Course Assignment')]]")) validate_pill('Missing') end + + it "can follow course link to course", priority: "1", test_id: 3306198 do + go_to_list_view + element = fln(@course[:name].upcase, f('.PlannerApp')) + expect_new_page_load do + element.click + end + expect(driver).not_to contain_css('.StudentPlanner__Container') + end end context "Graded discussion" do @@ -139,7 +147,6 @@ describe "student planner" do it "shows and navigates to quizzes page from student planner", priority: "1", test_id: 3259303 do go_to_list_view - wait_for_planner_load validate_object_displayed('Quiz') validate_link_to_url(@quiz, 'quizzes') end @@ -147,7 +154,6 @@ describe "student planner" do it "shows and navigates to graded surveys with due dates", priority: "1", test_id: 3282673 do @quiz.update(quiz_type: "graded_survey") go_to_list_view - wait_for_planner_load validate_object_displayed('Quiz') validate_link_to_url(@quiz, 'quizzes') end @@ -155,7 +161,6 @@ describe "student planner" do it "shows and navigates to ungraded surveys with due dates", priority: "1", test_id: 3282674 do @quiz.update(quiz_type: "survey") go_to_list_view - wait_for_planner_load validate_object_displayed('Quiz') validate_link_to_url(@quiz, 'quizzes') end @@ -163,7 +168,6 @@ describe "student planner" do it "shows and navigates to practice quizzes with due dates", priority: "1", test_id: 3284242 do @quiz.update(quiz_type: "practice_quiz") go_to_list_view - wait_for_planner_load validate_object_displayed('Quiz') validate_link_to_url(@quiz, 'quizzes') end @@ -242,7 +246,6 @@ describe "student planner" do it "edits a To Do", priority: "1", test_id: 3281714 do @student1.planner_notes.create!(todo_date: 2.days.from_now, title: "Title Text") go_to_list_view - # Opens the To Do edit sidebar todo_item = todo_info_holder expect(todo_item).to include_text("To Do") @@ -266,7 +269,6 @@ describe "student planner" do it "deletes a To Do", priority: "1", test_id: 3281715 do @student1.planner_notes.create!(todo_date: 2.days.from_now, title: "Title Text") go_to_list_view - expect(f('body')).not_to contain_jqcss("h2:contains('No Due Dates Assigned')") todo_item = todo_info_holder expect(todo_item).to include_text("To Do") @@ -349,7 +351,6 @@ describe "student planner" do it "loads more items at the bottom of the page", priority: "1", test_id: 3263149 do go_to_list_view - wait_for_planner_load current_last_item = items_displayed.last current_items = items_displayed.count scroll_to(current_last_item) diff --git a/spec/selenium/test_setup/common_helper_methods/custom_selenium_actions.rb b/spec/selenium/test_setup/common_helper_methods/custom_selenium_actions.rb index fd2b307074d..dbb8cf7e185 100644 --- a/spec/selenium/test_setup/common_helper_methods/custom_selenium_actions.rb +++ b/spec/selenium/test_setup/common_helper_methods/custom_selenium_actions.rb @@ -255,6 +255,31 @@ module CustomSeleniumActions end end + # This function is to be used as a last resort ONLY + # Make sure that you have tried: + # 1.) finding and clicking the element with f, fj, and fln statements. + # 2.) attempts to wait + # 3.) attempt to click blocking items by finding them instead + # 4.) attempts to find and click blocking items with xpath + # + # This function is to be used if: + # 1.) the above are still fragile + # 2.) clicking an item works intermittently + # 3.) an item is not covered (as this should cause a failure) + # 4.) an item is UNIQUE ON THE PAGE. + # + # If this function is used: + # 1.) make sure your jquery selector always finds ONLY THE ELEMENT YOU WANT + # 1a.) attempting to click a non-unique element may remain fragile. + # + # 2.) This function will click items that are not visible or covered. + # + # 3.) This function will likely have trouble clicking links. Use fln instead. + def force_click(element_jquery_finder) + fj(element_jquery_finder) + driver.execute_script(%{$(#{element_jquery_finder.to_s.to_json}).click()}) + end + def hover(element) element.with_stale_element_protection do driver.action.move_to(element).perform