spec: used shared examples to test sub accounts

Change-Id: I71cc0287f994d3ac74fbf9f71375647f9349c5b5
Reviewed-on: https://gerrit.instructure.com/11941
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Bryan Madsen <bryan@instructure.com>
This commit is contained in:
Jake Sorce 2012-06-27 15:39:26 -06:00
parent f46faca4b5
commit a571e513b8
36 changed files with 1113 additions and 969 deletions

View File

@ -62,7 +62,7 @@
<% if can_do @account, @current_user, :read_course_list %>
<% if @account == Account.default %>
<h2><%= t(:recently_created_courses_title, "Recently Created Courses") %></h2>
<ul class="item_list">
<ul id="recently_created_item_list" class="item_list">
<% @recently_created_courses.each do |course| %>
<li>
<a href="<%= course_path(course.id) %>" class="header"><%= course.name %></a>
@ -87,7 +87,7 @@
<% end %>
<h2><%= t(:recently_started_courses_title, "Recently Started Courses") %></h2>
<ul class="item_list">
<ul id="recently_started_item_list" class="item_list">
<% @recently_started_courses.each do |course| %>
<li>
<a href="<%= course_path(course.id) %>" class="header"><%= course.name %></a>
@ -100,7 +100,7 @@
</ul>
<h2><%= t(:recently_ended_courses_title, "Recently Ended Courses") %></h2>
<ul class="item_list">
<ul id="recently_ended_item_list" class="item_list">
<% @recently_ended_courses.each do |course| %>
<li>
<a href="<%= course_path(course.id) %>" class="header"><%= course.name %></a>
@ -115,7 +115,7 @@
<% if can_do @account, @current_user, :read_roster %>
<h2><%= t(:recently_logged_in_users_title, "Recently Logged-In Users") %></h2>
<ul class="item_list">
<ul id="recently_logged_in_item_list" class="item_list">
<% @recently_logged_users.each do |user| %>
<li>
<a href="<%= user_path(user.id) %>" class="header"><%= user.name %></a>

View File

@ -1,13 +1,10 @@
require File.expand_path(File.dirname(__FILE__) + '/../common')
require File.expand_path(File.dirname(__FILE__) + '/../helpers/basic/courses_specs')
describe "account admin courses tab" do
it_should_behave_like "in-process server selenium tests"
before (:each) do
course_with_admin_logged_in
get "/accounts/#{Account.default.id}"
end
def add_course course_name, has_student=false
def add_course(course_name, has_student = false)
Account.default.courses.create(:name => course_name).offer!
course = Course.find_by_name(course_name)
if (has_student)
@ -24,65 +21,67 @@ describe "account admin courses tab" do
course
end
it "should add a new course" do
f(".add_course_link").click
f("#add_course_form #course_name").send_keys("course 1")
f("#course_course_code").send_keys("12345")
submit_form("#add_course_form")
# we need to refresh the page so the course shows up
refresh_page
course = Course.find_by_name("course 1")
course.should be_present
course.course_code.should eql "12345"
f("#course_#{course.id}").should be_displayed
f("#course_#{course.id}").should include_text "course 1"
context "add course basic" do
describe "shared course specs" do
let(:account) { Account.default }
let(:url) { "/accounts/#{Account.default.id}" }
it_should_behave_like "courses basic tests"
end
end
it "should search a course and verify it goes to the course" do
name = "course 1"
course = add_course name, true
name = name.split(" ")
f("#course_name").send_keys(name[0])
f("#course_name").send_keys(" "+name[1])
ff(".ui-menu-item .ui-corner-all").count > 0
keep_trying_until { fj(".ui-menu-item .ui-corner-all:visible").text.should include_text(course.name) }
f("#new_course button").click
wait_for_ajax_requests
f("#crumb_course_#{course.id}").should be_displayed
end
context "add courses" do
it "should search a bogus course and it should not show up" do
add_course "course 1"
name = "courses 4"
name = name.split(" ")
f("#course_name").send_keys(name[0])
f("#course_name").send_keys(" "+name[1])
ff(".ui-menu-item .ui-corner-all").count.should eql 0
end
before (:each) do
course_with_admin_logged_in
get "/accounts/#{Account.default.id}"
end
it "should hide enrollmentless courses" do
name = "course 1"
name2 = "course 2"
course = add_course name
course2 = add_course name2, true
f("#enroll_filter_checkbox").click
f(".filter_button").click
wait_for_ajax_requests
f("#course_#{course.id}").should be_nil
f("#course_#{course2.id}").should be_displayed
end
it "should search a course and verify it goes to the course" do
name = "course 1"
course = add_course name, true
name = name.split(" ")
f("#course_name").send_keys(name[0])
f("#course_name").send_keys(" "+name[1])
ff(".ui-menu-item .ui-corner-all").count > 0
keep_trying_until { fj(".ui-menu-item .ui-corner-all:visible").text.should include_text(course.name) }
f("#new_course button").click
wait_for_ajax_requests
f("#crumb_course_#{course.id}").should be_displayed
end
it "should hide and then show enrollmentless courses" do
name = "course 1"
course = add_course name
f("#enroll_filter_checkbox").click
f(".filter_button").click
wait_for_ajax_requests
f("#course_#{course.id}").should be_nil
f("#enroll_filter_checkbox").click
f(".filter_button").click
wait_for_ajax_requests
f("#course_#{course.id}").should be_displayed
it "should search a bogus course and it should not show up" do
add_course "course 1"
name = "courses 4"
name = name.split(" ")
f("#course_name").send_keys(name[0])
f("#course_name").send_keys(" "+name[1])
ff(".ui-menu-item .ui-corner-all").count.should == 0
end
it "should hide enrollmentless courses" do
name = "course 1"
name2 = "course 2"
course = add_course name
course2 = add_course name2, true
f("#enroll_filter_checkbox").click
f(".filter_button").click
wait_for_ajax_requests
f("#course_#{course.id}").should be_nil
f("#course_#{course2.id}").should be_displayed
end
it "should hide and then show enrollmentless courses" do
name = "course 1"
course = add_course name
f("#enroll_filter_checkbox").click
f(".filter_button").click
wait_for_ajax_requests
f("#course_#{course.id}").should be_nil
f("#enroll_filter_checkbox").click
f(".filter_button").click
wait_for_ajax_requests
f("#course_#{course.id}").should be_displayed
end
end
end

View File

@ -1,93 +1,10 @@
require File.expand_path(File.dirname(__FILE__) + '/../common')
require File.expand_path(File.dirname(__FILE__) + '/../helpers/basic/grading_schemes_specs')
describe "account admin grading schemes" do
it_should_behave_like "in-process server selenium tests"
def save_and_reload_changes(grading_standard)
f('.save_button').click
wait_for_ajax_requests
grading_standard.reload
describe "shared grading scheme specs" do
let(:account) { Account.default }
let(:url) { "/accounts/#{Account.default.id}/grading_standards" }
it_should_behave_like "grading scheme basic tests"
end
before (:each) do
course_with_admin_logged_in
end
describe "grading schemes" do
it "should add a grading scheme" do
new_standard_name = 'new grading standard'
get "/accounts/#{Account.default.id}/grading_standards"
f('.add_standard_link').click
f('#grading_standard_new .scheme_name').send_keys(new_standard_name)
f('.save_button').click
wait_for_ajax_requests
new_grading_standard = GradingStandard.last
new_grading_standard.title.should == new_standard_name
f("#grading_standard_#{new_grading_standard.id}").should be_displayed
end
it "should edit a grading scheme" do
edit_name = 'edited grading scheme'
grading_standard_for(Account.default)
get "/accounts/#{Account.default.id}/grading_standards"
grading_standard = GradingStandard.last
f('.edit_grading_standard_link').click
f("#grading_standard_#{grading_standard.id} .scheme_name").send_keys(edit_name)
save_and_reload_changes(grading_standard)
grading_standard.title.should == edit_name
fj("#grading_standard_#{grading_standard.id} .title").text.should == edit_name #fj to avoid selenium caching
end
it "should delete a grading scheme" do
grading_standard_for(Account.default)
get "/accounts/#{Account.default.id}/grading_standards"
f('.delete_grading_standard_link').click
driver.switch_to.alert.accept
wait_for_ajaximations
GradingStandard.last.workflow_state.should == 'deleted'
end
end
describe "grading scheme items" do
def grading_standard_rows
ff('.grading_standard_row')
end
before (:each) do
account = Account.default
grading_standard_for(account)
@grading_standard = GradingStandard.last
get "/accounts/#{account.id}/grading_standards"
f('.edit_grading_standard_link').click
end
it "should add a grading scheme item" do
data_count = @grading_standard.data.count
driver.action.move_to(grading_standard_rows[0]).perform
f('.insert_grading_standard_link').click
replace_content(ff('.editing_box .standard_name')[0], 'F')
save_and_reload_changes(@grading_standard)
@grading_standard.data.count.should == data_count + 1
@grading_standard.data[0][0].should == 'F'
end
it "should edit a grading scheme item" do
replace_content(grading_standard_rows[0].find_element(:css, '.standard_name'), 'F')
save_and_reload_changes(@grading_standard)
@grading_standard.data[0][0].should == 'F'
end
it "should delete a grading scheme item" do
data_count = @grading_standard.data.count
grading_standard_rows[0].find_element(:css, '.delete_row_link').click
wait_for_ajaximations
save_and_reload_changes(@grading_standard)
@grading_standard.data.count.should == data_count - 1
@grading_standard.data[0][0].should == 'B'
end
end
end
end

View File

@ -55,7 +55,7 @@ describe "account admin manage groups" do
# submit new category form
add_account_category @admin_account, 'New Category'
driver.find_elements(:css, "#category_list li").size.should == 2
driver.find_elements(:css, "#category_list li a").last.text.should eql "New Category"
driver.find_elements(:css, "#category_list li a").last.text.should == "New Category"
end
it "should remove tab and sidebar entries for deleted category" do
@ -118,7 +118,7 @@ describe "account admin manage groups" do
it "should add another group and see that the group is there" do
get "/accounts/#{@admin_account.id}/groups"
group = add_group_to_category @courses_group_category, 'group 1'
driver.find_element(:css, "#group_#{group.id} .group_name").text.should eql(group.name)
driver.find_element(:css, "#group_#{group.id} .group_name").text.should == group.name
end
it "should add multiple groups and validate they exist" do
@ -137,7 +137,7 @@ describe "account admin manage groups" do
confirm_dialog.accept
wait_for_ajaximations
driver.find_elements(:css, ".left_side .group").should be_empty
@admin_account.group_categories.all.count.should eql 0
@admin_account.group_categories.all.count.should == 0
end
it "should edit an individual group" do
@ -213,7 +213,7 @@ describe "account admin manage groups" do
replace_content input_box, category_name
submit_form(form)
wait_for_ajaximations
@admin_account.group_categories.last.name.should eql category_name
@admin_account.group_categories.last.name.should == category_name
end
it "should create a category and should be able to check the Allow self sign-up box" do

View File

@ -2,11 +2,10 @@ require File.expand_path(File.dirname(__FILE__) + '/../common')
require File.expand_path(File.dirname(__FILE__) + '/../helpers/outcome_specs')
describe "account admin outcomes" do
it_should_behave_like "outcome tests"
describe "shared outcome specs" do
let(:outcome_url) { "/accounts/#{Account.default.id}/outcomes" }
let(:who_to_login) { 'admin' }
it_should_behave_like "outcome specs"
let(:account) { Account.default }
it_should_behave_like "outcome tests"
end
end

View File

@ -1,64 +1,9 @@
require File.expand_path(File.dirname(__FILE__) + '/../common')
require File.expand_path(File.dirname(__FILE__) + '/../helpers/basic/question_banks_specs')
describe "account admin question banks" do
it_should_behave_like "in-process server selenium tests"
before (:each) do
admin_logged_in
get "/accounts/#{Account.default.id}/question_banks"
describe "shared question bank specs" do
let(:url) { "/accounts/#{Account.default.id}/question_banks" }
it_should_behave_like "question bank basic tests"
end
def add_question_bank(title = 'bank 1')
f(".add_bank_link").click
question_bank_title = keep_trying_until do
question_bank_title = f("#assessment_question_bank_title")
question_bank_title.should be_displayed
question_bank_title
end
question_bank_title.send_keys(title, :return)
wait_for_ajaximations
question_bank = AssessmentQuestionBank.find_by_title(title)
question_bank.should be_present
question_bank.workflow_state.should == "active"
f("#question_bank_adding .title").should include_text title
question_bank.bookmarked_for?(User.last).should be_true
question_bank
end
it "should verify question bank is found by navigating to bookmark" do
question_bank = add_question_bank
expect_new_page_load { f(".see_bookmarked_banks").click }
f("#question_bank_#{question_bank.id}").should include_text question_bank.title
end
it "should un-bookmark a question bank" do
question_bank = add_question_bank
fj(".bookmark_bank_link img:visible").should have_attribute(:alt, "Bookmark")
fj(".bookmark_bank_link:visible").click
wait_for_ajax_requests
fj(".bookmark_bank_link img:visible").should have_attribute(:alt, "Bookmark_gray")
question_bank.reload
question_bank.bookmarked_for?(User.last).should be_false
end
it "should edit a question bank" do
new_title = "bank 2"
question_bank = add_question_bank
f("#questions .edit_bank_link").click
f("#assessment_question_bank_title").send_keys(new_title, :return)
wait_for_ajax_requests
question_bank.reload
question_bank.title.should == new_title
f("#questions .title").should include_text new_title
end
it "should delete a question bank" do
question_bank = add_question_bank
f("#questions .delete_bank_link").click
driver.switch_to.alert.accept
wait_for_ajaximations
question_bank.reload
question_bank.workflow_state.should == "deleted"
f("#questions .title").should be_nil
end
end
end

View File

@ -1,11 +1,10 @@
require File.expand_path(File.dirname(__FILE__) + '/../common')
require File.expand_path(File.dirname(__FILE__) + '/../helpers/rubrics_specs')
describe "account rubrics" do
it_should_behave_like "rubric tests"
describe "shared rubric specs" do
let(:rubric_url) { "/accounts/#{Account.default.id}/rubrics" }
let(:who_to_login) { 'admin' }
it_should_behave_like "rubric specs"
let(:account) { Account.default }
it_should_behave_like "rubric tests"
end
end

View File

@ -1,65 +1,11 @@
require File.expand_path(File.dirname(__FILE__) + '/../common')
require File.expand_path(File.dirname(__FILE__) + '/../helpers/basic/statistics_specs')
describe "account admin statistics" do
it_should_behave_like "in-process server selenium tests"
def item_lists
ff('.item_list')
describe "shared statistics specs" do
let(:url) { "/accounts/#{Account.default.id}/statistics" }
let(:account) { Account.default }
let(:list_css) { {:created => '#recently_created_item_list', :started => '#recently_started_item_list', :ended => '#recently_ended_item_list', :logged_in => '#recently_logged_in_item_list'} }
it_should_behave_like "statistics basic tests"
end
def validate_item_list(item_list, header_text)
item_list.find_element(:css, '.header').text.should == header_text
end
context "with admin initially logged in" do
before (:each) do
@course = Course.create!(:name => 'stats', :account => Account.default)
@course.offer!
admin_logged_in
end
context 'created, started, none to show, and link validation' do
before (:each) do
get "/accounts/#{Account.default.id}/statistics"
end
['created', 'started'].each_with_index do |action, i|
it "should validate recently #{action} courses display" do
validate_item_list(item_lists[i], @course.name)
end
end
it "should validate no info in list display" do
item_lists[2].text.should == 'None to show'
end
it "should validate link works in list" do
expect_new_page_load { item_lists[0].find_element(:css, '.header').click }
f('#section-tabs-header').should include_text(@course.name)
end
end
it "should validate recently ended courses display" do
concluded_course = Course.create!(:name => 'concluded course', :account => Account.default)
concluded_course.update_attributes(:conclude_at => 1.day.ago)
get "/accounts/#{Account.default.id}/statistics"
validate_item_list(item_lists[2], concluded_course.name)
end
end
it "should validate recently logged-in courses display" do
course = Course.create!(:name => 'new course', :account => Account.default)
course.offer!
student = User.create!(:name => 'Example Student')
student.register!
pseudonym = student.pseudonyms.create!(:unique_id => 'student@example.com', :password => 'asdfasdf', :password_confirmation => 'asdfasdf')
course.enroll_user(student, 'StudentEnrollment').accept!
login_as(pseudonym.unique_id, 'asdfasdf')
driver.navigate.to(app_host + '/logout')
admin_logged_in
get "/accounts/#{Account.default.id}/statistics"
validate_item_list(item_lists[3], student.name)
end
end
end

View File

@ -40,7 +40,7 @@ describe "admin avatars" do
wait_for_ajax_requests
f(".links .unlock_avatar_link").should be_displayed
user.reload
user.avatar_state.should eql :locked
user.avatar_state.should == :locked
user
end
@ -78,17 +78,17 @@ describe "admin avatars" do
f(".links .unlock_avatar_link").click
wait_for_ajax_requests
user.reload
user.avatar_state.should eql :approved
user.avatar_state.should == :approved
f(".links .lock_avatar_link").should be_displayed
end
it "should approve un-approved avatar" do
user = create_avatar_state
user.avatar_state.should eql :submitted
user.avatar_state.should == :submitted
f(".links .approve_avatar_link").click
wait_for_ajax_requests
user.reload
user.avatar_state.should eql :approved
user.avatar_state.should == :approved
f(".links .approve_avatar_link").should_not be_displayed
end
it "should delete the avatar" do
@ -98,7 +98,7 @@ describe "admin avatars" do
driver.switch_to.alert.accept
wait_for_ajax_requests
user.reload
user.avatar_state.should eql :none
user.avatar_state.should == :none
user.avatar_image_url.should be_nil
end
end

View File

@ -1,5 +1,6 @@
require File.expand_path(File.dirname(__FILE__) + '/../common')
require File.expand_path(File.dirname(__FILE__) + '/../helpers/external_tools_common')
require File.expand_path(File.dirname(__FILE__) + '/../helpers/basic/settings_specs')
describe "admin settings tabs" do
it_should_behave_like "external tools tests"
@ -8,42 +9,6 @@ describe "admin settings tabs" do
get "/accounts/#{Account.default.id}/settings"
end
context "admins tab" do
def add_account
address = "student1@example.com"
f(".add_users_link.button").click
f("textarea.user_list").send_keys(address)
f(".verify_syntax_button").click
wait_for_ajax_requests
f("#user_lists_processed_people .person").text.should eql address
f(".add_users_button").click
wait_for_ajax_requests
user = User.find_by_name(address)
user.should be_present
admin = AccountUser.find_by_user_id(user.id)
admin.should be_present
admin.membership_type.should eql "AccountAdmin"
f("#enrollment_#{admin.id} .email").text.should eql address
admin.id
end
before (:each) do
f("#tab-users-link").click
end
it "should add an account admin" do
add_account
end
it "should delete an account admin" do
admin_id = add_account
f("#enrollment_#{admin_id} .remove_account_user_link").click
driver.switch_to.alert.accept
wait_for_ajax_requests
AccountUser.find_by_id(admin_id).should be_nil
end
end
context "external tools tab" do
before (:each) do
f("#tab-tools-link").click
@ -75,7 +40,7 @@ describe "admin settings tabs" do
driver.switch_to.alert.accept
wait_for_ajax_requests
tool = ContextExternalTool.last
tool.workflow_state.should eql "deleted"
tool.workflow_state.should == "deleted"
f("#external_tool#{tool.id} .name").should be_nil
end
@ -87,17 +52,17 @@ describe "admin settings tabs" do
f(".save_button").click
wait_for_ajax_requests
tool = ContextExternalTool.last
tool.description.should eql new_description
f("#external_tool_#{tool.id} .description").text.should eql new_description
tool.description.should == new_description
f("#external_tool_#{tool.id} .description").text.should == new_description
end
end
context "announcements tab" do
def date_chooser(date="n")
def date_chooser(date = "n")
today = f(".ui-datepicker-calendar .ui-state-highlight").text.to_i
days = ff("#ui-datepicker-div .ui-state-default").count
time= Time.now
if (date.eql? "t")
if (date == "t")
if (today == days)
ff("#ui-datepicker-div .ui-icon")[1].click
ff("#ui-datepicker-div .ui-state-default")[0].click
@ -129,7 +94,7 @@ describe "admin settings tabs" do
notification.subject.should include_text(subject)
notification.start_at.to_s.should include_text today
notification.end_at.to_s.should include_text tomorrow
f("#tab-announcements .user_content").text.should eql "this is a message"
f("#tab-announcements .user_content").text.should == "this is a message"
end
before (:each) do
@ -145,7 +110,17 @@ describe "admin settings tabs" do
f(".delete_notification_link").click
driver.switch_to.alert.accept
wait_for_animations
AccountNotification.count.should eql 0
AccountNotification.count.should == 0
end
end
end
describe 'shared settings specs' do
describe "settings" do
let(:url) { "/accounts/#{Account.default.id}/statistics" }
let(:account) { Account.default }
let(:account_settings_url) { "/accounts/#{Account.default.id}/settings" }
let(:admin_tab_url) { "/accounts/#{Account.default.id}/settings#tab-users" }
it_should_behave_like "settings basic tests"
end
end

View File

@ -10,9 +10,7 @@ describe "admin settings tab" do
def get_default_services
default_services = []
service_hash = Account.default.allowed_services_hash
service_hash.each do |k, v|
default_services.push k if v[:expose_to_ui]
end
service_hash.each { |k, v| default_services.push k if v[:expose_to_ui] }
default_services
end
@ -24,11 +22,11 @@ describe "admin settings tab" do
end
end
def check_box_verifier (css_selectors, features, checker=true)
def check_box_verifier (css_selectors, features, checker = true)
is_symbol = false
if features.is_a? Symbol
is_symbol =true
if features.eql? :all_selectors
is_symbol = true
if features == :all_selectors
features = get_default_services
end
end
@ -47,7 +45,7 @@ describe "admin settings tab" do
f(selector).click
end
click_submit
if (is_symbol.eql? false)
if (is_symbol == false)
check_state = Account.default.service_enabled?(features[:allowed_services])
state_checker checker, check_state
else
@ -78,54 +76,24 @@ describe "admin settings tab" do
wait_for_ajax_requests
end
context "acccount settings" do
it "should change the admins name " do
replace_content f("#account_name"), "Admin 1"
click_submit
Account.default.name.should eql "Admin 1"
f("#account_name").should have_value "Admin 1"
end
it "should change the default course file quota" do
quota = 300
f("#account_default_course_storage_quota").should have_value "500"
replace_content f("#account_default_course_storage_quota"), quota
click_submit
Account.default.default_storage_quota.should eql quota.megabytes
f("#account_default_course_storage_quota").should have_value quota.to_s
end
it "should change the default user file quota" do
quota = 100
f("#account_default_user_storage_quota").should have_value "50"
replace_content f("#account_default_user_storage_quota"), quota
click_submit
Account.default.default_user_storage_quota.should eql quota.megabytes
f("#account_default_user_storage_quota").should have_value quota.to_s
end
it "should change the default language to spanish" do
f("#account_default_locale option[value='es']").click
click_submit
Account.default.default_locale.should eql "es"
f("label[for='account_name']").text.should include_text("Nombre de Cuenta")
end
context "account settings" do
it "should change the default time zone to Lima" do
f("#account_default_time_zone option[value='Lima']").click
click_submit
Account.default.default_time_zone.should eql "Lima"
Account.default.default_time_zone.should == "Lima"
f("#account_default_time_zone option[value='Lima']").attribute("selected").should be_true
end
describe "allow self-enrollment" do
def enrollment_helper (value='')
if (value.eql? '')
if (value == '')
f("#account_settings_self_enrollment option[value='']").click
else
f("#account_settings_self_enrollment option[value=#{value}]").click
end
click_submit
Account.default[:settings][:self_enrollment].should eql value
Account.default[:settings][:self_enrollment].should == value
f("#account_settings_self_enrollment").should have_value value
end
@ -221,8 +189,8 @@ describe "admin settings tab" do
f("#account_settings_equella_endpoint").send_keys(equella_url)
f("#account_settings_equella_teaser").send_keys("equella feature")
click_submit
Account.default.settings[:equella_endpoint].should eql equella_url
Account.default.settings[:equella_teaser].should eql "equella feature"
Account.default.settings[:equella_endpoint].should == equella_url
Account.default.settings[:equella_teaser].should == "equella feature"
f("#account_settings_equella_endpoint").should have_value equella_url
f("#account_settings_equella_teaser").should have_value "equella feature"
end
@ -241,8 +209,8 @@ describe "admin settings tab" do
replace_content(f("#account_settings_equella_endpoint"), new_equella_url)
replace_content(f("#account_settings_equella_teaser"), "new equella feature")
click_submit
Account.default.settings[:equella_endpoint].should eql new_equella_url
Account.default.settings[:equella_teaser].should eql "new equella feature"
Account.default.settings[:equella_endpoint].should == new_equella_url
Account.default.settings[:equella_teaser].should == "new equella feature"
f("#account_settings_equella_endpoint").should have_value new_equella_url
f("#account_settings_equella_teaser").should have_value "new equella feature"
end
@ -254,8 +222,8 @@ describe "admin settings tab" do
replace_content(f("#account_settings_equella_endpoint"), "")
replace_content(f("#account_settings_equella_teaser"), "")
click_submit
Account.default.settings[:equella_endpoint].should eql ""
Account.default.settings[:equella_teaser].should eql ""
Account.default.settings[:equella_endpoint].should == ""
Account.default.settings[:equella_teaser].should == ""
fj("#account_settings_equella_endpoint:visible").should be_nil
fj("#account_settings_equella_teaser:visible").should be_nil
end
@ -303,17 +271,17 @@ describe "admin settings tab" do
end
it "should enable and disable a plugin service (setting)" do
Account.register_service(:myplugin, { :name => "My Plugin", :description => "", :expose_to_ui => :setting, :default => false })
Account.register_service(:myplugin, {:name => "My Plugin", :description => "", :expose_to_ui => :setting, :default => false})
get "/accounts/#{Account.default.id}/settings"
check_box_verifier("#account_services_myplugin", { :allowed_services => :myplugin })
check_box_verifier("#account_services_myplugin", { :allowed_services => :myplugin }, false)
check_box_verifier("#account_services_myplugin", {:allowed_services => :myplugin})
check_box_verifier("#account_services_myplugin", {:allowed_services => :myplugin}, false)
end
it "should enable and disable a plugin service (service)" do
Account.register_service(:myplugin, { :name => "My Plugin", :description => "", :expose_to_ui => :service, :default => false })
Account.register_service(:myplugin, {:name => "My Plugin", :description => "", :expose_to_ui => :service, :default => false})
get "/accounts/#{Account.default.id}/settings"
check_box_verifier("#account_services_myplugin", { :allowed_services => :myplugin })
check_box_verifier("#account_services_myplugin", { :allowed_services => :myplugin }, false)
check_box_verifier("#account_services_myplugin", {:allowed_services => :myplugin})
check_box_verifier("#account_services_myplugin", {:allowed_services => :myplugin}, false)
end
end

View File

@ -1,6 +1,7 @@
require File.expand_path(File.dirname(__FILE__) + '/../common')
describe "admin sub accounts" do
it_should_behave_like "in-process server selenium tests"
DEFAULT_ACCOUNT_ID = Account.default.id
def create_sub_account(name = 'sub account', number_to_create = 1, parent_account = Account.default)
@ -29,7 +30,6 @@ describe "admin sub accounts" do
wait_for_ajaximations
end
it_should_behave_like "in-process server selenium tests"
before (:each) do
course_with_admin_logged_in
end

View File

@ -1,73 +1,42 @@
require File.expand_path(File.dirname(__FILE__) + '/../common')
require File.expand_path(File.dirname(__FILE__) + '/../helpers/shared_user_methods')
require File.expand_path(File.dirname(__FILE__) + '/../helpers/basic/users_specs')
describe "admin courses tab" do
it_should_behave_like "in-process server selenium tests"
before (:each) do
course_with_admin_logged_in
get "/accounts/#{Account.default.id}/users"
context "add user basic" do
describe "shared users specs" do
let(:account) { Account.default }
let(:url) { "/accounts/#{account.id}/users" }
let(:opts) { {:name => 'student'} }
it_should_behave_like "users basic tests"
end
end
def add_user (opts={})
f(".add_user_link").click
name = opts[:name] ? opts[:name] : "user1"
email = opts[:email] ? opts[:email] : "user1@test.com"
sortable_name = opts[:sortable_name] ? opts[:sortable_name] : name
confirmation = opts[:confirmation] ? opts[:confirmation] : 1
short_name = opts[:short_name] ? opts[:short_name] : name
if (!short_name.eql? name)
replace_content f("#user_short_name"), short_name
end
if(!sortable_name.eql? name)
replace_content f("#user_sortable_name"), sortable_name
end
is_checked("#pseudonym_send_confirmation").should be_true
if (confirmation == 0)
f("#pseudonym_send_confirmation").click
is_checked("#pseudonym_send_confirmation").should be_false
end
f("#add_user_form #user_name").send_keys name
f("#pseudonym_unique_id").send_keys email
submit_form("#add_user_form")
wait_for_ajax_requests
user = User.first(:conditions =>{:name => name})
user.should be_present
user.sortable_name.should eql sortable_name
user.short_name.should eql short_name
user.email.should eql email
user
end
it "should add an new user" do
opts = {:name => "user_name"}
user = add_user opts
#we need to refresh the page to see the user
refresh_page
f("#user_#{user.id}").should be_displayed
f("#user_#{user.id}").should include_text "user_name"
end
it "should add an new user with a sortable name" do
opts = {:sortable_name => "sortable name"}
add_user(opts)
end
it "should add an new user with a short name" do
opts = {:short_name => "short name"}
add_user(opts)
end
it "should add a new user with confirmation disabled" do
opts = {:confirmation => 0}
add_user(opts)
end
it "should search for a user and should go to it" do
pending do # disabled until we can fix performance
context "add users" do
before (:each) do
course_with_admin_logged_in
get "/accounts/#{Account.default.id}/users"
end
it "should add an new user with a sortable name" do
add_user({:sortable_name => "sortable name"})
end
it "should add an new user with a short name" do
add_user({:short_name => "short name"})
end
it "should add a new user with confirmation disabled" do
add_user({:confirmation => 0})
end
it "should search for a user and should go to it" do
pending('disabled until we can fix performance')
name = "user_1"
opts = {:name => name}
add_user(opts)
add_user({:name => name})
f("#right-side #user_name").send_keys(name)
ff(".ui-menu-item .ui-corner-all").count > 0
wait_for_ajax_requests
@ -76,14 +45,13 @@ describe "admin courses tab" do
wait_for_ajax_requests
f("#content h2").should include_text name
end
it "should search for a bogus user" do
name = "user_1"
add_user({:name => name})
bogus_name = "ser 1"
f("#right-side #user_name").send_keys(bogus_name)
ff(".ui-menu-item .ui-corner-all").count == 0
end
end
it "should search for a bogus user" do
name = "user_1"
opts = {:name => name}
add_user(opts)
bogus_name = "ser 1"
f("#right-side #user_name").send_keys(bogus_name)
ff(".ui-menu-item .ui-corner-all").count == 0
end
end
end

View File

@ -18,7 +18,7 @@ describe "site admin jobs ui" do
wait_for_ajax_requests
keep_trying_until do
Delayed::Job.all.each { |job| job.reload }
Delayed::Job.count(:conditions => {:locked_by => 'on hold'}).should eql count
Delayed::Job.count(:conditions => {:locked_by => 'on hold'}).should == count
end
status_cells = ff('.r2')
@ -72,7 +72,7 @@ describe "site admin jobs ui" do
f("#hold-jobs").click
wait_for_ajax_requests
j.reload.locked_by.should == 'on hold'
Delayed::Job.count(:conditions => {:locked_by => 'on hold'}).should eql 1
Delayed::Job.count(:conditions => {:locked_by => 'on hold'}).should == 1
end
context "all jobs" do
@ -83,34 +83,34 @@ describe "site admin jobs ui" do
it "should check all popular tags" do
filter_tags(FlavorTags::ALL)
keep_trying_until do
f("#tags-grid div[row='0'] .r0").text.should eql "String#reverse"
f("#tags-grid div[row='0'] .r1").text.should eql "2"
f("#tags-grid div[row='1'] .r0").text.should eql "String#capitalize"
f("#tags-grid div[row='1'] .r1").text.should eql "1"
f("#tags-grid div[row='0'] .r0").text.should == "String#reverse"
f("#tags-grid div[row='0'] .r1").text.should == "2"
f("#tags-grid div[row='1'] .r0").text.should == "String#capitalize"
f("#tags-grid div[row='1'] .r1").text.should == "1"
end
end
it "should check current popular tags" do
filter_tags(FlavorTags::CURRENT)
keep_trying_until do
f("#tags-grid div[row='0'] .r0").text.should eql "String#reverse"
f("#tags-grid div[row='0'] .r1").text.should eql "2"
f("#tags-grid div[row='0'] .r0").text.should == "String#reverse"
f("#tags-grid div[row='0'] .r1").text.should == "2"
end
end
it "should check future popular tags" do
filter_tags(FlavorTags::FUTURE)
keep_trying_until do
f("#tags-grid div[row='0'] .r0").text.should eql "String#capitalize"
f("#tags-grid div[row='0'] .r1").text.should eql "1"
f("#tags-grid div[row='0'] .r0").text.should == "String#capitalize"
f("#tags-grid div[row='0'] .r1").text.should == "1"
end
end
it "should check failed popular tags" do
filter_tags(FlavorTags::FAILED)
keep_trying_until do
f("#tags-grid .r0").text.should eql "String#downcase"
f("#tags-grid .r1").text.should eql "1"
f("#tags-grid .r0").text.should == "String#downcase"
f("#tags-grid .r1").text.should == "1"
end
end
@ -118,7 +118,7 @@ describe "site admin jobs ui" do
f("#hold-jobs").click
driver.switch_to.alert.should_not be_nil
driver.switch_to.alert.accept
Delayed::Job.count(:conditions => {:locked_by => 'on hold'}).should eql 0
Delayed::Job.count(:conditions => {:locked_by => 'on hold'}).should == 0
end
it "should confirm that all current rows were selected and put on hold" do
@ -141,9 +141,9 @@ describe "site admin jobs ui" do
driver.switch_to.alert.accept
wait_for_ajax_requests
keep_trying_until do
f("#jobs-grid .even .r2").text.should eql "0/ 15"
f("#jobs-grid .odd .r2").text.should eql "0/ 15"
Delayed::Job.count(:conditions => {:locked_by => 'on hold'}).should eql 0
f("#jobs-grid .even .r2").text.should == "0/ 15"
f("#jobs-grid .odd .r2").text.should == "0/ 15"
Delayed::Job.count(:conditions => {:locked_by => 'on hold'}).should == 0
end
end
@ -152,7 +152,7 @@ describe "site admin jobs ui" do
f("#jobs-refresh").click
wait_for_ajax_requests
job = Delayed::Job.find_by_tag("String#capitalize")
f("#jobs-grid .l0").text.should eql job.id.to_s
f("#jobs-grid .l0").text.should == job.id.to_s
end
it "should confirm that all jobs were selected" do
@ -160,14 +160,14 @@ describe "site admin jobs ui" do
f("#jobs-refresh").click
wait_for_ajax_requests
job = Delayed::Job.find_by_tag("String#capitalize")
f("#jobs-grid .l0").text.should eql job.id.to_s
f("#jobs-grid .l0").text.should == job.id.to_s
end
it "should confirm that failed jobs were selected" do
filter_jobs(FlavorTags::FAILED)
f("#jobs-refresh").click
wait_for_ajax_requests
ff("#jobs-grid .slick-row").count.should eql 1
ff("#jobs-grid .slick-row").count.should == 1
f("#jobs-grid .r1").text.should include_text "String#downcase"
end
@ -176,7 +176,7 @@ describe "site admin jobs ui" do
validate_all_jobs_selected
f("#jobs-grid .odd").should be_displayed
f("#jobs-grid .even").should be_displayed
f("#jobs-total").text.should eql "3"
f("#jobs-total").text.should == "3"
keep_trying_until do
f("#delete-jobs").click
driver.switch_to.alert.should_not be_nil
@ -186,7 +186,7 @@ describe "site admin jobs ui" do
wait_for_ajax_requests
fj("#jobs-grid .odd").should be_nil # using fj to bypass selenium cache
fj("#jobs-grid .even").should be_nil #using fj to bypass selenium cache
Delayed::Job.count.should eql 0
Delayed::Job.count.should == 0
end
end
end
@ -196,9 +196,9 @@ describe "site admin jobs ui" do
j = Delayed::Job.first(:order => :id)
j.lock_exclusively!('my test worker')
load_jobs_page
ffj('#running-grid .slick-row').size.should eql 1
ffj('#running-grid .slick-row').size.should == 1
first_cell = f('#running-grid .slick-cell.l0.r0')
first_cell.text.should eql 'my test worker'
first_cell.text.should == 'my test worker'
end
end
end

View File

@ -1,196 +1,11 @@
require File.expand_path(File.dirname(__FILE__) + '/../common')
require File.expand_path(File.dirname(__FILE__) + '/../helpers/basic/permissions_specs')
describe "site admin permissions" do
it_should_behave_like "in-process server selenium tests"
describe "account permissions" do
before (:each) do
course_with_admin_logged_in
describe "shared permission specs" do
let(:url) { "/accounts/#{Account.default.id}/permissions?account_roles=1" }
let(:account) { Account.default }
it_should_behave_like "permission tests"
end
def has_default_permission? (permission, enrollment_type)
default_permissions = Permissions.retrieve
default_permissions[permission][:true_for].include? enrollment_type
end
def get_updated_role (permission, enrollment_type)
RoleOverride.first(:conditions => {:permission => permission.to_s, :enrollment_type => enrollment_type})
end
def get_checkbox (permission, selector, enrollment_type)
row = nil
permissions = ff("#permissions-table tr > th")
permissions.each do |elem|
if (elem.text.include? permission)
row = elem.find_element(:xpath, "..")
break
end
end
#enrollment type is the number corresponding to the role i.e. Student = 0, Ta = 1, Teacher = 2...
element = row.find_elements(:css, selector)[enrollment_type]
end
def checkbox_verifier(permission, enrollment_type, disable_permission = false, locked = false)
selector = locked ? ".lock" : ".six-checkbox"
#get the element we need
check_box = get_checkbox(permission, selector, enrollment_type)
#we iterate according to the permission event
iterate = disable_permission ? 2 : 1
iterate.times { check_box.click }
f(".save_permissions_changes").click
wait_for_ajax_requests
check_box = get_checkbox(permission, selector, enrollment_type)
if (locked)
check_box.find_element(:xpath, "..").find_element(:css, "input").should have_value "true"
else
if (disable_permission)
check_box.find_element(:css, "input").should have_value "unchecked"
else
check_box.find_element(:css, "input").should have_value "checked"
end
end
end
def permissions_verifier(opts, default_permitted = false, disable_permission = false, locked = false)
if (default_permitted)
has_default_permission?(opts.keys[0], opts.values[0]).should be_true
else
has_default_permission?(opts.keys[0], opts.values[0]).should be_false
end
role = get_updated_role(opts.keys[0], opts.values[0])
role.should be_present
if (disable_permission)
role.enabled.should be_false
else
if (!locked)
role.enabled.should be_true
end
end
if (locked)
role.locked.should be_true
else
role.locked.should be_false
end
end
describe "default role permissions" do
before (:each) do
get "/accounts/#{Account.default.id}/permissions"
end
it "should enable and then disable read sis data for students" do
checkbox_verifier("Read SIS data", 0)
opts = {:read_sis => "StudentEnrollment"}
permissions_verifier(opts)
check_box = get_checkbox("Read SIS data", ".six-checkbox", 0)
check_box.click
f(".save_permissions_changes").click
wait_for_ajax_requests
check_box = get_checkbox("Read SIS data", ".six-checkbox", 0)
check_box.find_element(:css, "input").should have_value "unchecked"
permissions_verifier(opts, false, true)
end
it "should enable read sis data for TAs" do
checkbox_verifier("Read SIS data", 1)
opts = {:read_sis => "TaEnrollment"}
permissions_verifier(opts)
end
it "should lock sis data for students" do
checkbox_verifier("Read SIS data", 0, false, true)
opts = {:read_sis => "StudentEnrollment"}
permissions_verifier(opts, false, false, true)
end
it "should check that teachers have default read sis data enabled and then disable it" do
checkbox_verifier("Read SIS data", 2, true)
opts= {:read_sis => "TeacherEnrollment"}
permissions_verifier(opts, true, true)
end
it "should not enable read sis data for course designer " do
has_default_permission?(:read_sis, "DesignerEnrollment").should be_false
designer = get_checkbox("Read SIS data", ".six-checkbox", 3)
designer.attribute('title').should include_text "you do not have permission"
designer.click
f(".save_permissions_changes").click
wait_for_ajax_requests
designer_role = get_updated_role :read_sis, "DesignerEnrollment"
designer_role.should be_nil
designer = get_checkbox("Read SIS data", ".six-checkbox", 3)
designer.find_element(:css, "input").should have_value ""
end
it "should enable manage wiki for observer" do
checkbox_verifier("Manage wiki", 4)
opts = {:manage_wiki => "ObserverEnrollment"}
permissions_verifier(opts)
end
it "should enable view all grades for designer" do
checkbox_verifier("View all grades", 3)
opts = {:view_all_grades => "DesignerEnrollment"}
permissions_verifier(opts)
end
it "should navigate to manage account-level roles" do
f("#course_level_roles").click
wait_for_ajax_requests
f("#content h2").should include_text "Account Permissions"
end
end
describe "new role permissions" do
before (:each) do
get "/accounts/#{Account.default.id}/permissions?account_roles=1"
end
def add_new_role role
f(".add_new_role").send_keys(role)
f("#add_new_role_button").click
wait_for_ajax_requests
Account.default.account_membership_types.should include role
f("#permissions-table tr").should include_text role
end
it "should add a new account role type" do
role = "New Role"
add_new_role(role)
end
it "should delete an added role" do
role = "New Role"
add_new_role(role)
f(".remove_role_link").click
driver.switch_to.alert.accept
wait_for_ajax_requests
Account.default.account_membership_types.should_not include role
f("#permissions-table tr").should_not include_text role
end
it "should enable manage permissions of new role" do
role = "New Role"
add_new_role(role)
checkbox_verifier("Manage permissions", 1)
opts={:manage_role_overrides => role}
permissions_verifier(opts)
end
it "should disable manage permissions of new role" do
role = "New Role"
add_new_role(role)
checkbox_verifier("Manage permissions", 1, true)
opts={:manage_role_overrides => role}
permissions_verifier(opts, false, true)
end
it "should lock manage permissions of new role" do
role = "New Role"
add_new_role(role)
checkbox_verifier("Manage permissions", 1, false, true)
opts={:manage_role_overrides => role}
permissions_verifier(opts, false, false, true)
end
end
end
end

View File

@ -0,0 +1,10 @@
require File.expand_path(File.dirname(__FILE__) + '/../../common')
require File.expand_path(File.dirname(__FILE__) + '/../../helpers/basic/courses_specs')
describe "sub account courses" do
describe "shared courses specs" do
let(:account) { Account.create(:name => 'sub account from default account', :parent_account => Account.default) }
let(:url) { "/accounts/#{account.id}" }
it_should_behave_like "courses basic tests"
end
end

View File

@ -0,0 +1,10 @@
require File.expand_path(File.dirname(__FILE__) + '/../../common')
require File.expand_path(File.dirname(__FILE__) + '/../../helpers/basic/grading_schemes_specs')
describe "sub account grading schemes" do
describe "shared grading scheme specs" do
let(:account) { Account.create(:name => 'sub account from default account', :parent_account => Account.default) }
let(:url) { "/accounts/#{account.id}/grading_standards" }
it_should_behave_like "grading scheme basic tests"
end
end

View File

@ -0,0 +1,11 @@
require File.expand_path(File.dirname(__FILE__) + '/../../common')
require File.expand_path(File.dirname(__FILE__) + '/../../helpers/outcome_specs')
describe "sub account outcomes" do
describe "shared outcome specs" do
let(:account) { Account.create(:name => 'sub account from default account', :parent_account => Account.default) }
let(:outcome_url) { "/accounts/#{account.id}/outcomes" }
let(:who_to_login) { 'admin' }
it_should_behave_like "outcome tests"
end
end

View File

@ -0,0 +1,10 @@
require File.expand_path(File.dirname(__FILE__) + '/../../common')
require File.expand_path(File.dirname(__FILE__) + '/../../helpers/basic/permissions_specs')
describe "sub account permissions" do
describe "shared permission specs" do
let(:account) { Account.create(:name => 'sub account from default account', :parent_account => Account.default) }
let(:url) { "/accounts/#{account.id}/permissions?account_roles=1" }
it_should_behave_like "permission tests"
end
end

View File

@ -0,0 +1,10 @@
require File.expand_path(File.dirname(__FILE__) + '/../../common')
require File.expand_path(File.dirname(__FILE__) + '/../../helpers/basic/question_banks_specs')
describe "sub account question banks" do
describe "shared question bank specs" do
let(:account) { Account.create(:name => 'sub account from default account', :parent_account => Account.default) }
let(:url) { "/accounts/#{account.id}/question_banks" }
it_should_behave_like "question bank basic tests"
end
end

View File

@ -0,0 +1,11 @@
require File.expand_path(File.dirname(__FILE__) + '/../../common')
require File.expand_path(File.dirname(__FILE__) + '/../../helpers/rubrics_specs')
describe "sub account rubrics" do
describe "shared rubric specs" do
let(:account) { Account.create(:name => 'sub account from default account', :parent_account => Account.default) }
let(:rubric_url) { "/accounts/#{account.id}/rubrics" }
let(:who_to_login) { 'admin' }
it_should_behave_like "rubric tests"
end
end

View File

@ -0,0 +1,12 @@
require File.expand_path(File.dirname(__FILE__) + '/../../common')
require File.expand_path(File.dirname(__FILE__) + '/../../helpers/basic/settings_specs')
describe "sub account settings" do
describe "shared settings specs" do
let(:account) { Account.create(:name => 'sub account from default account', :parent_account => Account.default) }
let(:url) { "/accounts/#{account.id}/statistics" }
let(:account_settings_url) { "/accounts/#{account.id}/settings" }
let(:admin_tab_url) { "/accounts/#{account.id}/settings#tab-users" }
it_should_behave_like "settings basic tests"
end
end

View File

@ -0,0 +1,11 @@
require File.expand_path(File.dirname(__FILE__) + '/../../common')
require File.expand_path(File.dirname(__FILE__) + '/../../helpers/basic/statistics_specs')
describe "sub account statistics" do
describe "shared statistics specs" do
let(:account) { Account.create(:name => 'sub account from default account', :parent_account => Account.default) }
let(:url) { "/accounts/#{account.id}/statistics" }
let(:list_css) { {:started => '#recently_started_item_list', :ended => '#recently_ended_item_list', :logged_in => '#recently_logged_in_item_list'} }
it_should_behave_like "statistics basic tests"
end
end

View File

@ -0,0 +1,11 @@
require File.expand_path(File.dirname(__FILE__) + '/../../common')
require File.expand_path(File.dirname(__FILE__) + '/../../helpers/basic/users_specs')
describe "sub account users" do
describe "shared users specs" do
let(:account) { Account.create(:name => 'sub account from default account', :parent_account => Account.default) }
let(:url) { "/accounts/#{account.id}/users" }
let(:opts) { {:name => 'student'} }
it_should_behave_like "users basic tests"
end
end

View File

@ -0,0 +1,25 @@
shared_examples_for "courses basic tests" do
it_should_behave_like "in-process server selenium tests"
before (:each) do
course_with_admin_logged_in
end
it "should add a new course" do
pending('sub account course creation, failing at wait_for_dom_ready') if account != Account.default
course_name = 'course 1'
course_code = '12345'
get url
f(".add_course_link").click
f("#add_course_form #course_name").send_keys(course_name)
f("#course_course_code").send_keys(course_code)
submit_form("#add_course_form")
refresh_page # we need to refresh the page so the course shows up
course = Course.find_by_name(course_name)
course.should be_present
course.course_code.should == course_code
f("#course_#{course.id}").should be_displayed
f("#course_#{course.id}").should include_text(course_name)
end
end

View File

@ -0,0 +1,90 @@
shared_examples_for "grading scheme basic tests" do
it_should_behave_like "in-process server selenium tests"
def save_and_reload_changes(grading_standard)
f('.save_button').click
wait_for_ajax_requests
grading_standard.reload
end
before (:each) do
course_with_admin_logged_in
end
describe "grading schemes" do
it "should add a grading scheme" do
new_standard_name = 'new grading standard'
get url
f('.add_standard_link').click
f('#grading_standard_new .scheme_name').send_keys(new_standard_name)
f('.save_button').click
wait_for_ajax_requests
new_grading_standard = GradingStandard.last
new_grading_standard.title.should == new_standard_name
f("#grading_standard_#{new_grading_standard.id}").should be_displayed
end
it "should edit a grading scheme" do
edit_name = 'edited grading scheme'
grading_standard_for(account)
get url
grading_standard = GradingStandard.last
f('.edit_grading_standard_link').click
f("#grading_standard_#{grading_standard.id} .scheme_name").send_keys(edit_name)
save_and_reload_changes(grading_standard)
grading_standard.title.should == edit_name
fj("#grading_standard_#{grading_standard.id} .title").text.should == edit_name #fj to avoid selenium caching
end
it "should delete a grading scheme" do
grading_standard_for(account)
get url
f('.delete_grading_standard_link').click
driver.switch_to.alert.accept
wait_for_ajaximations
GradingStandard.last.workflow_state.should == 'deleted'
end
end
describe "grading scheme items" do
def grading_standard_rows
ff('.grading_standard_row')
end
before (:each) do
grading_standard_for(account)
@grading_standard = GradingStandard.last
get url
f('.edit_grading_standard_link').click
end
it "should add a grading scheme item" do
data_count = @grading_standard.data.count
driver.action.move_to(grading_standard_rows[0]).perform
f('.insert_grading_standard_link').click
replace_content(ff('.editing_box .standard_name')[0], 'F')
save_and_reload_changes(@grading_standard)
@grading_standard.data.count.should == data_count + 1
@grading_standard.data[0][0].should == 'F'
end
it "should edit a grading scheme item" do
replace_content(grading_standard_rows[0].find_element(:css, '.standard_name'), 'F')
save_and_reload_changes(@grading_standard)
@grading_standard.data[0][0].should == 'F'
end
it "should delete a grading scheme item" do
data_count = @grading_standard.data.count
grading_standard_rows[0].find_element(:css, '.delete_row_link').click
wait_for_ajaximations
save_and_reload_changes(@grading_standard)
@grading_standard.data.count.should == data_count - 1
@grading_standard.data[0][0].should == 'B'
end
end
end

View File

@ -0,0 +1,127 @@
shared_examples_for "permission tests" do
it_should_behave_like "in-process server selenium tests"
before (:each) do
course_with_admin_logged_in
end
def has_default_permission?(permission, enrollment_type)
default_permissions = Permissions.retrieve
default_permissions[permission][:true_for].include?(enrollment_type)
end
def get_updated_role(permission, enrollment_type)
RoleOverride.first(:conditions => {:permission => permission.to_s, :enrollment_type => enrollment_type})
end
def get_checkbox(permission, selector, enrollment_type)
row = nil
permissions = ff("#permissions-table tr > th")
permissions.each do |elem|
if (elem.text.include? permission)
row = elem.find_element(:xpath, "..")
break
end
end
#enrollment type is the number corresponding to the role i.e. Student = 0, Ta = 1, Teacher = 2...
row.find_elements(:css, selector)[enrollment_type]
end
def checkbox_verifier(permission, enrollment_type, disable_permission = false, locked = false)
selector = locked ? ".lock" : ".six-checkbox"
#get the element we need
check_box = get_checkbox(permission, selector, enrollment_type)
#we iterate according to the permission event
iterate = disable_permission ? 2 : 1
iterate.times { check_box.click }
f(".save_permissions_changes").click
wait_for_ajax_requests
check_box = get_checkbox(permission, selector, enrollment_type)
if (locked)
check_box.find_element(:xpath, "..").find_element(:css, "input").should have_value("true")
else
if (disable_permission)
check_box.find_element(:css, "input").should have_value("unchecked")
else
check_box.find_element(:css, "input").should have_value("checked")
end
end
end
def permissions_verifier(opts, default_permitted = false, disable_permission = false, locked = false)
if (default_permitted)
has_default_permission?(opts.keys[0], opts.values[0]).should be_true
else
has_default_permission?(opts.keys[0], opts.values[0]).should be_false
end
role = get_updated_role(opts.keys[0], opts.values[0])
role.should be_present
if (disable_permission)
role.enabled.should be_false
else
if (!locked)
role.enabled.should be_true
end
end
if (locked)
role.locked.should be_true
else
role.locked.should be_false
end
end
describe "new role permissions" do
before (:each) do
get url
end
def add_new_role(role)
f(".add_new_role").send_keys(role)
f("#add_new_role_button").click
wait_for_ajax_requests
account.reload
account.membership_types.should include(role)
f("#permissions-table tr").should include_text(role)
end
it "should add a new account role type" do
role = "New Role"
add_new_role(role)
end
it "should delete an added role" do
role = "New Role"
add_new_role(role)
f(".remove_role_link").click
driver.switch_to.alert.accept
wait_for_ajax_requests
account.reload
account.membership_types.should_not include(role)
f("#permissions-table tr").should_not include_text(role)
end
it "should enable manage permissions of new role" do
role = "New Role"
add_new_role(role)
checkbox_verifier("Manage permissions", 1)
opts = {:manage_role_overrides => role}
permissions_verifier(opts)
end
it "should disable manage permissions of new role" do
role = "New Role"
add_new_role(role)
checkbox_verifier("Manage permissions", 1, true)
opts = {:manage_role_overrides => role}
permissions_verifier(opts, false, true)
end
it "should lock manage permissions of new role" do
role = "New Role"
add_new_role(role)
checkbox_verifier("Manage permissions", 1, false, true)
opts = {:manage_role_overrides => role}
permissions_verifier(opts, false, false, true)
end
end
end

View File

@ -0,0 +1,61 @@
shared_examples_for "question bank basic tests" do
it_should_behave_like "in-process server selenium tests"
before (:each) do
admin_logged_in
get url
end
def add_question_bank(title = 'bank 1')
f(".add_bank_link").click
question_bank_title = keep_trying_until do
question_bank_title = f("#assessment_question_bank_title")
question_bank_title.should be_displayed
question_bank_title
end
question_bank_title.send_keys(title, :return)
wait_for_ajaximations
question_bank = AssessmentQuestionBank.find_by_title(title)
question_bank.should be_present
question_bank.workflow_state.should == "active"
f("#question_bank_adding .title").should include_text title
question_bank.bookmarked_for?(User.last).should be_true
question_bank
end
it "should verify question bank is found by navigating to bookmark" do
question_bank = add_question_bank
expect_new_page_load { f(".see_bookmarked_banks").click }
f("#question_bank_#{question_bank.id}").should include_text question_bank.title
end
it "should un-bookmark a question bank" do
question_bank = add_question_bank
fj(".bookmark_bank_link img:visible").should have_attribute(:alt, "Bookmark")
fj(".bookmark_bank_link:visible").click
wait_for_ajax_requests
fj(".bookmark_bank_link img:visible").should have_attribute(:alt, "Bookmark_gray")
question_bank.reload
question_bank.bookmarked_for?(User.last).should be_false
end
it "should edit a question bank" do
new_title = "bank 2"
question_bank = add_question_bank
f("#questions .edit_bank_link").click
f("#assessment_question_bank_title").send_keys(new_title, :return)
wait_for_ajax_requests
question_bank.reload
question_bank.title.should == new_title
f("#questions .title").should include_text new_title
end
it "should delete a question bank" do
question_bank = add_question_bank
f("#questions .delete_bank_link").click
driver.switch_to.alert.accept
wait_for_ajaximations
question_bank.reload
question_bank.workflow_state.should == "deleted"
f("#questions .title").should be_nil
end
end

View File

@ -0,0 +1,86 @@
shared_examples_for "settings basic tests" do
it_should_behave_like "in-process server selenium tests"
before (:each) do
course_with_admin_logged_in
end
context "admins tab" do
def add_account_admin
address = "student1@example.com"
f(".add_users_link").click
f("textarea.user_list").send_keys(address)
f(".verify_syntax_button").click
wait_for_ajax_requests
f("#user_lists_processed_people .person").text.should == address
f(".add_users_button").click
wait_for_ajax_requests
user = User.find_by_name(address)
user.should be_present
admin = AccountUser.find_by_user_id(user.id)
admin.should be_present
admin.membership_type.should == "AccountAdmin"
f("#enrollment_#{admin.id} .email").text.should == address
admin.id
end
before (:each) do
get "/accounts/#{account.id}/settings"
f("#tab-users-link").click
end
it "should add an account admin" do
add_account_admin
end
it "should delete an account admin" do
admin_id = add_account_admin
f("#enrollment_#{admin_id} .remove_account_user_link").click
driver.switch_to.alert.accept
wait_for_ajax_requests
AccountUser.find_by_id(admin_id).should be_nil
end
end
context "account settings" do
def click_submit
submit_form("#account_settings")
wait_for_ajax_requests
end
before (:each) do
get account_settings_url
end
it "should change the account name " do
new_account_name = 'new default account name'
replace_content(f("#account_name"), new_account_name)
click_submit
account.reload
account.name.should == new_account_name
f("#account_name").should have_value(new_account_name)
end
it "should change the default file quota" do
mb = 300
quota_input = f("#account_default_course_storage_quota")
quota_input.should have_value("500")
replace_content(quota_input, mb)
click_submit
bytes = mb * 1048576
account.reload
account.default_storage_quota.should == bytes
fj("#account_default_course_storage_quota").should have_value("300") # fj to avoid selenium caching
end
it "should change the default language to spanish" do
f("#account_default_locale option[value='es']").click
click_submit
account.reload
account.default_locale.should == "es"
f("label[for='account_name']").text.should include_text("Nombre de Cuenta")
end
end
end

View File

@ -0,0 +1,66 @@
shared_examples_for "statistics basic tests" do
it_should_behave_like "in-process server selenium tests"
def item_lists
ff('.item_list')
end
def validate_item_list(css, header_text)
f(css).text.should include_text(header_text)
end
context "with admin initially logged in" do
before (:each) do
@course = Course.create!(:name => 'stats', :account => account)
@course.offer!
admin_logged_in
end
it "should validate recently started courses display" do
pending('list is not available on sub account level') if account != Account.default
get url
validate_item_list(list_css[:created], @course.name)
end
it "should validate recently started courses display" do
pending('spec is broken on sub account level') if account != Account.default
get url
validate_item_list(list_css[:started], @course.name)
end
it "should validate no info in list display" do
get url
validate_item_list(list_css[:ended], 'None to show')
end
it "should validate link works in list" do
pending('spec is broken on sub account level') if account != Account.default
get url
expect_new_page_load { f(list_css[:started]).find_element(:css, '.header').click }
f('#section-tabs-header').should include_text(@course.name)
end
it "should validate recently ended courses display" do
pending('spec is broken on sub account level') if account != Account.default
concluded_course = Course.create!(:name => 'concluded course', :account => account)
concluded_course.update_attributes(:conclude_at => 1.day.ago)
get url
validate_item_list(list_css[:ended], concluded_course.name)
end
end
it "should validate recently logged-in courses display" do
course = Course.create!(:name => 'new course', :account => account)
course.offer!
student = User.create!(:name => 'Example Student')
student.register!
pseudonym = student.pseudonyms.create!(:unique_id => 'student@example.com', :password => 'asdfasdf', :password_confirmation => 'asdfasdf')
course.enroll_user(student, 'StudentEnrollment').accept!
login_as(pseudonym.unique_id, 'asdfasdf')
driver.navigate.to(app_host + '/logout')
admin_logged_in
get url
validate_item_list(list_css[:logged_in], student.name)
end
end

View File

@ -0,0 +1,15 @@
require File.expand_path(File.dirname(__FILE__) + '/../..//helpers/shared_user_methods')
shared_examples_for "users basic tests" do
it_should_behave_like "in-process server selenium tests"
it "should add a new user" do
pending('newly added user in sub account does not show up') if account != Account.default
course_with_admin_logged_in
get url
user = add_user(opts)
refresh_page #we need to refresh the page to see the user
f("#user_#{user.id}").should be_displayed
f("#user_#{user.id}").should include_text(opts[:name])
end
end

View File

@ -2,258 +2,256 @@ require File.expand_path(File.dirname(__FILE__) + '/../common')
shared_examples_for "outcome tests" do
it_should_behave_like "in-process server selenium tests"
shared_examples_for "outcome specs" do
before (:each) do
who_to_login == 'teacher' ? course_with_teacher_logged_in : course_with_admin_logged_in
end
before (:each) do
who_to_login == 'teacher' ? course_with_teacher_logged_in : course_with_admin_logged_in
end
it "should create a learning outcome with a new rating" do
it "should create a learning outcome with a new rating" do
get outcome_url
#create learning outcome
f('.add_outcome_link').click
outcome_name = 'first new outcome'
f('#learning_outcome_short_description').send_keys(outcome_name)
f('.switch_views_link').click
f('#learning_outcome_description').send_keys('new learning outcome')
#add a new rating
outcome_form = f('#edit_outcome_form')
outcome_form.find_element(:css, '.add_rating_link').click
rating_table = outcome_form.find_element(:css, '.rubric_criterion')
new_rating_row = fj('#edit_outcome_form .rubric_criterion tr:nth-child(6)')
new_rating_row.find_element(:css, 'input.outcome_rating_description').clear
new_rating_row.find_element(:css, 'input.outcome_rating_description').send_keys('New Expectation')
new_rating_points = new_rating_row.find_element(:name, 'learning_outcome[rubric_criterion][ratings][5][description]')
replace_content(new_rating_points, '1')
#delete a rating
rating_table.find_element(:css, 'tr:nth-child(4) .delete_rating_link img').click
threshold_input = rating_table.find_element(:name, 'learning_outcome[rubric_criterion][mastery_points]')
replace_content(threshold_input, '4')
submit_form(outcome_form)
wait_for_ajaximations
keep_trying_until { fj("#outcomes .learning_outcome .short_description").text.should == outcome_name }
f('.show_details_link').click
ffj('#outcomes .rubric_criterion .rating:visible').size.should eql(3)
end
it "should edit a learning outcome" do
edit_name = 'edit outcome'
who_to_login == 'teacher' ? @context = @course : @context = account
outcome_model
get outcome_url
driver.execute_script("$('#outcome_#{@outcome.id} .edit_outcome_link').hover().click()")
replace_content(f('#learning_outcome_short_description'), edit_name)
submit_form('#edit_outcome_form')
wait_for_ajaximations
LearningOutcome.find_by_short_description(edit_name).should be_present
f('.short_description').text.should == edit_name
end
it "should delete a learning outcome" do
who_to_login == 'teacher' ? @context = @course : @context = account
outcome_model
get outcome_url
driver.execute_script("$('#outcome_#{@outcome.id} .really_delete_outcome_link').hover().click()")
driver.switch_to.alert.accept
wait_for_ajaximations
LearningOutcome.find_by_id(@outcome.id).workflow_state.should == 'deleted'
refresh_page # to make sure it was correctly deleted
ff('.learning_outcome').each { |outcome_element| outcome_element.should_not be_displayed }
end
def create_groups(names)
button = f('.add_outcome_group_link')
records = []
names.each do |name|
button.click
f('#learning_outcome_group_title').send_keys(name, :enter)
wait_for_ajax_requests
records << LearningOutcomeGroup.find_by_title(name)
end
records
end
def create_outcomes(names)
button = f('.add_outcome_link')
records = []
names.each do |name|
button.click
f('#learning_outcome_short_description').send_keys(name, :enter)
wait_for_ajax_requests
records << LearningOutcome.find_by_short_description(name)
end
records
end
context 'drag and drop' do
before(:each) do
get outcome_url
@group1, @group2 = create_groups ['group1', 'group2']
@outcome1, @outcome2 = create_outcomes ['outcome1', 'outcome2']
get outcome_url
#create learning outcome
f('.add_outcome_link').click
outcome_name = 'first new outcome'
f('#learning_outcome_short_description').send_keys(outcome_name)
f('.switch_views_link').click
f('#learning_outcome_description').send_keys('new learning outcome')
#add a new rating
outcome_form = f('#edit_outcome_form')
outcome_form.find_element(:css, '.add_rating_link').click
rating_table = outcome_form.find_element(:css, '.rubric_criterion')
new_rating_row = fj('#edit_outcome_form .rubric_criterion tr:nth-child(6)')
new_rating_row.find_element(:css, 'input.outcome_rating_description').clear
new_rating_row.find_element(:css, 'input.outcome_rating_description').send_keys('New Expectation')
new_rating_points = new_rating_row.find_element(:name, 'learning_outcome[rubric_criterion][ratings][5][description]')
replace_content(new_rating_points, '1')
#delete a rating
rating_table.find_element(:css, 'tr:nth-child(4) .delete_rating_link img').click
threshold_input = rating_table.find_element(:name, 'learning_outcome[rubric_criterion][mastery_points]')
replace_content(threshold_input, '4')
submit_form(outcome_form)
wait_for_ajaximations
keep_trying_until { fj("#outcomes .learning_outcome .short_description").text.should == outcome_name }
f('.show_details_link').click
ffj('#outcomes .rubric_criterion .rating:visible').size.should eql(3)
# drag/drop handles
@gh1, @gh2, @oh1, @oh2 = ff('.reorder_link')
# drag and drop is flakey in selenium mac
load_simulate_js
end
it "should edit a learning outcome" do
edit_name = 'edit outcome'
who_to_login == 'teacher' ? @context = @course : @context = Account.default
outcome_model
get outcome_url
driver.execute_script("$('#outcome_#{@outcome.id} .edit_outcome_link').hover().click()")
replace_content(f('#learning_outcome_short_description'), edit_name)
submit_form('#edit_outcome_form')
wait_for_ajaximations
LearningOutcome.find_by_short_description(edit_name).should be_present
f('.short_description').text.should == edit_name
it "should allow dragging and dropping outside of the outcomes list without throwing an error" do
draggable = f('.outcome_group .reorder_link')
drag_to = f('#section-tabs')
driver.action.drag_and_drop(draggable, drag_to).perform
driver.execute_script('return INST.errorCount;').should eql 0
end
it "should delete a learning outcome" do
who_to_login == 'teacher' ? @context = @course : @context = Account.default
outcome_model
get outcome_url
driver.execute_script("$('#outcome_#{@outcome.id} .really_delete_outcome_link').hover().click()")
driver.switch_to.alert.accept
wait_for_ajaximations
LearningOutcome.find_by_id(@outcome.id).workflow_state.should == 'deleted'
refresh_page # to make sure it was correctly deleted
ff('.learning_outcome').each { |outcome_element| outcome_element.should_not be_displayed }
end
def create_groups(names)
button = f('.add_outcome_group_link')
records = []
names.each do |name|
button.click
f('#learning_outcome_group_title').send_keys(name, :enter)
wait_for_ajax_requests
records << LearningOutcomeGroup.find_by_title(name)
end
records
end
def create_outcomes(names)
button = f('.add_outcome_link')
records = []
names.each do |name|
button.click
f('#learning_outcome_short_description').send_keys(name, :enter)
wait_for_ajax_requests
records << LearningOutcome.find_by_short_description(name)
end
records
end
context 'drag and drop' do
before(:each) do
get outcome_url
@group1, @group2 = create_groups ['group1', 'group2']
@outcome1, @outcome2 = create_outcomes ['outcome1', 'outcome2']
get outcome_url
# drag/drop handles
@gh1, @gh2, @oh1, @oh2 = ff('.reorder_link')
# drag and drop is flakey in selenium mac
load_simulate_js
end
it "should allow dragging and dropping outside of the outcomes list without throwing an error" do
draggable = f('.outcome_group .reorder_link')
drag_to = f('#section-tabs')
driver.action.drag_and_drop(draggable, drag_to).perform
driver.execute_script('return INST.errorCount;').should eql 0
end
it "re-order sibling outcomes" do
# <-
# g1
# g2
# o1
# o2->
driver.action.drag_and_drop(@oh2, @gh1).perform
wait_for_js
wait_for_ajax_requests
get outcome_url
# get the elements in the order we expect
o2, g1, g2, o1 = ff('#outcomes > .outcome_group .outcome_item')
# verify they are in the order we expect
g1.attribute(:id).should == "group_#{@group1.id}"
g2.attribute(:id).should == "group_#{@group2.id}"
o1.attribute(:id).should == "outcome_#{@outcome1.id}"
o2.attribute(:id).should == "outcome_#{@outcome2.id}"
end
it "should nest an outcome into a group" do
# g1<-
# g2
# o1
# o2->
drag_with_js('.reorder_link:eq(3)', 0, -165)
wait_for_ajax_requests
get outcome_url
only_first_level_items_selector = '#outcomes > .outcome_group > .child_outcomes > .outcome_item'
g1, g2, o1, *extras = ff(only_first_level_items_selector)
# test top level items, make sure the fourth is gone and the others are as we expect
extras.length.should == 0
g1.attribute(:id).should == "group_#{@group1.id}"
g2.attribute(:id).should == "group_#{@group2.id}"
o1.attribute(:id).should == "outcome_#{@outcome1.id}"
# check that the outcome is nested
o2 = g1.find_element(:id, "outcome_#{@outcome2.id}")
o2.should be_displayed
end
it 'should re-order groups with children' do
# first we have to nest the outcomes
# g1<-
# ->g2
# o1->
# <-o2
# drag o1 into g1
drag_with_js('.reorder_link:eq(2)', 0, -100)
wait_for_ajax_requests
# drag o2 into g2
drag_with_js('.reorder_link:eq(3)', 0, -30)
wait_for_ajax_requests
# re-order the groups
# ->
# g1
# o1
# <-g2
# o2
driver.action.drag_and_drop(@gh2, @gh1).perform
drag_with_js('.reorder_link:eq(2)', 0, -200)
wait_for_ajax_requests
get outcome_url
only_first_level_items_selector = '#outcomes > .outcome_group > .child_outcomes > .outcome_item'
# get them in the order we expect
g2, g1, *extras = ff(only_first_level_items_selector)
# make sure we only have two
extras.length.should == 0
# verify they're in order
g1.attribute(:id).should == "group_#{@group1.id}"
g2.attribute(:id).should == "group_#{@group2.id}"
g1.find_element(:id, "outcome_#{@outcome1.id}").should be_displayed
g2.find_element(:id, "outcome_#{@outcome2.id}").should be_displayed
end
end
it "should create a rubric" do
who_to_login == 'teacher' ? @context = @course : @context = Account.default
@first_outcome = outcome_model({:context => @context})
@second_outcome = outcome_model({:short_description => 'second outcome', :context => @context})
it "re-order sibling outcomes" do
# <-
# g1
# g2
# o1
# o2->
driver.action.drag_and_drop(@oh2, @gh1).perform
wait_for_js
wait_for_ajax_requests
get outcome_url
#create rubric
find_with_jquery('#right-side a:last-child').click
f('.add_rubric_link').click
replace_content(f('#rubrics input[name="title"]'), 'New Rubric')
# get the elements in the order we expect
o2, g1, g2, o1 = ff('#outcomes > .outcome_group .outcome_item')
#edit first criterion
driver.execute_script('$(".links").show();') #couldn't get mouseover to work
f('#criterion_1 .criterion_description .edit_criterion_link img').click
replace_content(f('#edit_criterion_form input[name="description"]'), 'important criterion')
submit_form('#edit_criterion_form')
rating_row = find_with_jquery('#criterion_1 td:nth-child(2) table tr')
rating_row.find_element(:css, '.edit_rating_link img').click
replace_content(rating_row.find_element(:css, '#edit_rating_form input[name="description"]'), 'really good')
replace_content(rating_row.find_element(:css, '#edit_rating_form input[name="points"]'), '3')
submit_form('#edit_rating_form')
sleep 1
replace_content(f('#criterion_1 .criterion_points'), '4')
# verify they are in the order we expect
g1.attribute(:id).should == "group_#{@group1.id}"
g2.attribute(:id).should == "group_#{@group2.id}"
o1.attribute(:id).should == "outcome_#{@outcome1.id}"
o2.attribute(:id).should == "outcome_#{@outcome2.id}"
end
#add criterion
f('#rubric_new .add_criterion_link').click
replace_content(f('#edit_criterion_form input[name="description"]'), 'second criterion')
submit_form('#edit_criterion_form')
it "should nest an outcome into a group" do
# g1<-
# g2
# o1
# o2->
drag_with_js('.reorder_link:eq(3)', 0, -165)
wait_for_ajax_requests
get outcome_url
only_first_level_items_selector = '#outcomes > .outcome_group > .child_outcomes > .outcome_item'
g1, g2, o1, *extras = ff(only_first_level_items_selector)
#add outcome
f('#rubric_new .find_outcome_link').click
f('#find_outcome_criterion_dialog').should be_displayed
outcome_div = f('#find_outcome_criterion_dialog table tr td.right .outcome_' + @first_outcome.id.to_s)
outcome_div.find_element(:css, '.short_description').text.should == @first_outcome.short_description
unless is_checked("#find_outcome_criterion_dialog .criterion_for_scoring")
f("#find_outcome_criterion_dialog .criterion_for_scoring").click
end
outcome_div.find_element(:css, '.select_outcome_link').click
f('#find_outcome_criterion_dialog').should_not be_displayed
f('#criterion_3 .learning_outcome_flag').should be_displayed
f('#criterion_3 td.points_form').should include_text('3')
# test top level items, make sure the fourth is gone and the others are as we expect
extras.length.should == 0
g1.attribute(:id).should == "group_#{@group1.id}"
g2.attribute(:id).should == "group_#{@group2.id}"
o1.attribute(:id).should == "outcome_#{@outcome1.id}"
#add second outcome
f('#rubric_new .find_outcome_link').click
find_with_jquery('#find_outcome_criterion_dialog .outcomes_select:last-child').click
outcome_div = find_with_jquery('#find_outcome_criterion_dialog table tr td.right .outcome_' + @second_outcome.id.to_s)
outcome_div.find_element(:css, '.select_outcome_link').click
f('#find_outcome_criterion_dialog').should_not be_displayed
f('#criterion_4 .learning_outcome_flag').should be_displayed
sleep 1 #wait for points to recalculate
# check that the outcome is nested
o2 = g1.find_element(:id, "outcome_#{@outcome2.id}")
o2.should be_displayed
end
#save and check rubric
submit_form('#edit_rubric_form')
wait_for_ajaximations
f('#rubrics .edit_rubric_link img').should be_displayed
ffj('#rubrics tr.criterion:visible').size.should == 4
refresh_page
details = fj('#rubrics .details')
details.should include_text('4 criteria')
details.should include_text('15 points possible')
it 'should re-order groups with children' do
# first we have to nest the outcomes
# g1<-
# ->g2
# o1->
# <-o2
# drag o1 into g1
drag_with_js('.reorder_link:eq(2)', 0, -100)
wait_for_ajax_requests
# drag o2 into g2
drag_with_js('.reorder_link:eq(3)', 0, -30)
wait_for_ajax_requests
# re-order the groups
# ->
# g1
# o1
# <-g2
# o2
driver.action.drag_and_drop(@gh2, @gh1).perform
drag_with_js('.reorder_link:eq(2)', 0, -200)
wait_for_ajax_requests
get outcome_url
only_first_level_items_selector = '#outcomes > .outcome_group > .child_outcomes > .outcome_item'
# get them in the order we expect
g2, g1, *extras = ff(only_first_level_items_selector)
# make sure we only have two
extras.length.should == 0
# verify they're in order
g1.attribute(:id).should == "group_#{@group1.id}"
g2.attribute(:id).should == "group_#{@group2.id}"
g1.find_element(:id, "outcome_#{@outcome1.id}").should be_displayed
g2.find_element(:id, "outcome_#{@outcome2.id}").should be_displayed
end
end
it "should create a rubric" do
who_to_login == 'teacher' ? @context = @course : @context = account
@first_outcome = outcome_model({:context => @context})
@second_outcome = outcome_model({:short_description => 'second outcome', :context => @context})
get outcome_url
#create rubric
find_with_jquery('#right-side a:last-child').click
f('.add_rubric_link').click
replace_content(f('#rubrics input[name="title"]'), 'New Rubric')
#edit first criterion
driver.execute_script('$(".links").show();') #couldn't get mouseover to work
f('#criterion_1 .criterion_description .edit_criterion_link img').click
replace_content(f('#edit_criterion_form input[name="description"]'), 'important criterion')
submit_form('#edit_criterion_form')
rating_row = find_with_jquery('#criterion_1 td:nth-child(2) table tr')
rating_row.find_element(:css, '.edit_rating_link img').click
replace_content(rating_row.find_element(:css, '#edit_rating_form input[name="description"]'), 'really good')
replace_content(rating_row.find_element(:css, '#edit_rating_form input[name="points"]'), '3')
submit_form('#edit_rating_form')
sleep 1
replace_content(f('#criterion_1 .criterion_points'), '4')
#add criterion
f('#rubric_new .add_criterion_link').click
replace_content(f('#edit_criterion_form input[name="description"]'), 'second criterion')
submit_form('#edit_criterion_form')
#add outcome
f('#rubric_new .find_outcome_link').click
f('#find_outcome_criterion_dialog').should be_displayed
outcome_div = f('#find_outcome_criterion_dialog table tr td.right .outcome_' + @first_outcome.id.to_s)
outcome_div.find_element(:css, '.short_description').text.should == @first_outcome.short_description
unless is_checked("#find_outcome_criterion_dialog .criterion_for_scoring")
f("#find_outcome_criterion_dialog .criterion_for_scoring").click
end
outcome_div.find_element(:css, '.select_outcome_link').click
f('#find_outcome_criterion_dialog').should_not be_displayed
f('#criterion_3 .learning_outcome_flag').should be_displayed
f('#criterion_3 td.points_form').should include_text('3')
#add second outcome
f('#rubric_new .find_outcome_link').click
find_with_jquery('#find_outcome_criterion_dialog .outcomes_select:last-child').click
outcome_div = find_with_jquery('#find_outcome_criterion_dialog table tr td.right .outcome_' + @second_outcome.id.to_s)
outcome_div.find_element(:css, '.select_outcome_link').click
f('#find_outcome_criterion_dialog').should_not be_displayed
f('#criterion_4 .learning_outcome_flag').should be_displayed
sleep 1 #wait for points to recalculate
#save and check rubric
submit_form('#edit_rubric_form')
wait_for_ajaximations
f('#rubrics .edit_rubric_link img').should be_displayed
ffj('#rubrics tr.criterion:visible').size.should == 4
refresh_page
details = fj('#rubrics .details')
details.should include_text('4 criteria')
details.should include_text('15 points possible')
end
end

View File

@ -2,68 +2,88 @@ require File.expand_path(File.dirname(__FILE__) + '/../common')
shared_examples_for "rubric tests" do
it_should_behave_like "in-process server selenium tests"
shared_examples_for "rubric specs" do
before (:each) do
who_to_login == 'teacher' ? course_with_teacher_logged_in : course_with_admin_logged_in
end
before (:each) do
who_to_login == 'teacher' ? course_with_teacher_logged_in : course_with_admin_logged_in
end
def create_rubric_with_criterion_points(points)
get rubric_url
def create_rubric_with_criterion_points(points)
get rubric_url
f("#right-side-wrapper .add_rubric_link").click
criterion_points = f("#criterion_1 .criterion_points")
set_value(criterion_points, points.to_s)
criterion_points.send_keys(:return)
submit_form('#edit_rubric_form')
wait_for_ajaximations
end
f("#right-side-wrapper .add_rubric_link").click
criterion_points = f("#criterion_1 .criterion_points")
set_value(criterion_points, points.to_s)
criterion_points.send_keys(:return)
submit_form('#edit_rubric_form')
wait_for_ajaximations
end
def edit_rubric_after_updating
fj(".rubric .edit_rubric_link:visible").click
driver.find_element(:tag_name, "body").click
end
def edit_rubric_after_updating
fj(".rubric .edit_rubric_link:visible").click
driver.find_element(:tag_name, "body").click
end
# should be in editing mode before calling
def split_ratings(idx)
rating = ffj(".rubric .criterion:visible .rating")[idx]
driver.action.move_to(rating).perform
# should be in editing mode before calling
def split_ratings(idx)
rating = ffj(".rubric .criterion:visible .rating")[idx]
driver.action.move_to(rating).perform
driver.execute_script <<-JS
driver.execute_script <<-JS
var $rating = $('.rubric .criterion:visible .rating:eq(#{idx})');
$rating.addClass('add_column add_right');
$rating.prev().addClass('add_left');
$rating.click();
JS
end
JS
end
it "should allow fractional points" do
create_rubric_with_criterion_points "5.5"
fj(".rubric .criterion:visible .display_criterion_points").text.should == '5.5'
fj(".rubric .criterion:visible .rating .points").text.should == '5.5'
end
it "should edit a rubric" do
edit_title = 'edited rubric'
create_rubric_with_criterion_points "5"
rubric = Rubric.last
f('.edit_rubric_link').click
replace_content(ff("#rubric_#{rubric.id} .rubric_title input")[1], edit_title)
submit_form(ff("#rubric_#{rubric.id} #edit_rubric_form")[2])
wait_for_ajaximations
rubric.reload
rubric.title.should == edit_title
f('.rubric_title .title').text.should == edit_title
end
it "should round to 2 decimal places" do
create_rubric_with_criterion_points "5.249"
fj(".rubric .criterion:visible .display_criterion_points").text.should == '5.25'
end
it "should delete a rubric" do
create_rubric_with_criterion_points "5"
f('.delete_rubric_link').click
driver.switch_to.alert.accept
wait_for_ajaximations
Rubric.last.workflow_state.should == 'deleted'
ff('#rubrics .rubric').each { |rubric| rubric.should_not be_displayed }
end
it "should round to an integer when splitting" do
create_rubric_with_criterion_points "5.5"
edit_rubric_after_updating
it "should allow fractional points" do
create_rubric_with_criterion_points "5.5"
fj(".rubric .criterion:visible .display_criterion_points").text.should == '5.5'
fj(".rubric .criterion:visible .rating .points").text.should == '5.5'
end
split_ratings(1)
it "should round to 2 decimal places" do
create_rubric_with_criterion_points "5.249"
fj(".rubric .criterion:visible .display_criterion_points").text.should == '5.25'
end
ffj(".rubric .criterion:visible .rating .points")[1].text.should == '3'
end
it "should round to an integer when splitting" do
create_rubric_with_criterion_points "5.5"
edit_rubric_after_updating
it "should pick the lower value when splitting without room for an integer" do
create_rubric_with_criterion_points "0.5"
edit_rubric_after_updating
split_ratings(1)
split_ratings(1)
ffj(".rubric .criterion:visible .rating .points")[1].text.should == '3'
end
ffj(".rubric .criterion:visible .rating .points").count.should == 3
ffj(".rubric .criterion:visible .rating .points")[1].text.should == '0'
end
it "should pick the lower value when splitting without room for an integer" do
create_rubric_with_criterion_points "0.5"
edit_rubric_after_updating
split_ratings(1)
ffj(".rubric .criterion:visible .rating .points").count.should == 3
ffj(".rubric .criterion:visible .rating .points")[1].text.should == '0'
end
end

View File

@ -0,0 +1,30 @@
def add_user (opts={})
f(".add_user_link").click
name = opts[:name] ? opts[:name] : "user1"
email = opts[:email] ? opts[:email] : "user1@test.com"
sortable_name = opts[:sortable_name] ? opts[:sortable_name] : name
confirmation = opts[:confirmation] ? opts[:confirmation] : 1
short_name = opts[:short_name] ? opts[:short_name] : name
if (!short_name.eql? name)
replace_content f("#user_short_name"), short_name
end
if (!sortable_name.eql? name)
replace_content f("#user_sortable_name"), sortable_name
end
is_checked("#pseudonym_send_confirmation").should be_true
if (confirmation == 0)
f("#pseudonym_send_confirmation").click
is_checked("#pseudonym_send_confirmation").should be_false
end
f("#add_user_form #user_name").send_keys name
f("#pseudonym_unique_id").send_keys email
submit_form("#add_user_form")
wait_for_ajax_requests
user = User.first(:conditions => {:name => name})
user.should be_present
user.sortable_name.should eql sortable_name
user.short_name.should eql short_name
user.email.should eql email
user
end

View File

@ -1,11 +1,9 @@
require File.expand_path(File.dirname(__FILE__) + '/helpers/outcome_specs')
describe "course outcomes" do
it_should_behave_like "outcome tests"
describe "shared outcome specs" do
let(:outcome_url) { "/courses/#{@course.id}/outcomes" }
let(:who_to_login) { 'teacher' }
it_should_behave_like "outcome specs"
it_should_behave_like "outcome tests"
end
end

View File

@ -1,12 +1,13 @@
require File.expand_path(File.dirname(__FILE__) + '/helpers/rubrics_specs')
describe "course rubrics" do
it_should_behave_like "rubric tests"
describe "shared rubric specs" do
let(:rubric_url) { "/courses/#{@course.id}/rubrics" }
let(:who_to_login) { 'teacher' }
it_should_behave_like "rubric specs"
end
describe "shared rubric specs" do
let(:rubric_url) { "/courses/#{@course.id}/rubrics" }
let(:who_to_login) { 'teacher' }
it_should_behave_like "rubric tests"
end
describe "course rubrics" do
it_should_behave_like "in-process server selenium tests"
context "importing" do
it "should create a allow immediate editing when adding an imported rubric to a new assignment" do