Merge remote-tracking branch 'parent/main' into upstream-20240906

This commit is contained in:
KMY 2024-09-06 08:42:24 +09:00
commit f18eabfe75
689 changed files with 4369 additions and 2434 deletions

View file

@ -2,7 +2,7 @@
require 'rails_helper'
describe 'About page' do
RSpec.describe 'About page' do
it 'visits the about page and renders the web app' do
visit about_path

View file

@ -2,7 +2,7 @@
require 'rails_helper'
describe 'Admin::Accounts' do
RSpec.describe 'Admin::Accounts' do
let(:current_user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
before do

View file

@ -0,0 +1,134 @@
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe 'Admin::Announcements' do
include ActionView::RecordIdentifier
describe 'Viewing announcements' do
it 'can view a list of existing announcements' do
announcement = Fabricate :announcement, text: 'Test Announcement'
sign_in admin_user
visit admin_announcements_path
within css_id(announcement) do
expect(page)
.to have_content(announcement.text)
end
end
end
describe 'Creating announcements' do
it 'create a new announcement' do
sign_in admin_user
visit new_admin_announcement_path
fill_in text_label,
with: 'Announcement text'
expect { submit_form }
.to change(Announcement, :count).by(1)
expect(page)
.to have_content(I18n.t('admin.announcements.published_msg'))
end
end
describe 'Updating announcements' do
it 'updates an existing announcement' do
announcement = Fabricate :announcement, text: 'Test Announcement'
sign_in admin_user
visit admin_announcements_path
within css_id(announcement) do
click_on announcement.text
end
fill_in text_label,
with: 'Announcement text'
save_changes
expect(page)
.to have_content(I18n.t('admin.announcements.updated_msg'))
end
end
describe 'Deleting announcements' do
it 'deletes an existing announcement' do
announcement = Fabricate :announcement, text: 'Test Announcement'
sign_in admin_user
visit admin_announcements_path
expect { delete_announcement(announcement) }
.to change(Announcement, :count).by(-1)
expect(page)
.to have_content(I18n.t('admin.announcements.destroyed_msg'))
end
end
describe 'Publishing announcements' do
it 'publishes an existing announcement' do
announcement = Fabricate :announcement, published: false, scheduled_at: 10.days.from_now
sign_in admin_user
visit admin_announcements_path
expect { publish_announcement(announcement) }
.to change { announcement.reload.published? }.to(true)
expect(page)
.to have_content(I18n.t('admin.announcements.published_msg'))
end
it 'unpublishes an existing announcement' do
announcement = Fabricate :announcement, published: true
sign_in admin_user
visit admin_announcements_path
expect { unpublish_announcement(announcement) }
.to change { announcement.reload.published? }.to(false)
expect(page)
.to have_content(I18n.t('admin.announcements.unpublished_msg'))
end
end
private
def css_id(record)
"##{dom_id(record)}" # TODO: Extract to system spec helper?
end
def publish_announcement(announcement)
within css_id(announcement) do
click_on I18n.t('admin.announcements.publish')
end
end
def unpublish_announcement(announcement)
within css_id(announcement) do
click_on I18n.t('admin.announcements.unpublish')
end
end
def delete_announcement(announcement)
within css_id(announcement) do
click_on I18n.t('generic.delete')
end
end
def save_changes
click_on I18n.t('generic.save_changes')
end
def submit_form
click_on I18n.t('admin.announcements.new.create')
end
def text_label
I18n.t('simple_form.labels.announcement.text')
end
def admin_user
Fabricate(:user, role: UserRole.find_by(name: 'Admin'))
end
end

View file

@ -2,7 +2,7 @@
require 'rails_helper'
describe 'Admin::CustomEmojis' do
RSpec.describe 'Admin::CustomEmojis' do
let(:current_user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
before do

View file

@ -2,7 +2,7 @@
require 'rails_helper'
describe 'blocking domains through the moderation interface' do
RSpec.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

View file

@ -2,7 +2,7 @@
require 'rails_helper'
describe 'Admin::EmailDomainBlocks' do
RSpec.describe 'Admin::EmailDomainBlocks' do
let(:current_user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
before do

View file

@ -2,7 +2,7 @@
require 'rails_helper'
describe 'Admin::IpBlocks' do
RSpec.describe 'Admin::IpBlocks' do
let(:current_user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
before do

View file

@ -2,7 +2,7 @@
require 'rails_helper'
describe 'Admin::Reset' do
RSpec.describe 'Admin::Reset' do
it 'Resets password for account user' do
account = Fabricate :account
sign_in admin_user

View file

@ -0,0 +1,22 @@
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe 'Admin::Settings::About' do
it 'Saves changes to about settings' do
sign_in admin_user
visit admin_settings_about_path
fill_in extended_description_field,
with: 'new site description'
click_on submit_button
expect(page)
.to have_content(success_message)
end
def extended_description_field
form_label 'form_admin_settings.site_extended_description'
end
end

View file

@ -0,0 +1,22 @@
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe 'Admin::Settings::Appearance' do
it 'Saves changes to appearance settings' do
sign_in admin_user
visit admin_settings_appearance_path
fill_in custom_css_field,
with: 'html { display: inline; }'
click_on submit_button
expect(page)
.to have_content(success_message)
end
def custom_css_field
form_label 'form_admin_settings.custom_css'
end
end

View file

@ -0,0 +1,37 @@
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe 'Admin::Settings::Branding' do
it 'Saves changes to branding settings' do
sign_in admin_user
visit admin_settings_branding_path
fill_in short_description_field,
with: 'new key value'
fill_in site_contact_email_field,
with: User.last.email
fill_in site_contact_username_field,
with: Account.last.username
expect { click_on submit_button }
.to change(Setting, :site_short_description).to('new key value')
expect(page)
.to have_content(success_message)
end
def short_description_field
form_label 'form_admin_settings.site_short_description'
end
def site_contact_email_field
form_label 'form_admin_settings.site_contact_email'
end
def site_contact_username_field
form_label 'form_admin_settings.site_contact_username'
end
end

View file

@ -0,0 +1,22 @@
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe 'Admin::Settings::ContentRetention' do
it 'Saves changes to content retention settings' do
sign_in admin_user
visit admin_settings_content_retention_path
fill_in media_cache_retention_period_field,
with: '2'
click_on submit_button
expect(page)
.to have_content(success_message)
end
def media_cache_retention_period_field
form_label 'form_admin_settings.media_cache_retention_period'
end
end

View file

@ -0,0 +1,21 @@
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe 'Admin::Settings::Discovery' do
it 'Saves changes to discovery settings' do
sign_in admin_user
visit admin_settings_discovery_path
check trends_box
click_on submit_button
expect(page)
.to have_content(success_message)
end
def trends_box
form_label 'form_admin_settings.trends'
end
end

View file

@ -0,0 +1,26 @@
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe 'Admin::Settings::Registrations' do
it 'Saves changes to registrations settings' do
sign_in admin_user
visit admin_settings_registrations_path
select open_mode_option,
from: registrations_mode_field
click_on submit_button
expect(page)
.to have_content(success_message)
end
def open_mode_option
I18n.t('admin.settings.registrations_mode.modes.open')
end
def registrations_mode_field
form_label 'form_admin_settings.registrations_mode'
end
end

View file

@ -2,7 +2,7 @@
require 'rails_helper'
describe 'finding software updates through the admin interface' do
RSpec.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')

View file

@ -2,7 +2,7 @@
require 'rails_helper'
describe 'Admin::Statuses' do
RSpec.describe 'Admin::Statuses' do
let(:current_user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
before do

View file

@ -2,7 +2,7 @@
require 'rails_helper'
describe 'Admin::Trends::Links::PreviewCardProviders' do
RSpec.describe 'Admin::Trends::Links::PreviewCardProviders' do
let(:current_user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
before do

View file

@ -2,7 +2,7 @@
require 'rails_helper'
describe 'Admin::Trends::Links' do
RSpec.describe 'Admin::Trends::Links' do
let(:current_user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
before do

View file

@ -2,7 +2,7 @@
require 'rails_helper'
describe 'Admin::Trends::Statuses' do
RSpec.describe 'Admin::Trends::Statuses' do
let(:current_user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
before do

View file

@ -2,7 +2,7 @@
require 'rails_helper'
describe 'Admin::Trends::Tags' do
RSpec.describe 'Admin::Trends::Tags' do
let(:current_user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
before do

View file

@ -2,7 +2,7 @@
require 'rails_helper'
describe 'email confirmation flow when captcha is enabled' do
RSpec.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 }

View file

@ -2,7 +2,7 @@
require 'rails_helper'
describe 'Filters' do
RSpec.describe 'Filters' do
let(:user) { Fabricate(:user) }
let(:filter_title) { 'Filter of fun and games' }

View file

@ -2,7 +2,7 @@
require 'rails_helper'
describe 'Home page' do
RSpec.describe 'Home page' do
context 'when signed in' do
before { sign_in Fabricate(:user) }

View file

@ -0,0 +1,86 @@
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe 'Invites' do
include ActionView::RecordIdentifier
let(:user) { Fabricate :user }
before do
host! 'localhost:3000' # TODO: Move into before for all system specs?
sign_in user
end
describe 'Viewing invites' do
it 'Lists existing user invites' do
invite = Fabricate :invite, user: user
visit invites_path
within css_id(invite) do
expect(page)
.to have_content(invite.uses)
.and have_private_cache_control
expect(copyable_field.value)
.to eq(public_invite_url(invite_code: invite.code))
end
end
end
describe 'Creating a new invite' do
it 'Saves the invite for the user' do
visit invites_path
fill_invite_form
expect { submit_form }
.to change(user.invites, :count).by(1)
end
end
describe 'Deleting an existing invite' do
it 'Expires the invite' do
invite = Fabricate :invite, user: user
visit invites_path
expect { delete_invite(invite) }
.to change { invite.reload.expired? }.to(true)
within css_id(invite) do
expect(page).to have_content I18n.t('invites.expired')
end
end
end
private
def css_id(record)
"##{dom_id(record)}" # TODO: Extract to system spec helper?
end
def copyable_field
within '.input-copy' do
find(:field, type: :text, readonly: true)
end
end
def submit_form
click_on I18n.t('invites.generate')
end
def delete_invite(invite)
within css_id(invite) do
click_on I18n.t('invites.delete')
end
end
def fill_invite_form
select I18n.t('invites.max_uses', count: 100),
from: I18n.t('simple_form.labels.defaults.max_uses')
select I18n.t("invites.expires_in.#{30.minutes.to_i}"),
from: I18n.t('simple_form.labels.defaults.expires_in')
check I18n.t('simple_form.labels.defaults.autofollow')
end
end

View file

@ -2,7 +2,7 @@
require 'rails_helper'
describe 'Log in' do
RSpec.describe 'Log in' do
include ProfileStories
subject { page }

View file

@ -2,7 +2,7 @@
require 'rails_helper'
describe 'Log out' do
RSpec.describe 'Log out' do
include ProfileStories
before do

View file

@ -2,7 +2,7 @@
require 'rails_helper'
describe 'NewStatuses', :inline_jobs, :js, :streaming do
RSpec.describe 'NewStatuses', :inline_jobs, :js, :streaming do
include ProfileStories
subject { page }

View file

@ -2,7 +2,7 @@
require 'rails_helper'
describe 'Using OAuth from an external app' do
RSpec.describe 'Using OAuth from an external app' do
include ProfileStories
subject { visit "/oauth/authorize?#{params.to_query}" }

View file

@ -2,7 +2,7 @@
require 'rails_helper'
describe 'OCR', :attachment_processing, :inline_jobs, :js, :streaming do
RSpec.describe 'OCR', :attachment_processing, :inline_jobs, :js, :streaming do
include ProfileStories
let(:email) { 'test@example.com' }

View file

@ -2,7 +2,7 @@
require 'rails_helper'
describe 'Privacy policy page' do
RSpec.describe 'Privacy policy page' do
it 'visits the privacy policy page and renders the web app' do
visit privacy_policy_path

View file

@ -2,7 +2,7 @@
require 'rails_helper'
describe 'Profile' do
RSpec.describe 'Profile' do
include ProfileStories
subject { page }

View file

@ -2,7 +2,7 @@
require 'rails_helper'
describe 'redirection confirmations' do
RSpec.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') }

View file

@ -2,7 +2,7 @@
require 'rails_helper'
describe 'report interface', :attachment_processing, :js, :streaming do
RSpec.describe 'report interface', :attachment_processing, :js, :streaming do
include ProfileStories
let(:email) { 'admin@example.com' }

View file

@ -2,7 +2,7 @@
require 'rails_helper'
describe 'Severed relationships page' do
RSpec.describe 'Severed relationships page' do
include ProfileStories
describe 'GET severed_relationships#index' do

View file

@ -2,7 +2,7 @@
require 'rails_helper'
describe 'Share page', :js, :streaming do
RSpec.describe 'Share page', :js, :streaming do
include ProfileStories
let(:email) { 'test@example.com' }

19
spec/system/tags_spec.rb Normal file
View file

@ -0,0 +1,19 @@
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe 'Tags' do
describe 'Viewing a tag' do
let(:tag) { Fabricate(:tag, name: 'test') }
before { sign_in Fabricate(:user) }
it 'visits the tag page and renders the web app' do
visit tag_path(tag)
expect(page)
.to have_css('noscript', text: /Mastodon/)
.and have_private_cache_control
end
end
end

View file

@ -2,7 +2,7 @@
require 'rails_helper'
describe 'UnloggedBrowsing', :js, :streaming do
RSpec.describe 'UnloggedBrowsing', :js, :streaming do
subject { page }
before do