spec: Add spec for new scheduler
Test Plan: -passes Jenkins Change-Id: Ied9671ff1e25fcc6e3641918123431b3b79bbf60 Reviewed-on: https://gerrit.instructure.com/98307 Tested-by: Jenkins Reviewed-by: Heath Hales <hhales@instructure.com> Product-Review: Deepeeca Soundarrajan <dsoundarrajan@instructure.com> QA-Review: Deepeeca Soundarrajan <dsoundarrajan@instructure.com>
This commit is contained in:
parent
94058ccfb6
commit
116a4b8f89
|
@ -19,21 +19,46 @@ describe "scheduler" do
|
|||
before :each do
|
||||
user_session(@student1)
|
||||
make_full_screen
|
||||
get "/calendar2"
|
||||
end
|
||||
|
||||
it "shows the find appointment button with feature flag turned on", priority: "1", test_id: 2908326 do
|
||||
get "/calendar2"
|
||||
it 'shows the find appointment button with feature flag turned on', priority: "1", test_id: 2908326 do
|
||||
expect(f('#select-course-component')).to contain_css("#FindAppointmentButton")
|
||||
end
|
||||
|
||||
it "changes the Find Appointment button to a close button once the modal to select courses is closed", priority: "1", test_id: 2916527 do
|
||||
get "/calendar2"
|
||||
it 'changes the Find Appointment button to a close button once the modal to select courses is closed', priority: "1", test_id: 2916527 do
|
||||
f('#FindAppointmentButton').click
|
||||
expect(f('.ReactModalPortal')).to contain_css('.ReactModal__Layout')
|
||||
expect(f('.ReactModal__Header').text).to include('Select Course')
|
||||
f('.ReactModal__Footer-Actions .btn').click
|
||||
expect(f('#FindAppointmentButton')).to include_text('Close')
|
||||
end
|
||||
|
||||
it 'shows appointment slots on calendar in Find Appointment mode', priority: "1", test_id: 2925320 do
|
||||
open_select_courses_modal(@course1.name)
|
||||
expect(ff('.fc-content .fc-title')[2]).to include_text(@app3.title)
|
||||
close_select_courses_modal
|
||||
|
||||
# open again to see if appointment group spanning two content appears on selecting the other course also
|
||||
open_select_courses_modal(@course3.name)
|
||||
expect(f('.fc-content .fc-title')).to include_text(@app3.title)
|
||||
end
|
||||
|
||||
it 'hides the already reserved appointment slot for the student', priority: "1", test_id: 2925694 do
|
||||
open_select_courses_modal(@course1.name)
|
||||
num_slots = ff('.fc-time').size
|
||||
@app1.appointments.first.reserve_for(@student2, @student2)
|
||||
# close and open again to reload the page
|
||||
close_select_courses_modal
|
||||
refresh_page
|
||||
open_select_courses_modal(@course1.name)
|
||||
expected_time = format_time_for_view(@app1.new_appointments.last.start_at)
|
||||
expect(ff('.fc-time').size).to eq(num_slots-1)
|
||||
expect(ff('.fc-content .fc-title')[0]).to include_text(@app1.title)
|
||||
actual_time = ff('.fc-time')[0].text
|
||||
expect(expected_time).to include actual_time
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -52,18 +52,24 @@ module SchedulerCommon
|
|||
@student1 = User.create!(name: 'Student 1')
|
||||
@student2 = User.create!(name: 'Student 2')
|
||||
@student3 = User.create!(name: 'Student 3')
|
||||
@teacher1 = User.create!(name: 'teacher')
|
||||
@course1.enroll_student(@student1).accept!
|
||||
@course3.enroll_student(@student1).accept!
|
||||
@course1.enroll_teacher(@teacher1).accept!
|
||||
@course1.enroll_student(@student2).accept!
|
||||
@course2.enroll_student(@student2).accept!
|
||||
@course3.enroll_student(@student3).accept!
|
||||
@course3.enroll_student(@student1).accept!
|
||||
end
|
||||
|
||||
def create_appointment_groups_for_courses
|
||||
@app1 = AppointmentGroup.create!(appointment_params(title: "Appointment 1", contexts: [@course1]))
|
||||
@app1 = AppointmentGroup.create!(title: "Appointment 1", contexts: [@course1],
|
||||
new_appointments: [[Time.zone.now, Time.zone.now + 30.minutes],
|
||||
[Time.zone.now + 30.minutes, Time.zone.now + 1.hour]],
|
||||
participants_per_appointment: 1)
|
||||
@app1.publish!
|
||||
@app2 = AppointmentGroup.create!(appointment_params(title: "Appointment 2", contexts: [@course2]))
|
||||
@app2.publish!
|
||||
@app3 = AppointmentGroup.create!(appointment_params(title: "Appointment 3", contexts: [@course1, @course2]))
|
||||
@app3 = AppointmentGroup.create!(appointment_params(title: "Appointment 3", contexts: [@course1, @course3]))
|
||||
@app3.publish!
|
||||
end
|
||||
|
||||
|
@ -72,7 +78,7 @@ module SchedulerCommon
|
|||
title: opts[:title],
|
||||
contexts: opts[:contexts],
|
||||
new_appointments: [
|
||||
[opts[:start_at] || Time.zone.now + 1.hour,
|
||||
[opts[:start_at] || Time.zone.now + 1.hour,
|
||||
opts[:end_at] || Time.zone.now + 3.hours],
|
||||
],
|
||||
participants_per_appointment: opts[:participants] || 4
|
||||
|
@ -102,6 +108,17 @@ module SchedulerCommon
|
|||
}.to change(AppointmentGroup, :count).by(1)
|
||||
end
|
||||
|
||||
def open_select_courses_modal(course_name)
|
||||
f('#FindAppointmentButton').click
|
||||
click_option('.ic-Input', course_name)
|
||||
f('.ReactModal__Footer-Actions .btn').click
|
||||
end
|
||||
|
||||
# This method closes the modal only when it is already opened. If not, it will open the modal
|
||||
def close_select_courses_modal
|
||||
f('#FindAppointmentButton').click
|
||||
end
|
||||
|
||||
def click_scheduler_link
|
||||
f('button#scheduler').click
|
||||
wait_for_ajaximations
|
||||
|
|
Loading…
Reference in New Issue