require 'spec_helper'

describe "Visitor" do

	let(:fixxpert){ create :fixxpert, availability_defaults: "{\"0\":[\"25200\", \"26100\"],\"1\":[],\"2\":[],\"3\":[],\"4\":[],\"5\":[],\"6\":[]}" }


	before do
		visit root_path
		click_button "submit_customer_fixxperts_search"
		click_link "request_expert_session_fixxpert_#{fixxpert.id}"
	end

	trade{page}

	it "on filling request session button should redirecr to signin_or_signup path", js: true do
		# Look for next sunday because there are a validation
    # for dates and it shold be in the future
    date = next_sunday


    # If next_sunday is in next month, click on the calendar
    if date.month > Date.today.month
      click_link 'calendar_next_month'
    end

    find(:xpath, "//a[@data-date='#{date.to_s}']").click
    select '30', from: 'expert_session_length'
    sleep 1
    find(:xpath, "//div[@data-block='25200']").click

    click_button 'submit'

	end

end