Revert "Upstream 20240517"
This commit is contained in:
parent
9c006fd893
commit
f6dec44e95
2347 changed files with 26470 additions and 87494 deletions
|
@ -1,81 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
describe 'Admin::Accounts' do
|
||||
let(:current_user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
|
||||
|
||||
before do
|
||||
sign_in current_user
|
||||
end
|
||||
|
||||
describe 'Performing batch updates' do
|
||||
let(:unapproved_user_account) { Fabricate(:account) }
|
||||
let(:approved_user_account) { Fabricate(:account) }
|
||||
|
||||
before do
|
||||
unapproved_user_account.user.update(approved: false)
|
||||
approved_user_account.user.update(approved: true)
|
||||
|
||||
visit admin_accounts_path
|
||||
end
|
||||
|
||||
context 'without selecting any accounts' do
|
||||
it 'displays a notice about account selection' do
|
||||
click_on button_for_suspend
|
||||
|
||||
expect(page).to have_content(selection_error_text)
|
||||
end
|
||||
end
|
||||
|
||||
context 'with action of `suspend`' do
|
||||
it 'suspends the account' do
|
||||
batch_checkbox_for(approved_user_account).check
|
||||
|
||||
click_on button_for_suspend
|
||||
|
||||
expect(approved_user_account.reload).to be_suspended
|
||||
end
|
||||
end
|
||||
|
||||
context 'with action of `approve`' do
|
||||
it 'approves the account user' do
|
||||
batch_checkbox_for(unapproved_user_account).check
|
||||
|
||||
click_on button_for_approve
|
||||
|
||||
expect(unapproved_user_account.reload.user).to be_approved
|
||||
end
|
||||
end
|
||||
|
||||
context 'with action of `reject`', :sidekiq_inline do
|
||||
it 'rejects and removes the account' do
|
||||
batch_checkbox_for(unapproved_user_account).check
|
||||
|
||||
click_on button_for_reject
|
||||
|
||||
expect { unapproved_user_account.reload }.to raise_error(ActiveRecord::RecordNotFound)
|
||||
end
|
||||
end
|
||||
|
||||
def button_for_suspend
|
||||
I18n.t('admin.accounts.perform_full_suspension')
|
||||
end
|
||||
|
||||
def button_for_approve
|
||||
I18n.t('admin.accounts.approve')
|
||||
end
|
||||
|
||||
def button_for_reject
|
||||
I18n.t('admin.accounts.reject')
|
||||
end
|
||||
|
||||
def selection_error_text
|
||||
I18n.t('admin.accounts.no_account_selected')
|
||||
end
|
||||
|
||||
def batch_checkbox_for(account)
|
||||
find("#form_account_batch_account_ids_#{account.id}")
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,33 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
describe 'Admin::CustomEmojis' do
|
||||
let(:current_user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
|
||||
|
||||
before do
|
||||
sign_in current_user
|
||||
end
|
||||
|
||||
describe 'Performing batch updates' do
|
||||
before do
|
||||
visit admin_custom_emojis_path
|
||||
end
|
||||
|
||||
context 'without selecting any records' do
|
||||
it 'displays a notice about selection' do
|
||||
click_on button_for_enable
|
||||
|
||||
expect(page).to have_content(selection_error_text)
|
||||
end
|
||||
end
|
||||
|
||||
def button_for_enable
|
||||
I18n.t('admin.custom_emojis.enable')
|
||||
end
|
||||
|
||||
def selection_error_text
|
||||
I18n.t('admin.custom_emojis.no_emoji_selected')
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,115 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
describe 'blocking domains through the moderation interface' do
|
||||
before do
|
||||
allow(DomainBlockWorker).to receive(:perform_async).and_return(true)
|
||||
sign_in Fabricate(:user, role: UserRole.find_by(name: 'Admin')), scope: :user
|
||||
end
|
||||
|
||||
context 'when silencing a new domain' do
|
||||
it 'adds a new domain block' do
|
||||
visit new_admin_domain_block_path
|
||||
|
||||
submit_domain_block('example.com', 'silence')
|
||||
|
||||
expect(DomainBlock.exists?(domain: 'example.com', severity: 'silence')).to be true
|
||||
expect(DomainBlockWorker).to have_received(:perform_async)
|
||||
end
|
||||
end
|
||||
|
||||
context 'when suspending a new domain' do
|
||||
it 'presents a confirmation screen before suspending the domain' do
|
||||
visit new_admin_domain_block_path
|
||||
|
||||
submit_domain_block('example.com', 'suspend')
|
||||
|
||||
# It doesn't immediately block but presents a confirmation screen
|
||||
expect(page).to have_title(I18n.t('admin.domain_blocks.confirm_suspension.title', domain: 'example.com'))
|
||||
expect(DomainBlockWorker).to_not have_received(:perform_async)
|
||||
|
||||
# Confirming creates a block
|
||||
click_on I18n.t('admin.domain_blocks.confirm_suspension.confirm')
|
||||
|
||||
expect(DomainBlock.exists?(domain: 'example.com', severity: 'suspend')).to be true
|
||||
expect(DomainBlockWorker).to have_received(:perform_async)
|
||||
end
|
||||
end
|
||||
|
||||
context 'when suspending a domain that is already silenced' do
|
||||
it 'presents a confirmation screen before suspending the domain' do
|
||||
domain_block = Fabricate(:domain_block, domain: 'example.com', severity: 'silence')
|
||||
|
||||
visit new_admin_domain_block_path
|
||||
|
||||
submit_domain_block('example.com', 'suspend')
|
||||
|
||||
# It doesn't immediately block but presents a confirmation screen
|
||||
expect(page).to have_title(I18n.t('admin.domain_blocks.confirm_suspension.title', domain: 'example.com'))
|
||||
expect(DomainBlockWorker).to_not have_received(:perform_async)
|
||||
|
||||
# Confirming updates the block
|
||||
click_on I18n.t('admin.domain_blocks.confirm_suspension.confirm')
|
||||
|
||||
expect(domain_block.reload.severity).to eq 'suspend'
|
||||
expect(DomainBlockWorker).to have_received(:perform_async)
|
||||
end
|
||||
end
|
||||
|
||||
context 'when suspending a subdomain of an already-silenced domain' do
|
||||
it 'presents a confirmation screen before suspending the domain' do
|
||||
domain_block = Fabricate(:domain_block, domain: 'example.com', severity: 'silence')
|
||||
|
||||
visit new_admin_domain_block_path
|
||||
|
||||
submit_domain_block('subdomain.example.com', 'suspend')
|
||||
|
||||
# It doesn't immediately block but presents a confirmation screen
|
||||
expect(page).to have_title(I18n.t('admin.domain_blocks.confirm_suspension.title', domain: 'subdomain.example.com'))
|
||||
expect(DomainBlockWorker).to_not have_received(:perform_async)
|
||||
|
||||
# Confirming creates the block
|
||||
click_on I18n.t('admin.domain_blocks.confirm_suspension.confirm')
|
||||
|
||||
expect(DomainBlock.where(domain: 'subdomain.example.com', severity: 'suspend')).to exist
|
||||
expect(DomainBlockWorker).to have_received(:perform_async)
|
||||
|
||||
# And leaves the previous block alone
|
||||
expect(domain_block.reload)
|
||||
.to have_attributes(
|
||||
severity: eq('silence'),
|
||||
domain: eq('example.com')
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
context 'when editing a domain block' do
|
||||
it 'presents a confirmation screen before suspending the domain' do
|
||||
domain_block = Fabricate(:domain_block, domain: 'example.com', severity: 'silence')
|
||||
|
||||
visit edit_admin_domain_block_path(domain_block)
|
||||
|
||||
select I18n.t('admin.domain_blocks.new.severity.suspend'), from: 'domain_block_severity'
|
||||
click_on I18n.t('generic.save_changes')
|
||||
|
||||
# It doesn't immediately block but presents a confirmation screen
|
||||
expect(page).to have_title(I18n.t('admin.domain_blocks.confirm_suspension.title', domain: 'example.com'))
|
||||
expect(DomainBlockWorker).to_not have_received(:perform_async)
|
||||
|
||||
# Confirming updates the block
|
||||
click_on I18n.t('admin.domain_blocks.confirm_suspension.confirm')
|
||||
expect(DomainBlockWorker).to have_received(:perform_async)
|
||||
|
||||
expect(domain_block.reload.severity).to eq 'suspend'
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def submit_domain_block(domain, severity)
|
||||
fill_in 'domain_block_domain', with: domain
|
||||
select I18n.t("admin.domain_blocks.new.severity.#{severity}"), from: 'domain_block_severity'
|
||||
click_on I18n.t('admin.domain_blocks.new.create')
|
||||
end
|
||||
end
|
|
@ -1,33 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
describe 'Admin::EmailDomainBlocks' do
|
||||
let(:current_user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
|
||||
|
||||
before do
|
||||
sign_in current_user
|
||||
end
|
||||
|
||||
describe 'Performing batch updates' do
|
||||
before do
|
||||
visit admin_email_domain_blocks_path
|
||||
end
|
||||
|
||||
context 'without selecting any records' do
|
||||
it 'displays a notice about selection' do
|
||||
click_on button_for_delete
|
||||
|
||||
expect(page).to have_content(selection_error_text)
|
||||
end
|
||||
end
|
||||
|
||||
def button_for_delete
|
||||
I18n.t('admin.email_domain_blocks.delete')
|
||||
end
|
||||
|
||||
def selection_error_text
|
||||
I18n.t('admin.email_domain_blocks.no_email_domain_block_selected')
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,33 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
describe 'Admin::IpBlocks' do
|
||||
let(:current_user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
|
||||
|
||||
before do
|
||||
sign_in current_user
|
||||
end
|
||||
|
||||
describe 'Performing batch updates' do
|
||||
before do
|
||||
visit admin_ip_blocks_path
|
||||
end
|
||||
|
||||
context 'without selecting any records' do
|
||||
it 'displays a notice about selection' do
|
||||
click_on button_for_delete
|
||||
|
||||
expect(page).to have_content(selection_error_text)
|
||||
end
|
||||
end
|
||||
|
||||
def button_for_delete
|
||||
I18n.t('admin.ip_blocks.delete')
|
||||
end
|
||||
|
||||
def selection_error_text
|
||||
I18n.t('admin.ip_blocks.no_ip_block_selected')
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,23 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
describe 'finding software updates through the admin interface' do
|
||||
before do
|
||||
Fabricate(:software_update, version: '99.99.99', type: 'major', urgent: true, release_notes: 'https://github.com/mastodon/mastodon/releases/v99')
|
||||
|
||||
sign_in Fabricate(:user, role: UserRole.find_by(name: 'Owner')), scope: :user
|
||||
end
|
||||
|
||||
it 'shows a link to the software updates page, which links to release notes' do
|
||||
visit settings_profile_path
|
||||
click_on I18n.t('admin.critical_update_pending')
|
||||
|
||||
expect(page).to have_title(I18n.t('admin.software_updates.title'))
|
||||
|
||||
expect(page).to have_content('99.99.99')
|
||||
|
||||
click_on I18n.t('admin.software_updates.release_notes')
|
||||
expect(page).to have_current_path('https://github.com/mastodon/mastodon/releases/v99', url: true)
|
||||
end
|
||||
end
|
|
@ -1,34 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
describe 'Admin::Statuses' do
|
||||
let(:current_user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
|
||||
|
||||
before do
|
||||
sign_in current_user
|
||||
end
|
||||
|
||||
describe 'Performing batch updates' do
|
||||
before do
|
||||
_status = Fabricate(:status, account: current_user.account)
|
||||
visit admin_account_statuses_path(account_id: current_user.account_id)
|
||||
end
|
||||
|
||||
context 'without selecting any records' do
|
||||
it 'displays a notice about selection' do
|
||||
click_on button_for_report
|
||||
|
||||
expect(page).to have_content(selection_error_text)
|
||||
end
|
||||
end
|
||||
|
||||
def button_for_report
|
||||
I18n.t('admin.statuses.batch.report')
|
||||
end
|
||||
|
||||
def selection_error_text
|
||||
I18n.t('admin.statuses.no_status_selected')
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,33 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
describe 'Admin::Trends::Links::PreviewCardProviders' do
|
||||
let(:current_user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
|
||||
|
||||
before do
|
||||
sign_in current_user
|
||||
end
|
||||
|
||||
describe 'Performing batch updates' do
|
||||
before do
|
||||
visit admin_trends_links_preview_card_providers_path
|
||||
end
|
||||
|
||||
context 'without selecting any records' do
|
||||
it 'displays a notice about selection' do
|
||||
click_on button_for_allow
|
||||
|
||||
expect(page).to have_content(selection_error_text)
|
||||
end
|
||||
end
|
||||
|
||||
def button_for_allow
|
||||
I18n.t('admin.trends.allow')
|
||||
end
|
||||
|
||||
def selection_error_text
|
||||
I18n.t('admin.trends.links.publishers.no_publisher_selected')
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,33 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
describe 'Admin::Trends::Links' do
|
||||
let(:current_user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
|
||||
|
||||
before do
|
||||
sign_in current_user
|
||||
end
|
||||
|
||||
describe 'Performing batch updates' do
|
||||
before do
|
||||
visit admin_trends_links_path
|
||||
end
|
||||
|
||||
context 'without selecting any records' do
|
||||
it 'displays a notice about selection' do
|
||||
click_on button_for_allow
|
||||
|
||||
expect(page).to have_content(selection_error_text)
|
||||
end
|
||||
end
|
||||
|
||||
def button_for_allow
|
||||
I18n.t('admin.trends.links.allow')
|
||||
end
|
||||
|
||||
def selection_error_text
|
||||
I18n.t('admin.trends.links.no_link_selected')
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,33 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
describe 'Admin::Trends::Statuses' do
|
||||
let(:current_user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
|
||||
|
||||
before do
|
||||
sign_in current_user
|
||||
end
|
||||
|
||||
describe 'Performing batch updates' do
|
||||
before do
|
||||
visit admin_trends_statuses_path
|
||||
end
|
||||
|
||||
context 'without selecting any records' do
|
||||
it 'displays a notice about selection' do
|
||||
click_on button_for_allow
|
||||
|
||||
expect(page).to have_content(selection_error_text)
|
||||
end
|
||||
end
|
||||
|
||||
def button_for_allow
|
||||
I18n.t('admin.trends.statuses.allow')
|
||||
end
|
||||
|
||||
def selection_error_text
|
||||
I18n.t('admin.trends.statuses.no_status_selected')
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,33 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
describe 'Admin::Trends::Tags' do
|
||||
let(:current_user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
|
||||
|
||||
before do
|
||||
sign_in current_user
|
||||
end
|
||||
|
||||
describe 'Performing batch updates' do
|
||||
before do
|
||||
visit admin_trends_tags_path
|
||||
end
|
||||
|
||||
context 'without selecting any records' do
|
||||
it 'displays a notice about selection' do
|
||||
click_on button_for_allow
|
||||
|
||||
expect(page).to have_content(selection_error_text)
|
||||
end
|
||||
end
|
||||
|
||||
def button_for_allow
|
||||
I18n.t('admin.trends.allow')
|
||||
end
|
||||
|
||||
def selection_error_text
|
||||
I18n.t('admin.trends.tags.no_tag_selected')
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,46 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
describe 'email confirmation flow when captcha is enabled' do
|
||||
let(:user) { Fabricate(:user, confirmed_at: nil, confirmation_token: 'foobar', created_by_application: client_app) }
|
||||
let(:client_app) { nil }
|
||||
|
||||
before do
|
||||
allow(Auth::ConfirmationsController).to receive(:new).and_return(stubbed_controller)
|
||||
end
|
||||
|
||||
context 'when the user signed up through an app' do
|
||||
let(:client_app) { Fabricate(:application) }
|
||||
|
||||
it 'logs in' do
|
||||
visit "/auth/confirmation?confirmation_token=#{user.confirmation_token}&redirect_to_app=true"
|
||||
|
||||
# It presents the user with a captcha form
|
||||
expect(page).to have_title(I18n.t('auth.captcha_confirmation.title'))
|
||||
|
||||
# It redirects to app and confirms user
|
||||
expect { click_on I18n.t('challenge.confirm') }
|
||||
.to change { user.reload.confirmed? }.from(false).to(true)
|
||||
|
||||
expect(page).to have_current_path(/\A#{client_app.confirmation_redirect_uri}/, url: true)
|
||||
|
||||
# Browsers will generally reload the original page upon redirection
|
||||
# to external handlers, so test this as well
|
||||
visit "/auth/confirmation?confirmation_token=#{user.confirmation_token}&redirect_to_app=true"
|
||||
|
||||
# It presents a page with a link to the app callback
|
||||
expect(page)
|
||||
.to have_content(I18n.t('auth.confirmations.registration_complete', domain: 'cb6e6126.ngrok.io'))
|
||||
.and have_link(I18n.t('auth.confirmations.clicking_this_link'), href: client_app.confirmation_redirect_uri)
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def stubbed_controller
|
||||
Auth::ConfirmationsController.new.tap do |controller|
|
||||
allow(controller).to receive_messages(captcha_enabled?: true, check_captcha!: true, render_captcha: nil)
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,51 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
describe 'Log in' do
|
||||
include ProfileStories
|
||||
|
||||
subject { page }
|
||||
|
||||
let(:email) { 'test@example.com' }
|
||||
let(:password) { 'password' }
|
||||
let(:confirmed_at) { Time.zone.now }
|
||||
|
||||
before do
|
||||
as_a_registered_user
|
||||
visit new_user_session_path
|
||||
end
|
||||
|
||||
it 'A valid email and password user is able to log in' do
|
||||
fill_in 'user_email', with: email
|
||||
fill_in 'user_password', with: password
|
||||
click_on I18n.t('auth.login')
|
||||
|
||||
expect(subject).to have_css('div.app-holder')
|
||||
end
|
||||
|
||||
it 'A invalid email and password user is not able to log in' do
|
||||
fill_in 'user_email', with: 'invalid_email'
|
||||
fill_in 'user_password', with: 'invalid_password'
|
||||
click_on I18n.t('auth.login')
|
||||
|
||||
expect(subject).to have_css('.flash-message', text: failure_message('invalid'))
|
||||
end
|
||||
|
||||
context 'when confirmed at is nil' do
|
||||
let(:confirmed_at) { nil }
|
||||
|
||||
it 'A unconfirmed user is able to log in' do
|
||||
fill_in 'user_email', with: email
|
||||
fill_in 'user_password', with: password
|
||||
click_on I18n.t('auth.login')
|
||||
|
||||
expect(subject).to have_css('div.admin-wrapper')
|
||||
end
|
||||
end
|
||||
|
||||
def failure_message(message)
|
||||
keys = User.authentication_keys.map { |key| User.human_attribute_name(key) }
|
||||
I18n.t("devise.failure.#{message}", authentication_keys: keys.join('support.array.words_connector'))
|
||||
end
|
||||
end
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe 'NewStatuses', :js, :sidekiq_inline, :streaming do
|
||||
describe 'NewStatuses', :sidekiq_inline do
|
||||
include ProfileStories
|
||||
|
||||
subject { page }
|
||||
|
@ -15,7 +15,6 @@ describe 'NewStatuses', :js, :sidekiq_inline, :streaming do
|
|||
before do
|
||||
as_a_logged_in_user
|
||||
visit root_path
|
||||
page.driver.browser.manage.window.resize_to(1600, 1050)
|
||||
end
|
||||
|
||||
it 'can be posted' do
|
||||
|
@ -25,7 +24,7 @@ describe 'NewStatuses', :js, :sidekiq_inline, :streaming do
|
|||
|
||||
within('.compose-form') do
|
||||
fill_in "What's on your mind?", with: status_text
|
||||
click_on 'Post'
|
||||
click_on 'Publish!'
|
||||
end
|
||||
|
||||
expect(subject).to have_css('.status__content__text', text: status_text)
|
||||
|
@ -38,7 +37,7 @@ describe 'NewStatuses', :js, :sidekiq_inline, :streaming do
|
|||
|
||||
within('.compose-form') do
|
||||
fill_in "What's on your mind?", with: status_text
|
||||
click_on 'Post'
|
||||
click_on 'Publish!'
|
||||
end
|
||||
|
||||
expect(subject).to have_css('.status__content__text', text: status_text)
|
||||
|
|
|
@ -1,183 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
describe 'Using OAuth from an external app', :js, :streaming do
|
||||
let(:client_app) { Doorkeeper::Application.create!(name: 'test', redirect_uri: about_url(host: Rails.application.config.x.local_domain), scopes: 'read') }
|
||||
|
||||
context 'when the user is already logged in' do
|
||||
let!(:user) { Fabricate(:user) }
|
||||
|
||||
before do
|
||||
visit new_user_session_path
|
||||
fill_in_auth_details(user.email, user.password)
|
||||
end
|
||||
|
||||
it 'when accepting the authorization request' do
|
||||
params = { client_id: client_app.uid, response_type: 'code', redirect_uri: client_app.redirect_uri, scope: 'read' }
|
||||
visit "/oauth/authorize?#{params.to_query}"
|
||||
|
||||
# It presents the user with an authorization page
|
||||
expect(page).to have_content(I18n.t('doorkeeper.authorizations.buttons.authorize'))
|
||||
|
||||
# Upon authorizing, it redirects to the apps' callback URL
|
||||
click_on I18n.t('doorkeeper.authorizations.buttons.authorize')
|
||||
expect(page).to have_current_path(/\A#{client_app.redirect_uri}/, url: true)
|
||||
|
||||
# It grants the app access to the account
|
||||
expect(Doorkeeper::AccessGrant.exists?(application: client_app, resource_owner_id: user.id)).to be true
|
||||
end
|
||||
|
||||
it 'when rejecting the authorization request' do
|
||||
params = { client_id: client_app.uid, response_type: 'code', redirect_uri: client_app.redirect_uri, scope: 'read' }
|
||||
visit "/oauth/authorize?#{params.to_query}"
|
||||
|
||||
# It presents the user with an authorization page
|
||||
expect(page).to have_content(I18n.t('doorkeeper.authorizations.buttons.deny'))
|
||||
|
||||
# Upon denying, it redirects to the apps' callback URL
|
||||
click_on I18n.t('doorkeeper.authorizations.buttons.deny')
|
||||
expect(page).to have_current_path(/\A#{client_app.redirect_uri}/, url: true)
|
||||
|
||||
# It does not grant the app access to the account
|
||||
expect(Doorkeeper::AccessGrant.exists?(application: client_app, resource_owner_id: user.id)).to be false
|
||||
end
|
||||
end
|
||||
|
||||
context 'when the user is not already logged in' do
|
||||
let(:email) { 'test@example.com' }
|
||||
let(:password) { 'testpassword' }
|
||||
let(:user) { Fabricate(:user, email: email, password: password) }
|
||||
|
||||
before do
|
||||
user.mark_email_as_confirmed!
|
||||
user.approve!
|
||||
end
|
||||
|
||||
it 'when accepting the authorization request' do
|
||||
params = { client_id: client_app.uid, response_type: 'code', redirect_uri: client_app.redirect_uri, scope: 'read' }
|
||||
visit "/oauth/authorize?#{params.to_query}"
|
||||
|
||||
# It presents the user with a log-in page
|
||||
expect(page).to have_content(I18n.t('auth.login'))
|
||||
|
||||
# Failing to log-in presents the form again
|
||||
fill_in_auth_details(email, 'wrong password')
|
||||
expect(page).to have_content(I18n.t('auth.login'))
|
||||
|
||||
# Logging in redirects to an authorization page
|
||||
fill_in_auth_details(email, password)
|
||||
expect(page).to have_content(I18n.t('doorkeeper.authorizations.buttons.authorize'))
|
||||
|
||||
# Upon authorizing, it redirects to the apps' callback URL
|
||||
click_on I18n.t('doorkeeper.authorizations.buttons.authorize')
|
||||
expect(page).to have_current_path(/\A#{client_app.redirect_uri}/, url: true)
|
||||
|
||||
# It grants the app access to the account
|
||||
expect(Doorkeeper::AccessGrant.exists?(application: client_app, resource_owner_id: user.id)).to be true
|
||||
end
|
||||
|
||||
it 'when rejecting the authorization request' do
|
||||
params = { client_id: client_app.uid, response_type: 'code', redirect_uri: client_app.redirect_uri, scope: 'read' }
|
||||
visit "/oauth/authorize?#{params.to_query}"
|
||||
|
||||
# It presents the user with a log-in page
|
||||
expect(page).to have_content(I18n.t('auth.login'))
|
||||
|
||||
# Failing to log-in presents the form again
|
||||
fill_in_auth_details(email, 'wrong password')
|
||||
expect(page).to have_content(I18n.t('auth.login'))
|
||||
|
||||
# Logging in redirects to an authorization page
|
||||
fill_in_auth_details(email, password)
|
||||
expect(page).to have_content(I18n.t('doorkeeper.authorizations.buttons.authorize'))
|
||||
|
||||
# Upon denying, it redirects to the apps' callback URL
|
||||
click_on I18n.t('doorkeeper.authorizations.buttons.deny')
|
||||
expect(page).to have_current_path(/\A#{client_app.redirect_uri}/, url: true)
|
||||
|
||||
# It does not grant the app access to the account
|
||||
expect(Doorkeeper::AccessGrant.exists?(application: client_app, resource_owner_id: user.id)).to be false
|
||||
end
|
||||
|
||||
context 'when the user has set up TOTP' do
|
||||
let(:user) { Fabricate(:user, email: email, password: password, otp_required_for_login: true, otp_secret: User.generate_otp_secret(32)) }
|
||||
|
||||
it 'when accepting the authorization request' do
|
||||
params = { client_id: client_app.uid, response_type: 'code', redirect_uri: client_app.redirect_uri, scope: 'read' }
|
||||
visit "/oauth/authorize?#{params.to_query}"
|
||||
|
||||
# It presents the user with a log-in page
|
||||
expect(page).to have_content(I18n.t('auth.login'))
|
||||
|
||||
# Failing to log-in presents the form again
|
||||
fill_in_auth_details(email, 'wrong password')
|
||||
expect(page).to have_content(I18n.t('auth.login'))
|
||||
|
||||
# Logging in redirects to a two-factor authentication page
|
||||
fill_in_auth_details(email, password)
|
||||
expect(page).to have_content(I18n.t('simple_form.hints.sessions.otp'))
|
||||
|
||||
# Filling in an incorrect two-factor authentication code presents the form again
|
||||
fill_in_otp_details('wrong')
|
||||
expect(page).to have_content(I18n.t('simple_form.hints.sessions.otp'))
|
||||
|
||||
# Filling in the correct TOTP code redirects to an app authorization page
|
||||
fill_in_otp_details(user.current_otp)
|
||||
expect(page).to have_content(I18n.t('doorkeeper.authorizations.buttons.authorize'))
|
||||
|
||||
# Upon authorizing, it redirects to the apps' callback URL
|
||||
click_on I18n.t('doorkeeper.authorizations.buttons.authorize')
|
||||
expect(page).to have_current_path(/\A#{client_app.redirect_uri}/, url: true)
|
||||
|
||||
# It grants the app access to the account
|
||||
expect(Doorkeeper::AccessGrant.exists?(application: client_app, resource_owner_id: user.id)).to be true
|
||||
end
|
||||
|
||||
it 'when rejecting the authorization request' do
|
||||
params = { client_id: client_app.uid, response_type: 'code', redirect_uri: client_app.redirect_uri, scope: 'read' }
|
||||
visit "/oauth/authorize?#{params.to_query}"
|
||||
|
||||
# It presents the user with a log-in page
|
||||
expect(page).to have_content(I18n.t('auth.login'))
|
||||
|
||||
# Failing to log-in presents the form again
|
||||
fill_in_auth_details(email, 'wrong password')
|
||||
expect(page).to have_content(I18n.t('auth.login'))
|
||||
|
||||
# Logging in redirects to a two-factor authentication page
|
||||
fill_in_auth_details(email, password)
|
||||
expect(page).to have_content(I18n.t('simple_form.hints.sessions.otp'))
|
||||
|
||||
# Filling in an incorrect two-factor authentication code presents the form again
|
||||
fill_in_otp_details('wrong')
|
||||
expect(page).to have_content(I18n.t('simple_form.hints.sessions.otp'))
|
||||
|
||||
# Filling in the correct TOTP code redirects to an app authorization page
|
||||
fill_in_otp_details(user.current_otp)
|
||||
expect(page).to have_content(I18n.t('doorkeeper.authorizations.buttons.authorize'))
|
||||
|
||||
# Upon denying, it redirects to the apps' callback URL
|
||||
click_on I18n.t('doorkeeper.authorizations.buttons.deny')
|
||||
expect(page).to have_current_path(/\A#{client_app.redirect_uri}/, url: true)
|
||||
|
||||
# It does not grant the app access to the account
|
||||
expect(Doorkeeper::AccessGrant.exists?(application: client_app, resource_owner_id: user.id)).to be false
|
||||
end
|
||||
end
|
||||
# TODO: external auth
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def fill_in_auth_details(email, password)
|
||||
fill_in 'user_email', with: email
|
||||
fill_in 'user_password', with: password
|
||||
click_on I18n.t('auth.login')
|
||||
end
|
||||
|
||||
def fill_in_otp_details(value)
|
||||
fill_in 'user_otp_attempt', with: value
|
||||
click_on I18n.t('auth.login')
|
||||
end
|
||||
end
|
|
@ -1,33 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
describe 'OCR', :js, :paperclip_processing, :sidekiq_inline, :streaming do
|
||||
include ProfileStories
|
||||
|
||||
let(:email) { 'test@example.com' }
|
||||
let(:password) { 'password' }
|
||||
let(:confirmed_at) { Time.zone.now }
|
||||
let(:finished_onboarding) { true }
|
||||
|
||||
before do
|
||||
as_a_logged_in_user
|
||||
visit root_path
|
||||
end
|
||||
|
||||
it 'can recognize text in a media attachment' do
|
||||
expect(page).to have_css('div.app-holder')
|
||||
|
||||
within('.compose-form') do
|
||||
attach_file('file-upload-input', file_fixture('text.png'), make_visible: true)
|
||||
|
||||
within('.compose-form__upload') do
|
||||
click_on('Edit')
|
||||
end
|
||||
end
|
||||
|
||||
click_on('Detect text from picture')
|
||||
|
||||
expect(page).to have_css('#upload-modal__description', text: /Hello Mastodon\s*/, wait: 10)
|
||||
end
|
||||
end
|
|
@ -1,33 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
describe 'Profile' do
|
||||
include ProfileStories
|
||||
|
||||
subject { page }
|
||||
|
||||
let(:local_domain) { ENV['LOCAL_DOMAIN'] }
|
||||
|
||||
before do
|
||||
as_a_logged_in_user
|
||||
with_alice_as_local_user
|
||||
end
|
||||
|
||||
it 'I can view Annes public account' do
|
||||
visit account_path('alice')
|
||||
|
||||
expect(subject).to have_title("alice (@alice@#{local_domain})")
|
||||
end
|
||||
|
||||
it 'I can change my account' do
|
||||
visit settings_profile_path
|
||||
|
||||
fill_in 'Display name', with: 'Bob'
|
||||
fill_in 'Bio', with: 'Bob is silent'
|
||||
|
||||
first('button[type=submit]').click
|
||||
|
||||
expect(subject).to have_content 'Changes successfully saved!'
|
||||
end
|
||||
end
|
|
@ -1,32 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
describe 'redirection confirmations' do
|
||||
let(:account) { Fabricate(:account, domain: 'example.com', uri: 'https://example.com/users/foo', url: 'https://example.com/@foo') }
|
||||
let(:status) { Fabricate(:status, account: account, uri: 'https://example.com/users/foo/statuses/1', url: 'https://example.com/@foo/1') }
|
||||
|
||||
context 'when a logged out user visits a local page for a remote account' do
|
||||
it 'shows a confirmation page' do
|
||||
visit "/@#{account.pretty_acct}"
|
||||
|
||||
# It explains about the redirect
|
||||
expect(page).to have_content(I18n.t('redirects.title', instance: 'cb6e6126.ngrok.io'))
|
||||
|
||||
# It features an appropriate link
|
||||
expect(page).to have_link(account.url, href: account.url)
|
||||
end
|
||||
end
|
||||
|
||||
context 'when a logged out user visits a local page for a remote status' do
|
||||
it 'shows a confirmation page' do
|
||||
visit "/@#{account.pretty_acct}/#{status.id}"
|
||||
|
||||
# It explains about the redirect
|
||||
expect(page).to have_content(I18n.t('redirects.title', instance: 'cb6e6126.ngrok.io'))
|
||||
|
||||
# It features an appropriate link
|
||||
expect(page).to have_link(status.url, href: status.url)
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,31 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
describe 'report interface', :js, :paperclip_processing, :streaming do
|
||||
include ProfileStories
|
||||
|
||||
let(:email) { 'admin@example.com' }
|
||||
let(:password) { 'password' }
|
||||
let(:confirmed_at) { Time.zone.now }
|
||||
let(:finished_onboarding) { true }
|
||||
|
||||
let(:reported_account) { Fabricate(:account) }
|
||||
let(:reported_status) { Fabricate(:status, account: reported_account) }
|
||||
let(:media_attachment) { Fabricate(:media_attachment, account: reported_account, status: reported_status, file: attachment_fixture('attachment.jpg')) }
|
||||
let!(:report) { Fabricate(:report, target_account: reported_account, status_ids: [media_attachment.status.id]) }
|
||||
|
||||
before do
|
||||
as_a_logged_in_admin
|
||||
visit admin_report_path(report)
|
||||
end
|
||||
|
||||
it 'displays the report interface, including the javascript bits' do
|
||||
# The report category selector React component is properly rendered
|
||||
expect(page).to have_css('.report-reason-selector')
|
||||
|
||||
# The media React component is properly rendered
|
||||
page.scroll_to(page.find('.batch-table__row'))
|
||||
expect(page).to have_css('.spoiler-button__overlay__label')
|
||||
end
|
||||
end
|
|
@ -1,24 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
describe 'Severed relationships page' do
|
||||
include ProfileStories
|
||||
|
||||
describe 'GET severed_relationships#index' do
|
||||
before do
|
||||
as_a_logged_in_user
|
||||
|
||||
event = Fabricate(:relationship_severance_event)
|
||||
Fabricate.times(3, :severed_relationship, local_account: bob.account, relationship_severance_event: event)
|
||||
Fabricate(:account_relationship_severance_event, account: bob.account, relationship_severance_event: event)
|
||||
end
|
||||
|
||||
it 'returns http success' do
|
||||
visit severed_relationships_path
|
||||
|
||||
expect(page).to have_title(I18n.t('settings.severed_relationships'))
|
||||
expect(page).to have_link(href: following_severed_relationship_path(AccountRelationshipSeveranceEvent.first, format: :csv))
|
||||
end
|
||||
end
|
||||
end
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe 'ShareEntrypoint', :js, :streaming do
|
||||
describe 'ShareEntrypoint' do
|
||||
include ProfileStories
|
||||
|
||||
subject { page }
|
||||
|
@ -19,13 +19,13 @@ describe 'ShareEntrypoint', :js, :streaming do
|
|||
|
||||
it 'can be used to post a new status' do
|
||||
expect(subject).to have_css('div#mastodon-compose')
|
||||
expect(subject).to have_css('.compose-form__submit')
|
||||
expect(subject).to have_css('.compose-form__publish-button-wrapper > button')
|
||||
|
||||
status_text = 'This is a new status!'
|
||||
|
||||
within('.compose-form') do
|
||||
fill_in "What's on your mind?", with: status_text
|
||||
click_on 'Post'
|
||||
click_on 'Publish!'
|
||||
end
|
||||
|
||||
expect(subject).to have_css('.notification-bar-message', text: 'Post published.')
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe 'UnloggedBrowsing', :js, :streaming do
|
||||
describe 'UnloggedBrowsing' do
|
||||
subject { page }
|
||||
|
||||
before do
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue