Skip to content

Commit

Permalink
Add tests for pintips, kineticist links and backglass images
Browse files Browse the repository at this point in the history
  • Loading branch information
RyanTG committed Oct 14, 2024
1 parent 307ba96 commit 6129364
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions spec/features/location_machine_xrefs_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,60 @@
end
end

describe 'external links', type: :feature, js: true do
before(:each) do
machine_links = FactoryBot.create(:machine, name: 'Twilight Zone', id: 1, opdb_id: 666, kineticist_url: 'website.url')
machine_nolinks = FactoryBot.create(:machine, name: 'Hammer Time', id: 2)

@machine_links_lmx = FactoryBot.create(:location_machine_xref, location: @location, machine: machine_links, id: 11)
@machine_nolinks_lmx = FactoryBot.create(:location_machine_xref, location: @location, machine: machine_nolinks, id: 12)
end

it 'should show a pintips link if machine has opdb_id and kineticist link if machine has kineticist_url' do
visit "/#{@region.name}/?by_location_id=#{@location.id}"

page.find("div#machine_tools_lmx_banner_#{@machine_links_lmx.id}").click

expect(page).to have_content('PinTips')
expect(page).to have_content('Kineticist')
end

it 'should not show a pintips link if machine does not have opdb_id nor kineticist link if machine does not have kineticist_url' do
visit "/#{@region.name}/?by_location_id=#{@location.id}"

page.find("div#machine_tools_lmx_banner_#{@machine_nolinks_lmx.id}").click

expect(page).to_not have_content('PinTips')
expect(page).to_not have_content('Kineticist')
end
end

describe 'backglass images', type: :feature, js: true do
before(:each) do
machine_backglass = FactoryBot.create(:machine, name: 'Twilight Zone', id: 1, opdb_img: '/app/assets/images/favicon/favicon.ico')
machine_nobackglass = FactoryBot.create(:machine, name: 'Hammer Time', id: 2)

@machine_backglass_lmx = FactoryBot.create(:location_machine_xref, location: @location, machine: machine_backglass, id: 11)
@machine_nobackglass_lmx = FactoryBot.create(:location_machine_xref, location: @location, machine: machine_nobackglass, id: 12)
end

it 'should show a backglass image if machine has opdb_img' do
visit "/#{@region.name}/?by_location_id=#{@location.id}"

page.find("div#machine_tools_lmx_banner_#{@machine_backglass_lmx.id}").click

expect(page).to have_css('.backglass_container')
end

it 'should not show a backglass image if machine has opdb_img' do
visit "/#{@region.name}/?by_location_id=#{@location.id}"

page.find("div#machine_tools_lmx_banner_#{@machine_nobackglass_lmx.id}").click

expect(page).to_not have_css('.backglass_container')
end
end

describe 'insider connected', type: :feature, js: true do
before(:each) do
@user = FactoryBot.create(:user, id: 11, username: 'ssw', email: '[email protected]')
Expand Down

0 comments on commit 6129364

Please sign in to comment.