Skip to content

Commit

Permalink
spot system specの移植
Browse files Browse the repository at this point in the history
  • Loading branch information
YukiWatanabe824 committed Jun 16, 2024
1 parent 6b60d19 commit 7cc3361
Showing 1 changed file with 33 additions and 40 deletions.
73 changes: 33 additions & 40 deletions spec/system/spots_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,58 +7,51 @@

let(:make_by_admin_spot) { FactoryBot.create(:spot, :make_by_admin_user) }
let(:make_by_standard_spot) { FactoryBot.create(:spot, :make_by_standard_user) }

before do
admin_user_spot = make_by_admin_spot
user_spot = make_by_standard_spot
end
let(:user) { FactoryBot.create(:user, :admin_user) }

scenario 'showing spots on map' do
visit_root_closed_modal
expect(Spot.all.length).to eq page.all('.spot_marker', visible: false).count
end

# scenario 'showing spot menu by right click on spot marker' do
# visit_root_closed_modal
# spot = spots(:one)

# find(".spot-#{spot.id}", visible: false).click(x: 50, y: 50)
# find('#new_spot_marker').right_click
# assert_selector '#spot_menu'
# end

# scenario 'showing spot info in side menu by not signed in' do
# visit_root_closed_modal
# assert_selector '#map'
# assert_selector '.mapboxgl-canvas-container'
scenario 'showing spot menu by right click on spot marker' do
visit_root_closed_modal

# spot = spots(:one)
find(".mapboxgl-map").click(x: 50, y: 50)
find('#new_spot_marker').right_click
expect(page).to have_selector '#spot_menu'
end

# find(".spot-#{spot.id}", visible: false).click(x: 0, y: -5)
# assert_selector '.spot_accident_date', text: "#{spot.accident_date.year}年#{spot.accident_date.month}月#{spot.accident_date.day}日"
# assert_selector '.spot_accident_type', text: spot.accident_type
# assert_selector '.spot_created_at', text: "#{spot.created_at.year}年#{spot.created_at.month}月#{spot.created_at.day}日"
# assert_selector '.spot_id', text: spot.id
# end
scenario 'showing spot info in side menu by not signed in' do
visit_root_closed_modal
expect(page).to have_selector '#map'
expect(page).to have_selector '.mapboxgl-canvas-container'

spot = Spot.all.first
find(".spot-#{spot.id}", visible: false).click(x: 0, y: -5)
expect(page).to have_selector '.spot_accident_date', text: "#{spot.accident_date.year}#{spot.accident_date.month}#{spot.accident_date.day}日"
expect(page).to have_selector '.spot_accident_type', text: spot.accident_type
expect(page).to have_selector '.spot_created_at', text: "#{spot.created_at.year}#{spot.created_at.month}#{spot.created_at.day}日"
expect(page).to have_selector '.spot_id', text: spot.id
end

# scenario 'create spot' do
# user = users(:watanabe)
# sign_in user
# visit_root_closed_modal
scenario 'create spot' do
sign_in user
visit_root_closed_modal

# spot = spots(:one)
spot = Spot.all.first

# find(".spot-#{spot.id}", visible: false).click(x: 50, y: 50)
# find('#new_spot_marker').right_click
# click_on('スポットを作成する')
find(".spot-#{spot.id}", visible: false).click(x: 50, y: 50)
find('#new_spot_marker').right_click
click_on('スポットを作成する')

# choose('spot_accident_type_物損事故')
# fill_in('追加情報', with: 'test')
# fill_in '事故の発生日', with: Date.new(2021, 1, 1)
# click_on('登録する')
# assert_selector '.spot_accident_type', text: '物損事故'
# assert_selector '.spot_content', text: 'test'
# end
choose('spot_accident_type_物損事故')
fill_in('追加情報', with: 'test')
fill_in '事故の発生日', with: Date.new(2021, 1, 1)
click_on('登録する')
expect(page).to have_selector '.spot_accident_type', text: '物損事故'
expect(page).to have_selector '.spot_content', text: 'test'
end

# scenario 'unknown accident date' do
# user = users(:watanabe)
Expand Down

0 comments on commit 7cc3361

Please sign in to comment.