require 'rails_helper'

describe 'welcome/testbox.html.erb', :js => true do
  context 'loading original and test' do
    describe 'any given chart' do

      before :all do
        @test_files = %w(original test test3)
        # @test_files = %w(original)
        visit "#{testbox_path}?#{@test_files.map{ |entry| "ids[]=#{entry}" }.join('&')}"
        # visit "/testbox?ids[]=original"
      end

      it do
        @test_files.each do |file|
          expect(page.find("div.#{file}")).not_to be_nil
        end
      end

    end

  end

  context 'oneValueNoExtremeOutliers' do
    before :each do
      @file = 'oneValueNoExtremeOutliers'
      visit "#{testbox_path}?ids[]=#{@file}"
      @chart_container = page.find("div.#{@file}")
    end

    it { expect(@chart_container).not_to have_selector('select') }

    it { expect(@chart_container).not_to have_selector('text.extremeOutlierLabel') }

  end


  # it { expect(page).to have_errors }
  # it { @chart_container.has_no_content? }
  # it { expect(@chart_container).not_to have_selector('select') }

  # it { expect(@chart_container).not_to have_selector('text.extremeOutlierLabel') }

end

#     it { expect(page).to have_content(@introText) }
#
#     it { expect(page).to have_selector('body select') }
#
#     context 'when no option selected' do
#       it { expect(@chart_container).not_to have_selector('svg') }
#     end
#
#     context 'when option selected' do
#
#       before do
#         find('select').find(:xpath, 'option[8]').select_option
#       end
#
#       it {expect(@chart_container).to have_selector('svg')}
#
#       it do
#         expect(@chart_container.find_all('svg').length).to equal(3)
#       end
#
#       context 'when there is an extreme Outlier label' do
#
#         before do
#           @extremeOutlierLabel = first('text.extremeOutlierLabel')
#         end
#
#         context 'when not hovering over extreme Outlier label' do
#           it { expect(page).not_to have_selector('div.toolbox')  }
#         end
#
#         context 'when hovering over extreme Outlier label' do
#           before do
#             sleep 2
#             @extremeOutlierLabel.hover
#             # page.save_and_open_screenshot
#           end
#
#           it { expect(page).to have_selector('div.tooltip') }
#
#         end
#       end
#     end
#   end
# end

# describe 'static chart' do
#
#   before do
#     @chart_container = page.find('div.static_chart')
#   end
#
#   it { expect(@chart_container).to have_selector('svg') }
#
#
# end
#
# end
