I have the following test that passes when I run it in isolation:
require 'rails_helper'
RSpec.describe 'deleting a non-recurring user event', js: true do
let(:user) { create(:proofreader_user) }
let(:date) { Date.current.strftime('%Y-%m-%d') }
let(:date_time) { date + ' 00:00'}
it 'deletes the event' do
visit root_path
click_on "Login"
fill_in "Email", with: user.email
fill_in "Password", with: user.password
click_on "Sign In"
visit calendar_path
expect(current_path).to eq(calendar_path)
expect(page).to have_css("#complete_registration:disabled")
expect(page).to_not have_css("td.fc-event-container")
find("td.fc-day[data-date='#{date}']").click
expect(page).to have_css("div#user-event-modal")
expect(page).to have_select('user_event[title]', :options => UserEvent.titles.keys)
expect(find('input', id: 'user_event_starting').value).to eq date_time
expect(find('input', id: 'user_event_ending').value).to eq date_time
page.execute_script("$('input#user_event_starting').val('#{date} 09:00')")
expect(find('input', id: 'user_event_starting').value).to eq date + ' 09:00'
page.execute_script("$('input#user_event_ending').val('#{date} 12:00')")
expect(find('input', id: 'user_event_ending').value).to eq date + ' 12:00'
click_on 'Save'
expect(page).to have_css("td.fc-event-container a.fc-day-grid-event")
expect(page).to have_css("span.fc-time", text: '9a - 12p')
expect(page).to have_css("span.fc-title", text: 'work')
find("span.fc-time", text: '9a - 12p').click
expect(page).to have_css("div#user-event-modal")
find("#del_one_event").click
within('.swal2-actions') { click_button('Yes') }
wait_for { page }.to_not have_css("div#user-event-modal")
expect(page).to_not have_css("td.fc-event-container")
expect(page).to_not have_css("span.fc-time", text: '10a - 14p')
end
end
However, when I run all of the tests I get the following error:
Failure/Error: within('.swal2-actions') { click_button('Yes') }
Capybara::ElementNotFound:
Unable to find visible css ".swal2-actions"
Why does this test fail when I run it with the other test and how can I fix it so it passes when I run all tests?