Clean up tests a bit

This commit is contained in:
Eugene Burmakin 2025-05-29 12:22:08 +02:00
parent 68165c47f6
commit d885796576
2 changed files with 2 additions and 19 deletions

View file

@ -6,7 +6,6 @@ RSpec.describe 'Authentication', type: :request do
let(:user) { create(:user, password: 'password123') }
before do
# Stub GitHub API to avoid external dependencies
stub_request(:get, "https://api.github.com/repos/Freika/dawarich/tags")
.with(headers: { 'Accept'=>'*/*', 'Accept-Encoding'=>/.*/,
'Host'=>'api.github.com', 'User-Agent'=>/.*/})
@ -26,10 +25,6 @@ RSpec.describe 'Authentication', type: :request do
end
end
# The self-hosted registration tests are already covered by system tests
# And it seems the route doesn't exist in the test environment
# Focus on the core authentication functionality in request specs
describe 'Account Management' do
it 'prevents account update without current password' do
sign_in user
@ -41,7 +36,6 @@ RSpec.describe 'Authentication', type: :request do
}
}
# Just check it's not a successful response
expect(response).not_to be_successful
expect(user.reload.email).not_to eq('updated@example.com')
end
@ -56,7 +50,6 @@ RSpec.describe 'Authentication', type: :request do
}
}
# Devise redirects to root_path by default, not map_path
expect(response).to redirect_to(root_path)
expect(user.reload.email).to eq('updated@example.com')
end

View file

@ -6,7 +6,6 @@ RSpec.describe 'Authentication UI', type: :system do
let(:user) { create(:user, password: 'password123') }
before do
# Stub the GitHub API call to avoid external dependencies
stub_request(:any, 'https://api.github.com/repos/Freika/dawarich/tags')
.to_return(status: 200, body: '[{"name": "1.0.0"}]', headers: {})
@ -17,38 +16,29 @@ RSpec.describe 'Authentication UI', type: :system do
ActionMailer::Base.deliveries.clear
end
# We'll keep only UI-focused tests that actually need to test visual elements
describe 'Account UI' do
it 'shows the user email in the UI when signed in' do
sign_in_user(user)
expect(page).to have_current_path(map_path)
# Verify user dropdown is present (indicates user is signed in)
expect(page).to have_current_path(map_path)
expect(page).to have_css('summary', text: user.email)
end
end
describe 'Self-hosted UI' do
context 'when self-hosted mode is enabled' do
before do
# Mock DawarichSettings.self_hosted? to be true to disable registration
allow(DawarichSettings).to receive(:self_hosted?).and_return(true)
stub_const('SELF_HOSTED', true)
end
it 'does not show registration links in the login UI' do
visit new_user_session_path
expect(page).not_to have_link('Register')
expect(page).not_to have_link('Sign up')
expect(page).not_to have_content('Register a new account')
end
end
end
end