From 944db88b65987571dbbfa2038c5cb25682dcdff2 Mon Sep 17 00:00:00 2001 From: Robert Lamb Date: Tue, 15 Mar 2016 13:18:06 -0600 Subject: [PATCH] spec: create generic pick_test_id and pick_priority For use with shared examples. Created generic pick_test_id method in a helper file Switched all calls to pick_test_id to use the generic method removed unused shared_context call Change-Id: Ib54eb41ca2b237bc4580e113d9083c3361ea5af2 Reviewed-on: https://gerrit.instructure.com/74559 Reviewed-by: Deepeeca Soundarrajan Tested-by: Jenkins Product-Review: Robert Lamb QA-Review: Robert Lamb --- .../admin/account_admin_settings_spec.rb | 4 +- .../admin/sub_accounts/settings_spec.rb | 8 +- spec/selenium/gradebook_student_common.rb | 95 +++++++------------ spec/selenium/gradebook_student_spec.rb | 10 +- spec/selenium/groups_pages_student_spec.rb | 18 ++-- spec/selenium/groups_pages_teacher_spec.rb | 14 +-- spec/selenium/helpers/basic/settings_specs.rb | 24 ++--- .../helpers/groups_shared_examples.rb | 73 +++++--------- .../helpers/shared_examples_common.rb | 36 +++++++ spec/selenium/offline_contents_common.rb | 43 ++++----- spec/selenium/offline_contents_spec.rb | 12 +-- spec/selenium/profile_admin_spec.rb | 11 ++- spec/selenium/profile_common.rb | 53 +++-------- spec/selenium/profile_student_spec.rb | 13 +-- spec/selenium/profile_teacher_spec.rb | 13 +-- 15 files changed, 195 insertions(+), 232 deletions(-) create mode 100644 spec/selenium/helpers/shared_examples_common.rb diff --git a/spec/selenium/admin/account_admin_settings_spec.rb b/spec/selenium/admin/account_admin_settings_spec.rb index 26746586dce..a26cf3d0a48 100644 --- a/spec/selenium/admin/account_admin_settings_spec.rb +++ b/spec/selenium/admin/account_admin_settings_spec.rb @@ -5,7 +5,7 @@ describe "root account basic settings" do let(:account) { Account.default } let(:account_settings_url) { "/accounts/#{account.id}/settings" } let(:admin_tab_url) { "/accounts/#{account.id}/settings#tab-users" } - include_examples "settings basic tests", false + include_examples "settings basic tests", :root_account it "should change the default user quota", priority: "1", test_id: 250002 do course_with_admin_logged_in @@ -54,4 +54,4 @@ describe "root account basic settings" do account.reload expect(account.settings[:ip_filters]).to be_blank end -end \ No newline at end of file +end diff --git a/spec/selenium/admin/sub_accounts/settings_spec.rb b/spec/selenium/admin/sub_accounts/settings_spec.rb index 4f576d68edd..f6506d685be 100644 --- a/spec/selenium/admin/sub_accounts/settings_spec.rb +++ b/spec/selenium/admin/sub_accounts/settings_spec.rb @@ -5,7 +5,7 @@ describe "sub account basic settings" do let(:account) { Account.create(name: 'sub account from default account', parent_account: Account.default) } let(:account_settings_url) { "/accounts/#{account.id}/settings" } let(:admin_tab_url) { "/accounts/#{account.id}/settings#tab-users" } - include_examples "settings basic tests", true + include_examples "settings basic tests", :sub_account it "should disable inherited settings if locked by a parent account", priority: "1", test_id: 250007 do parent = Account.default @@ -15,11 +15,11 @@ describe "sub account basic settings" do get account_settings_url expect(f('#account_settings_restrict_student_past_view_value').attribute('disabled')).to be_nil - expect(f('#account_settings_restrict_student_past_view_locked')).to_not be_nil + expect(f('#account_settings_restrict_student_past_view_locked')).not_to be_nil - expect(f('#account_settings_restrict_student_future_view_value').attribute('disabled')).to_not be_nil + expect(f('#account_settings_restrict_student_future_view_value').attribute('disabled')).not_to be_nil expect(f('#account_settings_restrict_student_future_view_locked')).to be_nil # don't even show the locked checkbox expect(is_checked('#account_settings_restrict_student_future_view_value')).to be_truthy end -end \ No newline at end of file +end diff --git a/spec/selenium/gradebook_student_common.rb b/spec/selenium/gradebook_student_common.rb index be8499ae4d8..6a5d1698463 100644 --- a/spec/selenium/gradebook_student_common.rb +++ b/spec/selenium/gradebook_student_common.rb @@ -1,4 +1,6 @@ -require File.expand_path(File.dirname(__FILE__) + '/common') +require_relative 'common' +require_relative 'helpers/shared_examples_common' +include SharedExamplesCommon shared_examples 'Arrange By dropdown' do |context| before :each do @@ -11,7 +13,7 @@ shared_examples 'Arrange By dropdown' do |context| let(:module_order) {[@quiz.title, @assignment0.title, @assignment1.title, @discussion.title]} let(:assign_group_order) {[@assignment0.title, @discussion.title, @quiz.title, @assignment1.title]} - it 'should persist', test_id: pick_test_id(context, "591860", "592108", "592119", "592130"), priority: pick_priority(context, "1", "2") do + it 'should persist', test_id: pick_test_id(context, student: "591860", teacher: "592108", admin: "592119", ta: "592130"), priority: pick_priority(context, student: "1", teacher: "1", admin: "2", ta: "2") do click_option('#assignment_order', 'Title') get "/courses/#{@course.id}" get "/courses/#{@course.id}/grades/#{@student.id}" @@ -22,11 +24,11 @@ shared_examples 'Arrange By dropdown' do |context| end end - it 'should exist with one course', test_id: pick_test_id(context, "591850", "592109", "592120", "592131"), priority: pick_priority(context, "1", "2") do + it 'should exist with one course', test_id: pick_test_id(context, student: "591850", teacher: "592109", admin: "592120", ta: "592131"), priority: pick_priority(context, student: "1", teacher: "1", admin: "2", ta: "2") do expect(f('#assignment_order')).to be_present end - it 'should exist with more than one course', test_id: pick_test_id(context, "591851", "592110", "592121", "592132"), priority: pick_priority(context, "1", "2") do + it 'should exist with more than one course', test_id: pick_test_id(context, student: "591851", teacher: "592110", admin: "592121", ta: "592132"), priority: pick_priority(context, student: "1", teacher: "1", admin: "2", ta: "2") do course2 = Course.create!(name: 'Second Course') course2.offer! course2.enroll_student(@student).accept! @@ -36,27 +38,27 @@ shared_examples 'Arrange By dropdown' do |context| expect(f('#assignment_order')).to be_present end - it 'should contain Title', test_id: pick_test_id(context, "591852", "592111", "592122", "592133"), priority: pick_priority(context, "1", "2") do + it 'should contain Title', test_id: pick_test_id(context, student: "591852", teacher: "592111", admin: "592122", ta: "592133"), priority: pick_priority(context, student: "1", teacher: "1", admin: "2", ta: "2") do f('#assignment_order').click expect(f("#assignment_order option[value=\"title\"]")).to be_present end - it 'should contain Due Date', test_id: pick_test_id(context, "591853", "592112", "592123", "592134"), priority: pick_priority(context, "1", "2") do + it 'should contain Due Date', test_id: pick_test_id(context, student: "591853", teacher: "592112", admin: "592123", ta: "592134"), priority: pick_priority(context, student: "1", teacher: "1", admin: "2", ta: "2") do f('#assignment_order').click expect(f("#assignment_order option[value=\"due_at\"]")).to be_present end - it 'should contain Module', test_id: pick_test_id(context, "591854", "592113", "592124", "592135"), priority: pick_priority(context, "1", "2") do + it 'should contain Module', test_id: pick_test_id(context, student: "591854", teacher: "592113", admin: "592124", ta: "592135"), priority: pick_priority(context, student: "1", teacher: "1", admin: "2", ta: "2") do f('#assignment_order').click expect(f("#assignment_order option[value=\"module\"]")).to be_present end - it 'should contain Assignment Group', test_id: pick_test_id(context, "591855", "592114", "592125", "592136"), priority: pick_priority(context, "1", "2") do + it 'should contain Assignment Group', test_id: pick_test_id(context, student: "591855", teacher: "592114", admin: "592125", ta: "592136"), priority: pick_priority(context, student: "1", teacher: "1", admin: "2", ta: "2") do f('#assignment_order').click expect(f("#assignment_order option[value=\"assignment_group\"]")).to be_present end - it 'should sort by Title', test_id: pick_test_id(context, "591856", "592115", "592126", "592137"), priority: pick_priority(context, "1", "2") do + it 'should sort by Title', test_id: pick_test_id(context, student: "591856", teacher: "592115", admin: "592126", ta: "592137"), priority: pick_priority(context, student: "1", teacher: "1", admin: "2", ta: "2") do click_option('#assignment_order', 'Title') table_rows = ff('#grades_summary tr') @@ -65,7 +67,7 @@ shared_examples 'Arrange By dropdown' do |context| end end - it 'should sort by Due Date', test_id: pick_test_id(context, "591857", "592116", "592127", "592138"), priority: pick_priority(context, "1", "2") do + it 'should sort by Due Date', test_id: pick_test_id(context, student: "591857", teacher: "592116", admin: "592127", ta: "592138"), priority: pick_priority(context, student: "1", teacher: "1", admin: "2", ta: "2") do click_option('#assignment_order', 'Due Date') table_rows = ff('#grades_summary tr') @@ -74,7 +76,7 @@ shared_examples 'Arrange By dropdown' do |context| end end - it 'should sort by Module', test_id: pick_test_id(context, "591858", "592117", "592128", "592139"), priority: pick_priority(context, "1", "2") do + it 'should sort by Module', test_id: pick_test_id(context, student: "591858", teacher: "592117", admin: "592128", ta: "592139"), priority: pick_priority(context, student: "1", teacher: "1", admin: "2", ta: "2") do click_option('#assignment_order', 'Module') table_rows = ff('#grades_summary tr') @@ -83,7 +85,7 @@ shared_examples 'Arrange By dropdown' do |context| end end - it 'should sort by Assignment Group', test_id: pick_test_id(context, "591859", "591859", "592129", "592140"), priority: pick_priority(context, "1", "2") do + it 'should sort by Assignment Group', test_id: pick_test_id(context, student: "591859", teacher: "592118", admin: "592129", ta: "592140"), priority: pick_priority(context, student: "1", teacher: "1", admin: "2", ta: "2") do click_option('#assignment_order', 'Assignment Group') table_rows = ff('#grades_summary tr') @@ -91,53 +93,28 @@ shared_examples 'Arrange By dropdown' do |context| expect(table_rows[3 * index + 1].find_element(:css, 'th').text).to eq assign_name end end -end -def pick_test_id(context, id1, id2, id3, id4) - case context - when 'student' - id1 - when 'teacher' - id2 - when 'admin' - id3 - when 'ta' - id4 - else - raise('Error: Invalid context') - end -end - -def pick_priority(context, pri1, pri2) - case context - when 'student', 'teacher' - pri1 - when 'admin', 'ta' - pri2 - else - raise('Error: Invalid context') - end -end - -def enroll_context(context) - case context - when 'student' - user_session(@student) - - when 'teacher' - @teacher = User.create!(name: "Teacher") - @course.enroll_teacher(@teacher).accept! - user_session(@teacher) - - when 'admin' - admin_logged_in - - when 'ta' - @ta = User.create!(name: "TA") - @course.enroll_ta(@ta).accept! - user_session(@ta) - - else - raise('Error: Invalid context') + def enroll_context(context) + case context + when :student + user_session(@student) + + when :teacher + @teacher = User.create!(name: "Teacher") + @course.enroll_teacher(@teacher).accept! + user_session(@teacher) + + when :admin + admin_logged_in + + when :ta + @ta = User.create!(name: "TA") + @course.enroll_ta(@ta).accept! + user_session(@ta) + + else + raise('Error: Invalid context') + end end end + diff --git a/spec/selenium/gradebook_student_spec.rb b/spec/selenium/gradebook_student_spec.rb index cbbc7b469ce..69ef7a3d6f2 100644 --- a/spec/selenium/gradebook_student_spec.rb +++ b/spec/selenium/gradebook_student_spec.rb @@ -58,7 +58,7 @@ describe 'Student Gradebook' do [course1, course2, course3].each do |course| enrollment = ObserverEnrollment.new(user: observer, - course: course, + course: course, workflow_state: 'active') enrollment.associated_user_id = student @@ -252,19 +252,19 @@ describe 'Student Gradebook' do end context "as a student" do - it_behaves_like 'Arrange By dropdown', 'student' + it_behaves_like 'Arrange By dropdown', :student end context "as a teacher" do - it_behaves_like 'Arrange By dropdown', 'teacher' + it_behaves_like 'Arrange By dropdown', :teacher end context "as an admin" do - it_behaves_like 'Arrange By dropdown', 'admin' + it_behaves_like 'Arrange By dropdown', :admin end context "as a ta" do - it_behaves_like 'Arrange By dropdown', 'ta' + it_behaves_like 'Arrange By dropdown', :ta end end end diff --git a/spec/selenium/groups_pages_student_spec.rb b/spec/selenium/groups_pages_student_spec.rb index 036f96a4906..51229b56164 100644 --- a/spec/selenium/groups_pages_student_spec.rb +++ b/spec/selenium/groups_pages_student_spec.rb @@ -32,7 +32,7 @@ describe "groups" do #------------------------------------------------------------------------------------------------------------------- describe "home page" do - it_behaves_like 'home_page', 'student' + it_behaves_like 'home_page', :student it "should only allow group members to access the group home page", priority: "1", test_id: 319908 do get url @@ -43,7 +43,7 @@ describe "groups" do #------------------------------------------------------------------------------------------------------------------- describe "announcements page" do - it_behaves_like 'announcements_page', 'student' + it_behaves_like 'announcements_page', :student it "should allow group members to delete their own announcements", priority: "1", test_id: 326521 do create_group_announcement_manually("Announcement by #{@students.first.name}",'yo ho, yo ho') @@ -75,7 +75,7 @@ describe "groups" do wait_for_ajaximations get announcements_page expect(ff('.discussion-topic').size).to eq 1 - expect(fj('.discussion-summary').text).to include_text('Rey is Yodas daughter ') + expect(f('.discussion-summary').text).to include_text('Rey is Yodas daughter ') end it "should not allow group members to edit someone else's announcement", priority: "1", test_id: 327111 do @@ -105,7 +105,7 @@ describe "groups" do #------------------------------------------------------------------------------------------------------------------- describe "people page" do - it_behaves_like 'people_page', 'student' + it_behaves_like 'people_page', :student it "should display and show a list of group members", priority: "1", test_id: 273614 do get people_page @@ -123,7 +123,7 @@ describe "groups" do #------------------------------------------------------------------------------------------------------------------- describe "discussions page" do - it_behaves_like 'discussions_page', 'student' + it_behaves_like 'discussions_page', :student it "should allow discussions to be created within a group", priority: "1", test_id: 273615 do get discussions_page @@ -186,7 +186,7 @@ describe "groups" do type_in_tiny('textarea[name=message]','The slopes are ready,') f('.btn-primary').click wait_for_ajaximations - expect(fj('.user_content').text).to include_text('The slopes are ready,') + expect(f('.user_content').text).to include_text('The slopes are ready,') end it "should not allow group member to edit discussions by other creators", priority: "1", test_id: 323327 do @@ -203,7 +203,7 @@ describe "groups" do #------------------------------------------------------------------------------------------------------------------- describe "pages page" do - it_behaves_like 'pages_page', 'student' + it_behaves_like 'pages_page', :student it "should allow group members to create a page", priority: "1", test_id: 273611 do get pages_page @@ -228,7 +228,7 @@ describe "groups" do #------------------------------------------------------------------------------------------------------------------- describe "Files page" do - it_behaves_like 'files_page', 'student' + it_behaves_like 'files_page', :student it "should allow group members to add a new folder", priority: "1", test_id: 273625 do get files_page @@ -295,7 +295,7 @@ describe "groups" do PluginSetting.create!(name: "wimba", settings: {"domain" => "wimba.instructure.com"}) end - it_behaves_like 'conferences_page', 'student' + it_behaves_like 'conferences_page', :student it "should allow access to conferences only within the scope of a group", priority: "1", test_id: 273638 do get conferences_page diff --git a/spec/selenium/groups_pages_teacher_spec.rb b/spec/selenium/groups_pages_teacher_spec.rb index ccda82b568d..f2f3dd515a3 100644 --- a/spec/selenium/groups_pages_teacher_spec.rb +++ b/spec/selenium/groups_pages_teacher_spec.rb @@ -30,12 +30,12 @@ describe "groups" do #------------------------------------------------------------------------------------------------------------------- describe "home page" do - it_behaves_like 'home_page', 'teacher' + it_behaves_like 'home_page', :teacher end #------------------------------------------------------------------------------------------------------------------- describe "announcements page" do - it_behaves_like 'announcements_page', 'teacher' + it_behaves_like 'announcements_page', :teacher it "should allow teachers to see announcements", priority: "1", test_id: 287049 do @announcement = @testgroup.first.announcements.create!(title: 'Group Announcement', message: 'Group',user: @students.first) @@ -80,7 +80,7 @@ describe "groups" do #------------------------------------------------------------------------------------------------------------------- describe "people page" do - it_behaves_like 'people_page', 'teacher' + it_behaves_like 'people_page', :teacher it "should display and show a list of group members", priority: "2", test_id: 324929 do get people_page @@ -92,7 +92,7 @@ describe "groups" do #------------------------------------------------------------------------------------------------------------------- describe "discussions page" do - it_behaves_like 'discussions_page', 'teacher' + it_behaves_like 'discussions_page', :teacher it "should allow teachers to create discussions within a group", priority: "1", test_id: 285586 do get discussions_page @@ -133,7 +133,7 @@ describe "groups" do #------------------------------------------------------------------------------------------------------------------- describe "pages page" do - it_behaves_like 'pages_page', 'teacher' + it_behaves_like 'pages_page', :teacher it "should allow teachers to create a page", priority: "1", test_id: 289993 do get pages_page @@ -149,7 +149,7 @@ describe "groups" do #------------------------------------------------------------------------------------------------------------------- describe "Files page" do - it_behaves_like 'files_page', 'teacher' + it_behaves_like 'files_page', :teacher it "should allow teacher to add a new folder", priority: "2", test_id: 303703 do get files_page @@ -208,7 +208,7 @@ describe "groups" do PluginSetting.create!(name: "wimba", settings: {"domain" => "wimba.instructure.com"}) end - it_behaves_like 'conferences_page', 'teacher' + it_behaves_like 'conferences_page', :teacher end end end diff --git a/spec/selenium/helpers/basic/settings_specs.rb b/spec/selenium/helpers/basic/settings_specs.rb index 4d93b7d0835..52c9af786a0 100644 --- a/spec/selenium/helpers/basic/settings_specs.rb +++ b/spec/selenium/helpers/basic/settings_specs.rb @@ -1,4 +1,7 @@ -shared_examples_for "settings basic tests" do |is_sub_account| +require_relative '../shared_examples_common' +include SharedExamplesCommon + +shared_examples_for "settings basic tests" do |account_type| include_context "in-process server selenium tests" before(:each) do @@ -29,11 +32,11 @@ shared_examples_for "settings basic tests" do |is_sub_account| f("#tab-users-link").click end - it "should add an account admin", priority: "1", test_id: pick_test_id(is_sub_account, 249780, 251030) do + it "should add an account admin", priority: "1", test_id: pick_test_id(account_type, sub_account: 249780, root_account: 251030) do add_account_admin end - it "should delete an account admin", priority: "1", test_id: pick_test_id(is_sub_account, 249781, 251031) do + it "should delete an account admin", priority: "1", test_id: pick_test_id(account_type, sub_account: 249781, root_account: 251031) do admin_id = add_account_admin f("#enrollment_#{admin_id} .remove_account_user_link").click driver.switch_to.alert.accept @@ -54,7 +57,7 @@ shared_examples_for "settings basic tests" do |is_sub_account| get account_settings_url end - it "should change the account name", priority: "1", test_id: pick_test_id(is_sub_account, 249782, 251032) do + it "should change the account name", priority: "1", test_id: pick_test_id(account_type, sub_account: 249782, root_account: 251032) do new_account_name = 'new default account name' replace_content(f("#account_name"), new_account_name) click_submit @@ -63,7 +66,7 @@ shared_examples_for "settings basic tests" do |is_sub_account| expect(f("#account_name")).to have_value(new_account_name) end - it "should change the default quotas", priority: "1", test_id: pick_test_id(is_sub_account, 250003, 251033) do + it "should change the default quotas", priority: "1", test_id: pick_test_id(account_type, sub_account: 250003, root_account: 251033) do f('#tab-quotas-link').click # update the quotas @@ -87,7 +90,7 @@ shared_examples_for "settings basic tests" do |is_sub_account| account.reload expect(account.default_storage_quota_mb).to eq course_quota expect(account.default_storage_quota).to eq course_quota * 1048576 - account.default_group_storage_quota_mb == group_quota + expect(account.default_group_storage_quota_mb).to eq group_quota expect(account.default_group_storage_quota).to eq group_quota * 1048576 # ensure the new value is reflected after a refresh @@ -96,7 +99,7 @@ shared_examples_for "settings basic tests" do |is_sub_account| expect(fj('[name="default_group_storage_quota_mb"]')).to have_value(group_quota.to_s) # fj to avoid selenium caching end - it "should manually change a course quota", priority: "1", test_id: pick_test_id(is_sub_account, 250004, 251034) do + it "should manually change a course quota", priority: "1", test_id: pick_test_id(account_type, sub_account: 250004, root_account: 251034) do f('#tab-quotas-link').click # find the course by id @@ -123,7 +126,7 @@ shared_examples_for "settings basic tests" do |is_sub_account| expect(@course.storage_quota_mb).to eq 42 end - it "should manually change a group quota", priority: "1", test_id: pick_test_id(is_sub_account, 250005, 251035) do + it "should manually change a group quota", priority: "1", test_id: pick_test_id(account_type, sub_account: 250005, root_account: 251035) do f('#tab-quotas-link').click # find the course by id @@ -150,7 +153,7 @@ shared_examples_for "settings basic tests" do |is_sub_account| expect(@group.storage_quota_mb).to eq 42 end - it "should change the default language to spanish", priority: "1", test_id: pick_test_id(is_sub_account, 250006, 251036) do + it "should change the default language to spanish", priority: "1", test_id: pick_test_id(account_type, sub_account: 250006, root_account: 251036) do f("#account_default_locale option[value='es']").click click_submit account.reload @@ -160,6 +163,3 @@ shared_examples_for "settings basic tests" do |is_sub_account| end end -def pick_test_id(is_sub_account, truthy_id, falsy_id) - is_sub_account ? truthy_id : falsy_id -end diff --git a/spec/selenium/helpers/groups_shared_examples.rb b/spec/selenium/helpers/groups_shared_examples.rb index 1bce8d58cd7..ee900793834 100644 --- a/spec/selenium/helpers/groups_shared_examples.rb +++ b/spec/selenium/helpers/groups_shared_examples.rb @@ -1,12 +1,14 @@ require_relative '../common' require_relative 'groups_common' +require_relative 'shared_examples_common' include GroupsCommon +include SharedExamplesCommon # ====================================================================================================================== # Shared Examples # ====================================================================================================================== shared_examples 'home_page' do |context| - it "should display a coming up section with relevant events", priority: pick_priority(context,"1","2"), test_id: pick_test_id(context, 273602, 319909) do + it "should display a coming up section with relevant events", priority: pick_priority(context, student: "1", teacher: "2"), test_id: pick_test_id(context, student: 273602, teacher: 319909) do # Create an event to have something in the Coming up Section event = @testgroup[0].calendar_events.create!(title: "ohai", start_at: Time.zone.now + 1.day) @@ -17,18 +19,18 @@ shared_examples 'home_page' do |context| expect(f('.coming_up .event a b')).to include_text("#{event.title}") end - it "should display a view calendar link on the group home page", priority: pick_priority(context,"1","2"), test_id: pick_test_id(context, 273603, 319910) do + it "should display a view calendar link on the group home page", priority: pick_priority(context, student: "1", teacher: "2"), test_id: pick_test_id(context, student: 273603, teacher: 319910) do get url expect(f('.event-list-view-calendar')).to be_displayed end - it "should have a working link to add an announcement from the group home page", priority: pick_priority(context,"1","2"), test_id: pick_test_id(context, 273604, 319911) do + it "should have a working link to add an announcement from the group home page", priority: pick_priority(context, student: "1", teacher: "2"), test_id: pick_test_id(context, student: 273604, teacher: 319911) do get url expect_new_page_load { fln('New Announcement').click } expect(f('.btn-primary')).to be_displayed end - it "should display recent activity feed on the group home page", priority: pick_priority(context,"1","2"), test_id: pick_test_id(context, 273605, 319912) do + it "should display recent activity feed on the group home page", priority: pick_priority(context, student: "1", teacher: "2"), test_id: pick_test_id(context, student: 273605, teacher: 319912) do DiscussionTopic.create!(context: @testgroup.first, user: @teacher, title: 'Discussion Topic', message: 'test') @testgroup.first.announcements.create!(title: 'Test Announcement', message: 'Message',user: @teacher) @@ -41,7 +43,7 @@ shared_examples 'home_page' do |context| expect(activity[1]).to include_text('1 Discussion') end - it "should display announcements on the group home page feed", priority: pick_priority(context,"1","2"), test_id: pick_test_id(context, 273609, 319913) do + it "should display announcements on the group home page feed", priority: pick_priority(context, student: "1", teacher: "2"), test_id: pick_test_id(context, student: 273609, teacher: 319913) do @testgroup.first.announcements.create!(title: 'Test Announcement', message: 'Message',user: @teacher) get url expect(f('.title')).to include_text('1 Announcement') @@ -52,13 +54,13 @@ end #----------------------------------------------------------------------------------------------------------------------- shared_examples 'announcements_page' do |context| - it "should center the add announcement button if no announcements are present", priority: pick_priority(context,"1","2"), test_id: pick_test_id(context, 273606, 324936) do + it "should center the add announcement button if no announcements are present", priority: pick_priority(context, student: "1", teacher: "2"), test_id: pick_test_id(context, student: 273606, teacher: 324936) do get announcements_page expect(f('#content.container-fluid div')).to have_attribute(:style, 'text-align: center;') expect(f('.btn.btn-large.btn-primary')).to be_displayed end - it "should list all announcements", priority: pick_priority(context,"1","2"), test_id: pick_test_id(context, 273608, 324935) do + it "should list all announcements", priority: pick_priority(context, student: "1", teacher: "2"), test_id: pick_test_id(context, student: 273608, teacher: 324935) do # Create 5 announcements in the group announcements = [] 5.times do |n| @@ -69,7 +71,7 @@ shared_examples 'announcements_page' do |context| expect(ff('.discussion-topic').size).to eq 5 end - it "should only list in-group announcements in the content right pane", priority: pick_priority(context,"1","2"), test_id: pick_test_id(context, 273621, 324934) do + it "should only list in-group announcements in the content right pane", priority: pick_priority(context, student: "1", teacher: "2"), test_id: pick_test_id(context, student: 273621, teacher: 324934) do # create group and course announcements @testgroup.first.announcements.create!(title: 'Group Announcement', message: 'Group',user: @teacher) @course.announcements.create!(title: 'Course Announcement', message: 'Course',user: @teacher) @@ -81,7 +83,7 @@ shared_examples 'announcements_page' do |context| expect(fln('Course Announcement')).to be_nil end - it "should only access group files in announcements right content pane", priority: pick_priority(context,"1","2"), test_id: pick_test_id(context, 273624, 324931) do + it "should only access group files in announcements right content pane", priority: pick_priority(context, student: "1", teacher: "2"), test_id: pick_test_id(context, student: 273624, teacher: 324931) do add_test_files get announcements_page expect_new_page_load { f('.btn-primary').click } @@ -89,12 +91,12 @@ shared_examples 'announcements_page' do |context| expect(ffj('.file .text:visible').size).to eq 1 end - it "should have an Add External Feed link on announcements", priority: "2", test_id: pick_test_id(context, 329628, 329629) do + it "should have an Add External Feed link on announcements", priority: "2", test_id: pick_test_id(context, student: 329628, teacher: 329629) do get announcements_page expect(fln('Add External Feed')).to be_displayed end - it "should have an RSS feed button on announcements", priority: "2", test_id: pick_test_id(context, 329630, 329631) do + it "should have an RSS feed button on announcements", priority: "2", test_id: pick_test_id(context, student: 329630, teacher: 329631) do @testgroup.first.announcements.create!(title: 'Group Announcement', message: 'Group',user: @teacher) get announcements_page expect(f('.btn[title="RSS feed"]')).to be_displayed @@ -103,14 +105,14 @@ end #----------------------------------------------------------------------------------------------------------------------- shared_examples 'pages_page' do |context| - it "should load pages index and display all pages", priority: pick_priority(context,"1","2"), test_id: pick_test_id(context, 273610, 324927) do + it "should load pages index and display all pages", priority: pick_priority(context, student: "1", teacher: "2"), test_id: pick_test_id(context, student: 273610, teacher: 324927) do @testgroup.first.wiki.wiki_pages.create!(title: "Page 1", user: @teacher) @testgroup.first.wiki.wiki_pages.create!(title: "Page 2", user: @teacher) get pages_page expect(ff('.collectionViewItems .clickable').size).to eq 2 end - it "should only list in-group pages in the content right pane", priority: pick_priority(context,"1","2"), test_id: pick_test_id(context, 273620,324928) do + it "should only list in-group pages in the content right pane", priority: pick_priority(context, student: "1", teacher: "2"), test_id: pick_test_id(context, student: 273620, teacher: 324928) do # create group and course announcements group_page = @testgroup.first.wiki.wiki_pages.create!(user: @teacher, title: 'Group Page', message: 'Group') @@ -125,7 +127,7 @@ shared_examples 'pages_page' do |context| expect(fln("#{course_page.title}")).to be_nil end - it "should only access group files in pages right content pane", priority: pick_priority(context,"1","2"), test_id: pick_test_id(context, 303700,324932) do + it "should only access group files in pages right content pane", priority: pick_priority(context, student: "1", teacher: "2"), test_id: pick_test_id(context, student: 303700, teacher: 324932) do add_test_files get pages_page f('.btn-primary').click @@ -137,7 +139,7 @@ end #----------------------------------------------------------------------------------------------------------------------- shared_examples 'people_page' do |context| - it "should allow group users to see group registered services page", priority: pick_priority(context,"1","2"),test_id: pick_test_id(context, 323329, 324926) do + it "should allow group users to see group registered services page", priority: pick_priority(context, student: "1", teacher: "2"),test_id: pick_test_id(context, student: 323329, teacher: 324926) do get people_page expect_new_page_load { fln('View Registered Services').click } # Checks that we are on the Registered Services page @@ -147,7 +149,7 @@ end #----------------------------------------------------------------------------------------------------------------------- shared_examples 'discussions_page' do |context| - it "should only list in-group discussions in the content right pane", priority: pick_priority(context,"1","2"), test_id: pick_test_id(context, 273622,324930) do + it "should only list in-group discussions in the content right pane", priority: pick_priority(context, student: "1", teacher: "2"), test_id: pick_test_id(context, student: 273622, teacher: 324930) do # create group and course announcements group_dt = DiscussionTopic.create!(context: @testgroup.first, user: @teacher, title: 'Group Discussion', message: 'Group') @@ -161,7 +163,7 @@ shared_examples 'discussions_page' do |context| expect(fln("#{course_dt.title}")).to be_nil end - it "should only access group files in discussions right content pane", priority: pick_priority(context,"1","2"), test_id: pick_test_id(context, 303701, 324933) do + it "should only access group files in discussions right content pane", priority: pick_priority(context, student: "1", teacher: "2"), test_id: pick_test_id(context, student: 303701, teacher: 324933) do add_test_files get discussions_page expect_new_page_load { f('.btn-primary').click } @@ -169,7 +171,7 @@ shared_examples 'discussions_page' do |context| expect(ffj('.file .text:visible').size).to eq 1 end - it "should allow group users to reply to group discussions", priority: pick_priority(context,"1","2"), test_id: pick_test_id(context, 312868, 312870) do + it "should allow group users to reply to group discussions", priority: pick_priority(context, student: "1", teacher: "2"), test_id: pick_test_id(context, student: 312868, teacher: 312870) do DiscussionTopic.create!(context: @testgroup.first, user: @teacher, title: 'Group Discussion', message: 'Group') get discussions_page @@ -186,7 +188,7 @@ end #----------------------------------------------------------------------------------------------------------------------- shared_examples 'files_page' do |context| - it "should allow group users to rename a file", priority: "2", test_id: pick_test_id(context, 312869, 315577) do + it "should allow group users to rename a file", priority: "2", test_id: pick_test_id(context, student: 312869, teacher: 315577) do add_test_files get files_page edit_name_from_cog_icon('cool new name') @@ -194,7 +196,7 @@ shared_examples 'files_page' do |context| expect(fln('cool new name')).to be_present end - it "should search files only within the scope of a group", priority: pick_priority(context,"1","2"), test_id: pick_test_id(context, 273627, 324937) do + it "should search files only within the scope of a group", priority: pick_priority(context, student: "1", teacher: "2"), test_id: pick_test_id(context, student: 273627, teacher: 324937) do add_test_files get files_page f('input[type="search"]').send_keys 'example.pdf' @@ -208,14 +210,14 @@ end #----------------------------------------------------------------------------------------------------------------------- shared_examples 'conferences_page' do |context| - it "should allow group users to create a conference", priority: pick_priority(context,"1","2"),test_id: pick_test_id(context, 307624, 308534) do + it "should allow group users to create a conference", priority: pick_priority(context, student: "1", teacher: "2"),test_id: pick_test_id(context, student: 307624, teacher: 308534) do title = 'test conference' get conferences_page create_conference(title: title) expect(f('#new-conference-list .ig-title').text).to include(title) end - it "should allow group users to delete an active conference", priority: pick_priority(context,"1","2"),test_id: pick_test_id(context, 323557, 323558) do + it "should allow group users to delete an active conference", priority: pick_priority(context, student: "1", teacher: "2"),test_id: pick_test_id(context, student: 323557, teacher: 323558) do WimbaConference.create!(title: "new conference", user: @user, context: @testgroup.first) get conferences_page @@ -223,7 +225,7 @@ shared_examples 'conferences_page' do |context| expect(f('#new-conference-list')).to include_text('There are no new conferences') end - it "should allow group users to delete a concluded conference", priority: pick_priority(context,"1","2"),test_id: pick_test_id(context, 323559, 323560) do + it "should allow group users to delete a concluded conference", priority: pick_priority(context, student: "1", teacher: "2"),test_id: pick_test_id(context, student: 323559, teacher: 323560) do cc = WimbaConference.create!(title: "cncluded conference", user: @user, context: @testgroup.first) conclude_conference(cc) get conferences_page @@ -233,28 +235,3 @@ shared_examples 'conferences_page' do |context| end end -# ====================================================================================================================== -# Helper Methods -# ====================================================================================================================== - -def pick_test_id(context, id1, id2) - case context - when 'student' - id1 - when 'teacher' - id2 - else - raise('Error: Invalid context!') - end -end - -def pick_priority(context, p1, p2) - case context - when 'student' - p1 - when 'teacher' - p2 - else - raise('Error: Invalid context!') - end -end diff --git a/spec/selenium/helpers/shared_examples_common.rb b/spec/selenium/helpers/shared_examples_common.rb new file mode 100644 index 00000000000..fb71dcf48f7 --- /dev/null +++ b/spec/selenium/helpers/shared_examples_common.rb @@ -0,0 +1,36 @@ +module SharedExamplesCommon + + # For use with choosing TestRail test id in shared specs based on context. + # + # usage: + # pick_test_id(context, option1: , option2: [, option3: , option2: [, option3: