add vdd specs for students, cleanup helper

Test Plan:
 - pass Jenkins
 - check for syntax errors
 - make sure new test_ids match up to an existing test case in TestRails

mhargiss,panda,11

Change-Id: Ifabf373af44c71f0585cb375272bfa26597dea51
Reviewed-on: https://gerrit.instructure.com/62016
Tested-by: Jenkins
Reviewed-by: Caleb Guanzon <cguanzon@instructure.com>
Product-Review: Caleb Guanzon <cguanzon@instructure.com>
QA-Review: Caleb Guanzon <cguanzon@instructure.com>
This commit is contained in:
Michael Hargiss 2015-08-26 11:20:10 -06:00 committed by Caleb Guanzon
parent 89aed994f9
commit 18f43eeaec
10 changed files with 163 additions and 110 deletions

View File

@ -150,17 +150,17 @@ module AssignmentOverridesSeleniumHelper
@new_section = new_section
end
def prepare_multiple_due_dates_scenario
def prepare_vdd_scenario
@course = course_model
@course.name = 'Test Course'
@course.name = 'VDD Course'
@course.offer!
# must have two sections: A and B
@section_a = @course.course_sections.create!(name: 'Section A')
@section_b = @course.course_sections.create!(name: 'Section B')
# must have a published quiz with multiple due dates
create_quiz_with_multiple_due_dates
# must have a published quiz with variable due dates
create_quiz_with_vdd
end
def enroll_section_a_student
@ -174,7 +174,7 @@ module AssignmentOverridesSeleniumHelper
end
def prepare_vdd_scenario_for_first_observer
prepare_multiple_due_dates_scenario
prepare_vdd_scenario
enroll_section_a_student
enroll_section_b_student
@ -200,7 +200,7 @@ module AssignmentOverridesSeleniumHelper
end
def prepare_vdd_scenario_for_second_observer
prepare_multiple_due_dates_scenario
prepare_vdd_scenario
enroll_section_b_student
@ -215,33 +215,51 @@ module AssignmentOverridesSeleniumHelper
)
end
def prepare_multiple_due_dates_scenario_for_teacher
prepare_multiple_due_dates_scenario
def prepare_vdd_scenario_for_first_student
prepare_vdd_scenario
enroll_section_a_student
end
def prepare_vdd_scenario_for_second_student
prepare_vdd_scenario
enroll_section_b_student
end
def prepare_vdd_scenario_for_teacher
prepare_vdd_scenario
@teacher1 = user_with_pseudonym(username: 'teacher1@example.com', active_all: 1)
@course.enroll_teacher(@teacher1, section: @section_a)
@course.enroll_teacher(@teacher1, section: @section_b)
end
def prepare_multiple_due_dates_scenario_for_ta
prepare_multiple_due_dates_scenario
def prepare_vdd_scenario_for_ta
prepare_vdd_scenario
@ta1 = user_with_pseudonym(username: 'ta1@example.com', active_all: 1)
@course.enroll_ta(@ta1, section: @section_a)
@course.enroll_ta(@ta1, section: @section_b)
end
def create_quiz_with_multiple_due_dates
def create_quiz_with_vdd
assignment_quiz([], course: @course)
set_quiz_dates_for_section_a
set_quiz_dates_for_section_b
end
def set_quiz_dates_for_section_a
now = Time.zone.now
@due_at_a = now.advance(days: 2)
@unlock_at_a = now
@lock_at_a = now.advance(days: 3)
assignment_quiz([], course: @course)
@quiz.update_attribute(:due_at, @due_at_a)
@quiz.update_attribute(:unlock_at, @unlock_at_a)
@quiz.update_attribute(:lock_at, @lock_at_a)
end
def set_quiz_dates_for_section_b
now = Time.zone.now
@due_at_b = now.advance(days: 4)
@unlock_at_b = now.advance(days: 1)
@lock_at_b = now.advance(days: 4)
@ -253,23 +271,32 @@ module AssignmentOverridesSeleniumHelper
unlock_at: @unlock_at_b,
lock_at: @lock_at_b
)
@quiz
end
# Formatted output: Mmm d, e.g. 'Jan 1'
def format_date_for_view(date)
date.strftime('%b %-d')
end
# Formatted output: Mmm d at h, e.g. 'Jan 1 at 1:01pm'
# Note: Removes on-the-hour minutes, e.g. '5:00pm' becomes '5pm'
def format_time_for_view(time)
time.strftime('%b %-d at %-l:%M') << time.strftime('%p').downcase
formatter = '%b %-d at %-l'
formatted_time = time.strftime(formatter)
on_the_hour = true if time.strftime(':%M') == ':00'
formatted_time << time.strftime(':%M') unless on_the_hour
# append 'am' or 'pm'
formatted_time << time.strftime('%p').downcase
end
def obtain_due_date(section)
case section
when @section_a
date = obtain_date_from_quiz_summary(1, 1)
date = obtain_date_from_quiz_show_page(1, 1)
when @section_b
date = obtain_date_from_quiz_summary(2, 1)
date = obtain_date_from_quiz_show_page(2, 1)
end
date
end
@ -277,9 +304,9 @@ module AssignmentOverridesSeleniumHelper
def obtain_availability_start_date(section)
case section
when @section_a
date = obtain_date_from_quiz_summary(1, 3)
date = obtain_date_from_quiz_show_page(1, 3)
when @section_b
date = obtain_date_from_quiz_summary(2, 3)
date = obtain_date_from_quiz_show_page(2, 3)
end
date
end
@ -287,14 +314,14 @@ module AssignmentOverridesSeleniumHelper
def obtain_availability_end_date(section)
case section
when @section_a
date = obtain_date_from_quiz_summary(1, 4)
date = obtain_date_from_quiz_show_page(1, 4)
when @section_b
date = obtain_date_from_quiz_summary(2, 4)
date = obtain_date_from_quiz_show_page(2, 4)
end
date
end
def obtain_date_from_quiz_summary(row_number, cell_number, load_page=false)
def obtain_date_from_quiz_show_page(row_number, cell_number, load_page=false)
get "/accounts/#{@account.id}/courses/#{@course.id}/quizzes/#{@quiz.id}" if load_page
fj("tr:nth-child(#{row_number}) td:nth-child(#{cell_number}) .screenreader-only", f('.assignment-dates'))
end
@ -303,7 +330,7 @@ module AssignmentOverridesSeleniumHelper
expect(f('#quiz_show').text).to include_text("#{message}")
end
def validate_quiz_dates(context_selector, message)
def validate_vdd_quiz_tooltip_dates(context_selector, message)
keep_trying_until(2) do
driver.mouse.move_to fln('Multiple Dates', f("#{context_selector}"))
expect(fj('.ui-tooltip')).to include_text("#{message}")

View File

@ -16,22 +16,22 @@ describe 'viewing a quiz with variable due dates on the quizzes index page' do
it 'shows the due dates for Section A', priority: "2", test_id: 282169 do
skip('Bug ticket created: CNVS-22794')
validate_quiz_dates('.date-due', "Everyone else\n#{format_date_for_view(@due_at_a)}")
validate_vdd_quiz_tooltip_dates('.date-due', "Everyone else\n#{format_date_for_view(@due_at_a)}")
end
it 'shows the due dates for Section B', priority: "2", test_id: 315666 do
skip('Bug ticket created: CNVS-22794')
validate_quiz_dates('.date-due', "#{@section_b.name}\n#{format_date_for_view(@due_at_b)}")
validate_vdd_quiz_tooltip_dates('.date-due', "#{@section_b.name}\n#{format_date_for_view(@due_at_b)}")
end
it 'shows the availability dates for Section A', priority: "2", test_id: 282397 do
skip('Bug ticket created: CNVS-22793')
validate_quiz_dates('.date-available', "Everyone else\nAvailable until #{format_date_for_view(@lock_at_a)}")
validate_vdd_quiz_tooltip_dates('.date-available', "Everyone else\nAvailable until #{format_date_for_view(@lock_at_a)}")
end
it 'shows the availability dates for Section B', priority: "2", test_id: 315669 do
skip('Bug ticket created: CNVS-22793')
validate_quiz_dates('.date-available', "#{@section_b.name}\nNot available until #{format_date_for_view(@unlock_at_b)}")
validate_vdd_quiz_tooltip_dates('.date-available', "#{@section_b.name}\nNot available until #{format_date_for_view(@unlock_at_b)}")
end
end

View File

@ -0,0 +1,41 @@
require File.expand_path(File.dirname(__FILE__) + '/../helpers/quizzes_common')
require File.expand_path(File.dirname(__FILE__) + '/../helpers/assignment_overrides')
describe 'viewing a quiz with variable due dates on the quizzes index page' do
include AssignmentOverridesSeleniumHelper
include_context 'in-process server selenium tests'
context 'as a student in Section A' do
before(:all) { prepare_vdd_scenario_for_first_student }
before(:each) do
user_session(@student1)
get "/courses/#{@course.id}/quizzes"
end
it 'shows the due dates for Section A', priority: "1", test_id: 282165 do
expect(f('.date-due')).to include_text("Due #{format_time_for_view(@due_at_a)}")
end
it 'shows the availability dates for Section A', priority: "1", test_id: 282389 do
expect(f('.date-available')).to include_text("Available until #{format_date_for_view(@lock_at_a)}")
end
end
context 'as a student in Section B' do
before(:all) { prepare_vdd_scenario_for_second_student }
before(:each) do
user_session(@student2)
get "/courses/#{@course.id}/quizzes"
end
it 'shows the due dates for Section B', priority: "1", test_id: 282166 do
expect(f('.date-due')).to include_text("Due #{format_time_for_view(@due_at_b)}")
end
it 'shows the availability dates for Section B', priority: "1", test_id: 282391 do
expect(f('.date-available')).to include_text("Not available until #{format_date_for_view(@unlock_at_b)}")
end
end
end

View File

@ -5,30 +5,28 @@ describe 'viewing a quiz with variable due dates on the quizzes index page' do
include AssignmentOverridesSeleniumHelper
include_context 'in-process server selenium tests'
before(:all) do
prepare_multiple_due_dates_scenario_for_ta
end
context 'as a TA in both sections' do
before(:all) { prepare_vdd_scenario_for_ta }
context 'with a TA in both sections' do
before(:each) do
user_session(@ta1)
get "/courses/#{@course.id}/quizzes"
end
it 'shows the due dates for Section A', priority: "2", test_id: 282168 do
validate_quiz_dates('.date-due', "Everyone else\n#{format_date_for_view(@due_at_a)}")
validate_vdd_quiz_tooltip_dates('.date-due', "Everyone else\n#{format_date_for_view(@due_at_a)}")
end
it 'shows the due dates for Section B', priority: "2", test_id: 315651 do
validate_quiz_dates('.date-due', "#{@section_b.name}\n#{format_date_for_view(@due_at_b)}")
validate_vdd_quiz_tooltip_dates('.date-due', "#{@section_b.name}\n#{format_date_for_view(@due_at_b)}")
end
it 'shows the availability dates for Section A', priority: "2", test_id: 282395 do
validate_quiz_dates('.date-available', "Everyone else\nAvailable until #{format_date_for_view(@lock_at_a)}")
validate_vdd_quiz_tooltip_dates('.date-available', "Everyone else\nAvailable until #{format_date_for_view(@lock_at_a)}")
end
it 'shows the availability dates for Section B', priority: "2", test_id: 315653 do
validate_quiz_dates('.date-available', "#{@section_b.name}\nNot available until #{format_date_for_view(@unlock_at_b)}")
validate_vdd_quiz_tooltip_dates('.date-available', "#{@section_b.name}\nNot available until #{format_date_for_view(@unlock_at_b)}")
end
end
end

View File

@ -5,30 +5,28 @@ describe 'viewing a quiz with variable due dates on the quizzes index page' do
include AssignmentOverridesSeleniumHelper
include_context 'in-process server selenium tests'
before(:all) do
prepare_multiple_due_dates_scenario_for_teacher
end
context 'as a teacher in both sections' do
before(:all) { prepare_vdd_scenario_for_teacher }
context 'with a teacher in both sections' do
before(:each) do
user_session(@teacher1)
get "/courses/#{@course.id}/quizzes"
end
it 'shows the due dates for Section A', priority: "1", test_id: 282167 do
validate_quiz_dates('.date-due', "Everyone else\n#{format_date_for_view(@due_at_a)}")
validate_vdd_quiz_tooltip_dates('.date-due', "Everyone else\n#{format_date_for_view(@due_at_a)}")
end
it 'shows the due dates for Section B', priority: "1", test_id: 315661 do
validate_quiz_dates('.date-due', "#{@section_b.name}\n#{format_date_for_view(@due_at_b)}")
validate_vdd_quiz_tooltip_dates('.date-due', "#{@section_b.name}\n#{format_date_for_view(@due_at_b)}")
end
it 'shows the availability dates for Section A', priority: "1", test_id: 282393 do
validate_quiz_dates('.date-available', "Everyone else\nAvailable until #{format_date_for_view(@lock_at_a)}")
validate_vdd_quiz_tooltip_dates('.date-available', "Everyone else\nAvailable until #{format_date_for_view(@lock_at_a)}")
end
it 'shows the availability dates for Section B', priority: "1", test_id: 315663 do
validate_quiz_dates('.date-available', "#{@section_b.name}\nNot available until #{format_date_for_view(@unlock_at_b)}")
validate_vdd_quiz_tooltip_dates('.date-available', "#{@section_b.name}\nNot available until #{format_date_for_view(@unlock_at_b)}")
end
end
end

View File

@ -0,0 +1,53 @@
require File.expand_path(File.dirname(__FILE__) + '/../helpers/quizzes_common')
require File.expand_path(File.dirname(__FILE__) + '/../helpers/assignment_overrides')
describe 'viewing a quiz with variable due dates on the quiz show page' do
include AssignmentOverridesSeleniumHelper
include_context 'in-process server selenium tests'
context 'as a student in Section A' do
before(:all) { prepare_vdd_scenario_for_first_student }
before(:each) do
user_session(@student1)
get "/courses/#{@course.id}/quizzes/#{@quiz.id}"
end
it 'shows the due dates for Section A', priority: "1", test_id: 315649 do
validate_quiz_show_page("Due #{format_time_for_view(@due_at_a)}")
end
it 'shows the availability dates for Section A', priority: "1", test_id: 315856 do
validate_quiz_show_page("Available #{format_time_for_view(@unlock_at_a)} - #{format_time_for_view(@lock_at_a)}")
end
it 'allows taking the quiz', priority: "1", test_id: 282390 do
expect(f('.take_quiz_button')).to be_displayed
end
end
context 'as a student in Section B' do
before(:all) { prepare_vdd_scenario_for_second_student }
before(:each) do
user_session(@student2)
get "/courses/#{@course.id}/quizzes/#{@quiz.id}"
end
it 'shows its due date', priority: "1", test_id: 315857 do
validate_quiz_show_page("Due #{format_time_for_view(@due_at_b)}")
end
it 'shows its availability dates', priority: "1", test_id: 315859 do
validate_quiz_show_page("Available #{format_time_for_view(@unlock_at_b)} - #{format_time_for_view(@lock_at_b)}")
end
it 'prevents taking the quiz', priority: "1", test_id: 324918 do
expect(f('.take_quiz_button')).to be_nil
end
it 'indicates quiz is locked', priority: "1", test_id: 282392 do
validate_quiz_show_page("This quiz is locked until #{format_time_for_view(@unlock_at_b)}")
end
end
end

View File

@ -5,11 +5,9 @@ describe 'viewing a quiz with variable due dates on the quiz show page' do
include AssignmentOverridesSeleniumHelper
include_context 'in-process server selenium tests'
before(:all) do
prepare_multiple_due_dates_scenario_for_ta
end
context 'as a TA in both sections' do
before(:all) { prepare_vdd_scenario_for_ta }
context 'with a TA in both sections' do
before(:each) do
user_session(@ta1)
get "/courses/#{@course.id}/quizzes/#{@quiz.id}"

View File

@ -5,11 +5,9 @@ describe 'viewing a quiz with variable due dates on the quiz show page' do
include AssignmentOverridesSeleniumHelper
include_context 'in-process server selenium tests'
before(:all) do
prepare_multiple_due_dates_scenario_for_teacher
end
context 'as a teacher in both sections' do
before(:all) { prepare_vdd_scenario_for_teacher }
context 'with a teacher in both sections' do
before(:each) do
user_session(@teacher1)
get "/courses/#{@course.id}/quizzes/#{@quiz.id}"

View File

@ -1,32 +0,0 @@
require File.expand_path(File.dirname(__FILE__) + '/helpers/quizzes_common')
require File.expand_path(File.dirname(__FILE__) + '/common')
require File.expand_path(File.dirname(__FILE__) + '/helpers/assignment_overrides.rb')
describe "quizzes attempts" do
include AssignmentOverridesSeleniumHelper
include_context 'in-process server selenium tests'
before :all do
@student2 = user_with_pseudonym(:username => 'student2@example.com', :active_all => 1)
@course1 = course_model
@course1.offer!
@quiz = create_quiz_with_default_due_dates
add_user_specific_due_date_override(@quiz, :due_at => Time.zone.now.advance(days: 3),
:unlock_at => Time.zone.now.advance(days:1),
:lock_at => Time.zone.now.advance(days:4))
student_in_section(@new_section, :user => @student2)
end
it "should not be accesible for student in the additional section", priority: "1",test_id: 114315 do
skip('going to replace with better test coverage in subsequent commit')
user_session(@student2)
due_at_time = @override.due_at.strftime('%b %-d at %-l:%M') << @override.due_at.strftime('%p').downcase
unlock_at_time = @override.unlock_at.strftime('%b %-d at %-l:%M') << @override.unlock_at.strftime('%p').downcase
lock_at_time = @override.lock_at.strftime('%b %-d at %-l:%M') << @override.lock_at.strftime('%p').downcase
get "/courses/#{@course1.id}/quizzes"
expect_new_page_load { f("#summary_quiz_#{@quiz.id}").click }
expect(f("#quiz_student_details").text).to include("Due #{due_at_time}")
expect(f("#quiz_student_details").text).to include("Available #{unlock_at_time} - #{lock_at_time}")
expect(f("#quiz_show").text).to include("This quiz is locked until #{unlock_at_time}")
end
end

View File

@ -1,28 +0,0 @@
require File.expand_path(File.dirname(__FILE__) + '/helpers/quizzes_common')
require File.expand_path(File.dirname(__FILE__) + '/common')
require File.expand_path(File.dirname(__FILE__) + '/helpers/assignment_overrides.rb')
describe "quizzes attempts" do
include AssignmentOverridesSeleniumHelper
include_context 'in-process server selenium tests'
before :all do
@student1 = user_with_pseudonym(:username => 'student1@example.com', :active_all => 1)
@course1 = course_with_student_logged_in(:user => @student1, :active_all => 1, :course_name => 'course1').course
@quiz = create_quiz_with_default_due_dates
add_user_specific_due_date_override(@quiz, :due_at => Time.zone.now.advance(days: 3),
:unlock_at => Time.zone.now.advance(days:1),
:lock_at => Time.zone.now.advance(days:4))
end
it "should be accesible for student in the main section", priority: "1", test_id: 114315, priority: "1" do
skip('going to replace with better test coverage in subsequent commit')
get "/courses/#{@course1.id}/quizzes"
expect_new_page_load { f("#summary_quiz_#{@quiz.id}").click }
due_at_time = @quiz.due_at.strftime('%b %-d at %-l:%M') << @quiz.due_at.strftime('%p').downcase
unlock_at_time = @quiz.unlock_at.strftime('%b %-d at %-l:%M') << @quiz.unlock_at.strftime('%p').downcase
lock_at_time = @quiz.lock_at.strftime('%b %-d at %-l:%M') << @quiz.lock_at.strftime('%p').downcase
expect(f("#quiz_student_details").text).to include("Due #{due_at_time}")
expect(f("#quiz_student_details").text).to include("Available #{unlock_at_time} - #{lock_at_time}")
end
end