<commit_before>require File.expand_path(File.dirname(__FILE__) + '/../common')
require File.expand_path(File.dirname(__FILE__) + '/../helpers/calendar2_common')
require File.expand_path(File.dirname(__FILE__) + '/../helpers/scheduler_common')

describe "scheduler" do
  include_examples "in-process server selenium tests"
  context "as a student" do

    before (:each) do
      Account.default.tap do |a|
        a.settings[:show_scheduler]   = true
        a.settings[:agenda_view]      = true
        a.save!
      end
      course_with_student_logged_in
      make_full_screen
    end

    def reserve_appointment_manual(n)
      ffj('.fc-event')[n].click
      driver.execute_script("$('.event-details .reserve_event_link').trigger('click')")
      wait_for_ajax_requests
    end

    it "should let me reserve appointment groups for contexts I am in", :priority  => "1", test_id: 140195 do
      my_course = @course
      course_with_student(:active_all => true)
      other_course = @course

      create_appointment_group(:contexts => [other_course, my_course])

      get "/calendar2"
      click_scheduler_link
      wait_for_ajaximations
      click_appointment_link

      reserve_appointment_manual(0)
      expect(f('.fc-event')).to include_text "Reserved"
    end

    it "should allow me to cancel existing reservation and sign up for the appointment group from the calendar", :priority  => "1", test_id: 140200 do
      tomorrow = (Date.today + 1).to_s
      create_appointment_group(:max_appointments_per_participant => 1,
                               :new_appointments => [
                                   [tomorrow + ' 12:00:00', current_date = tomorrow + ' 13:00:00'],
                                   [tomorrow + ' 14:00:00', current_date = tomorrow + ' 15:00:00'],
                               ])
      get "/calendar2"
      click_scheduler_link
      click_appointment_link

      reserve_appointment_manual(0)
      expect(f('.fc-event')).to include_text "Reserved"

      # try to reserve the second appointment
      reserve_appointment_manual(1)
      fj('.ui-button:contains(Reschedule)').click
      wait_for_ajax_requests

      event1, event2 = ff('.fc-event')
      expect(event1).to include_text "Available"
      expect(event2).to include_text "Reserved"
    end

    it "should not let me book too many appointments" do
      tomorrow = (Date.today + 1).to_s
      create_appointment_group(:max_appointments_per_participant => 2,
                               :new_appointments => [
                                   [tomorrow + ' 12:00:00', current_date = tomorrow + ' 13:00:00'],
                                   [tomorrow + ' 14:00:00', current_date = tomorrow + ' 15:00:00'],<commit_msg>Fixed a hashrocket I missed in my last commit<commit_after>require File.expand_path(File.dirname(__FILE__) + '/../common')
require File.expand_path(File.dirname(__FILE__) + '/../helpers/calendar2_common')
require File.expand_path(File.dirname(__FILE__) + '/../helpers/scheduler_common')

describe "scheduler" do
  include_examples "in-process server selenium tests"
  context "as a student" do

    before (:each) do
      Account.default.tap do |a|
        a.settings[:show_scheduler]   = true
        a.settings[:agenda_view]      = true
        a.save!
      end
      course_with_student_logged_in
      make_full_screen
    end

    def reserve_appointment_manual(n)
      ffj('.fc-event')[n].click
      driver.execute_script("$('.event-details .reserve_event_link').trigger('click')")
      wait_for_ajax_requests
    end

    it "should let me reserve appointment groups for contexts I am in", :priority  => "1", test_id: 140195 do
      my_course = @course
      course_with_student(:active_all => true)
      other_course = @course

      create_appointment_group(:contexts => [other_course, my_course])

      get "/calendar2"
      click_scheduler_link
      wait_for_ajaximations
      click_appointment_link

      reserve_appointment_manual(0)
      expect(f('.fc-event')).to include_text "Reserved"
    end

    it "should allow me to cancel existing reservation and sign up for the appointment group from the calendar", priority: "1", test_id: 140200 do
      tomorrow = (Date.today + 1).to_s
      create_appointment_group(:max_appointments_per_participant => 1,
                               :new_appointments => [
                                   [tomorrow + ' 12:00:00', current_date = tomorrow + ' 13:00:00'],
                                   [tomorrow + ' 14:00:00', current_date = tomorrow + ' 15:00:00'],
                               ])
      get "/calendar2"
      click_scheduler_link
      click_appointment_link

      reserve_appointment_manual(0)
      expect(f('.fc-event')).to include_text "Reserved"

      # try to reserve the second appointment
      reserve_appointment_manual(1)
      fj('.ui-button:contains(Reschedule)').click
      wait_for_ajax_requests

      event1, event2 = ff('.fc-event')
      expect(event1).to include_text "Available"
      expect(event2).to include_text "Reserved"
    end

    it "should not let me book too many appointments" do
      tomorrow = (Date.today + 1).to_s
      create_appointment_group(:max_appointments_per_participant => 2,
                               :new_appointments => [
                                   [tomorrow + ' 12:00:00', current_date = tomorrow + ' 13:00:00'],
                                   [tomorrow + ' 14:00:00', current_date = tomorrow + ' 15:00:00'],
{'fraction_non_alphanumeric': 0.105989110707804, 'fraction_numerical': 0.027586206896551724, 'mean_word_length': 2.499047619047619, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 18, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2011862', 'n_tokens_mistral': 1741, 'n_tokens_neox': 1598, 'n_words': 351}