1
0
Fork 0
forked from gitea/nas

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

This commit is contained in:
KMY 2025-03-10 19:58:05 +09:00
commit 5979c0ea1d
345 changed files with 4304 additions and 2540 deletions

View file

@ -0,0 +1,28 @@
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe 'Admin Announcement Mail Distributions' do
let(:user) { Fabricate(:admin_user) }
let(:announcement) { Fabricate(:announcement, notification_sent_at: nil) }
before { sign_in(user) }
describe 'Sending an announcement notification', :inline_jobs do
it 'marks the announcement as notified and sends the email' do
visit admin_announcement_preview_path(announcement)
expect(page)
.to have_title(I18n.t('admin.announcements.preview.title'))
emails = capture_emails do
expect { click_on I18n.t('admin.terms_of_service.preview.send_to_all', count: 1, display_count: 1) }
.to(change { announcement.reload.notification_sent_at })
end
expect(emails.first)
.to be_present
.and(deliver_to(user.email))
expect(page)
.to have_title(I18n.t('admin.announcements.title'))
end
end
end

View file

@ -0,0 +1,19 @@
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe 'Admin Announcements Mail Previews' do
let(:admin_user) { Fabricate(:admin_user) }
let(:announcement) { Fabricate(:announcement, notification_sent_at: nil) }
before { sign_in(admin_user) }
describe 'Viewing Announcements Mail previews' do
it 'shows the Announcement Mail preview page' do
visit admin_announcement_preview_path(announcement)
expect(page)
.to have_title(I18n.t('admin.announcements.preview.title'))
end
end
end

View file

@ -0,0 +1,25 @@
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe 'Admin TermsOfService Tests' do
let(:user) { Fabricate(:admin_user) }
let(:announcement) { Fabricate(:announcement, notification_sent_at: nil) }
before { sign_in(user) }
describe 'Sending test Announcement email', :inline_jobs do
it 'generates the test email' do
visit admin_announcement_preview_path(announcement)
expect(page)
.to have_title(I18n.t('admin.announcements.preview.title'))
emails = capture_emails { click_on I18n.t('admin.terms_of_service.preview.send_preview', email: user.email) }
expect(emails.first)
.to be_present
.and(deliver_to(user.email))
expect(page)
.to have_title(I18n.t('admin.announcements.title'))
end
end
end

View file

@ -117,7 +117,7 @@ RSpec.describe 'Admin::Announcements' do
end
def text_label
I18n.t('simple_form.labels.announcement.text')
form_label('announcement.text')
end
def admin_user

View file

@ -57,7 +57,7 @@ RSpec.describe 'Admin Invites' do
end
def max_use_field
I18n.t('simple_form.labels.defaults.max_uses')
form_label('defaults.max_uses')
end
end
end

View file

@ -0,0 +1,20 @@
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe 'Admin Relationships' do
let(:admin_user) { Fabricate(:admin_user) }
before { sign_in(admin_user) }
describe 'Viewing account relationships page' do
let(:account) { Fabricate(:account) }
it 'shows page with relationships for account' do
visit admin_account_relationships_path(account.id)
expect(page)
.to have_title(I18n.t('admin.relationships.title', acct: account.pretty_acct))
end
end
end

View file

@ -65,7 +65,7 @@ RSpec.describe 'Admin Rules' do
end
def submit_form
click_on I18n.t('generic.save_changes')
click_on(submit_button)
end
end

View file

@ -3,9 +3,14 @@
require 'rails_helper'
RSpec.describe 'Admin::Settings::About' do
let(:admin_user) { Fabricate(:admin_user) }
before { sign_in(admin_user) }
it 'Saves changes to about settings' do
sign_in admin_user
visit admin_settings_about_path
expect(page)
.to have_title(I18n.t('admin.settings.about.title'))
fill_in extended_description_field,
with: 'new site description'

View file

@ -3,9 +3,14 @@
require 'rails_helper'
RSpec.describe 'Admin::Settings::Appearance' do
let(:admin_user) { Fabricate(:admin_user) }
before { sign_in(admin_user) }
it 'Saves changes to appearance settings' do
sign_in admin_user
visit admin_settings_appearance_path
expect(page)
.to have_title(I18n.t('admin.settings.appearance.title'))
fill_in custom_css_field,
with: 'html { display: inline; }'

View file

@ -3,9 +3,14 @@
require 'rails_helper'
RSpec.describe 'Admin::Settings::Branding' do
let(:admin_user) { Fabricate(:admin_user) }
before { sign_in(admin_user) }
it 'Saves changes to branding settings' do
sign_in admin_user
visit admin_settings_branding_path
expect(page)
.to have_title(I18n.t('admin.settings.branding.title'))
fill_in short_description_field,
with: 'new key value'

View file

@ -3,9 +3,14 @@
require 'rails_helper'
RSpec.describe 'Admin::Settings::ContentRetention' do
let(:admin_user) { Fabricate(:admin_user) }
before { sign_in(admin_user) }
it 'Saves changes to content retention settings' do
sign_in admin_user
visit admin_settings_content_retention_path
expect(page)
.to have_title(I18n.t('admin.settings.content_retention.title'))
fill_in media_cache_retention_period_field,
with: '2'

View file

@ -3,9 +3,14 @@
require 'rails_helper'
RSpec.describe 'Admin::Settings::Discovery' do
let(:admin_user) { Fabricate(:admin_user) }
before { sign_in(admin_user) }
it 'Saves changes to discovery settings' do
sign_in admin_user
visit admin_settings_discovery_path
expect(page)
.to have_title(I18n.t('admin.settings.discovery.title'))
check trends_box

View file

@ -3,9 +3,14 @@
require 'rails_helper'
RSpec.describe 'Admin::Settings::Registrations' do
let(:admin_user) { Fabricate(:admin_user) }
before { sign_in(admin_user) }
it 'Saves changes to registrations settings' do
sign_in admin_user
visit admin_settings_registrations_path
expect(page)
.to have_title(I18n.t('admin.settings.registrations.title'))
select open_mode_option,
from: registrations_mode_field

View file

@ -0,0 +1,27 @@
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe 'Admin SiteUploads' do
let(:user) { Fabricate(:admin_user) }
before { sign_in(user) }
describe 'Removing a site upload' do
let!(:site_upload) { Fabricate(:site_upload, var: 'thumbnail') }
it 'removes the upload and redirects' do
visit admin_settings_branding_path
expect(page)
.to have_title(I18n.t('admin.settings.branding.title'))
expect { click_on I18n.t('admin.site_uploads.delete') }
.to change(SiteUpload, :count).by(-1)
expect { site_upload.reload }
.to raise_error(ActiveRecord::RecordNotFound)
expect(page)
.to have_content(I18n.t('admin.site_uploads.destroyed_msg'))
.and have_title(I18n.t('admin.settings.branding.title'))
end
end
end

View file

@ -28,7 +28,7 @@ RSpec.describe 'Admin Tags' do
end
def display_name_field
I18n.t('simple_form.labels.defaults.display_name')
form_label('defaults.display_name')
end
def match_error_text

View file

@ -0,0 +1,28 @@
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe 'Admin TermsOfService Distributions' do
let(:user) { Fabricate(:admin_user) }
let(:terms_of_service) { Fabricate(:terms_of_service, notification_sent_at: nil) }
before { sign_in(user) }
describe 'Sending a TOS change notification', :inline_jobs do
it 'marks the TOS as notified and sends the email' do
visit admin_terms_of_service_preview_path(terms_of_service)
expect(page)
.to have_title(I18n.t('admin.terms_of_service.preview.title'))
emails = capture_emails do
expect { click_on I18n.t('admin.terms_of_service.preview.send_to_all', count: 1, display_count: 1) }
.to(change { terms_of_service.reload.notification_sent_at })
end
expect(emails.first)
.to be_present
.and(deliver_to(user.email))
expect(page)
.to have_title(I18n.t('admin.terms_of_service.title'))
end
end
end

View file

@ -0,0 +1,41 @@
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe 'Admin TermsOfService Drafts' do
let(:admin_user) { Fabricate(:admin_user) }
before { sign_in(admin_user) }
describe 'Managing TOS drafts' do
let!(:terms) { Fabricate :terms_of_service, published_at: nil }
it 'saves and publishes TOS drafts' do
visit admin_terms_of_service_draft_path
expect(page)
.to have_title(I18n.t('admin.terms_of_service.title'))
# Invalid submission
expect { click_on I18n.t('admin.terms_of_service.save_draft') }
.to_not(change { terms.reload.published_at })
expect(page)
.to have_title(I18n.t('admin.terms_of_service.title'))
# Valid submission with draft button
fill_in 'terms_of_service_text', with: 'new'
expect { click_on I18n.t('admin.terms_of_service.save_draft') }
.to not_change { terms.reload.published_at }.from(nil)
.and not_change(Admin::ActionLog, :count)
expect(page)
.to have_title(I18n.t('admin.terms_of_service.title'))
# Valid with publish button
fill_in 'terms_of_service_text', with: 'newer'
expect { click_on I18n.t('admin.terms_of_service.publish') }
.to change { terms.reload.published_at }.from(nil)
.and change(Admin::ActionLog, :count)
expect(page)
.to have_title(I18n.t('admin.terms_of_service.title'))
end
end
end

View file

@ -0,0 +1,44 @@
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe 'Admin TermsOfService Generates' do
let(:admin_user) { Fabricate(:admin_user) }
before { sign_in(admin_user) }
describe 'Generating a TOS policy' do
it 'saves a new TOS from values' do
visit admin_terms_of_service_generate_path
expect(page)
.to have_title(I18n.t('admin.terms_of_service.generates.title'))
# Invalid form submission
fill_in 'terms_of_service_generator_admin_email', with: 'what the'
expect { submit_form }
.to_not change(TermsOfService, :count)
expect(page)
.to have_title(I18n.t('admin.terms_of_service.generates.title'))
# Valid submission
fill_in 'terms_of_service_generator_admin_email', with: 'test@host.example'
fill_in 'terms_of_service_generator_arbitration_address', with: '123 Main Street'
fill_in 'terms_of_service_generator_arbitration_website', with: 'https://host.example'
fill_in 'terms_of_service_generator_dmca_address', with: '123 DMCA Ave'
fill_in 'terms_of_service_generator_dmca_email', with: 'dmca@host.example'
fill_in 'terms_of_service_generator_domain', with: 'host.example'
fill_in 'terms_of_service_generator_jurisdiction', with: 'Europe'
fill_in 'terms_of_service_generator_choice_of_law', with: 'New York'
fill_in 'terms_of_service_generator_min_age', with: '16'
expect { submit_form }
.to change(TermsOfService, :count).by(1)
expect(page)
.to have_title(I18n.t('admin.terms_of_service.title'))
end
def submit_form
click_on I18n.t('admin.terms_of_service.generates.action')
end
end
end

View file

@ -0,0 +1,19 @@
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe 'Admin TermsOfService Previews' do
let(:terms_of_service) { Fabricate(:terms_of_service, notification_sent_at: nil) }
let(:admin_user) { Fabricate(:admin_user) }
before { sign_in(admin_user) }
describe 'Viewing TOS previews' do
it 'shows the TOS preview page' do
visit admin_terms_of_service_preview_path(terms_of_service)
expect(page)
.to have_title(I18n.t('admin.terms_of_service.preview.title'))
end
end
end

View file

@ -0,0 +1,25 @@
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe 'Admin TermsOfService Tests' do
let(:user) { Fabricate(:admin_user) }
let(:terms_of_service) { Fabricate(:terms_of_service, notification_sent_at: nil) }
before { sign_in(user) }
describe 'Sending test TOS email', :inline_jobs do
it 'generates the test email' do
visit admin_terms_of_service_preview_path(terms_of_service)
expect(page)
.to have_title(I18n.t('admin.terms_of_service.preview.title'))
emails = capture_emails { click_on I18n.t('admin.terms_of_service.preview.send_preview', email: user.email) }
expect(emails.first)
.to be_present
.and(deliver_to(user.email))
expect(page)
.to have_title(I18n.t('admin.terms_of_service.preview.title'))
end
end
end

View file

@ -11,6 +11,8 @@ RSpec.describe 'Admin::Trends::Links::PreviewCardProviders' do
context 'without selecting any records' do
it 'displays a notice about selection' do
visit admin_trends_links_preview_card_providers_path
expect(page)
.to have_title(I18n.t('admin.trends.preview_card_providers.title'))
click_on button_for_allow

View file

@ -11,6 +11,8 @@ RSpec.describe 'Admin::Trends::Links' do
context 'without selecting any records' do
it 'displays a notice about selection' do
visit admin_trends_links_path
expect(page)
.to have_title(I18n.t('admin.trends.links.title'))
click_on button_for_allow

View file

@ -11,6 +11,8 @@ RSpec.describe 'Admin::Trends::Statuses' do
context 'without selecting any records' do
it 'displays a notice about selection' do
visit admin_trends_statuses_path
expect(page)
.to have_title(I18n.t('admin.trends.statuses.title'))
click_on button_for_allow

View file

@ -11,6 +11,8 @@ RSpec.describe 'Admin::Trends::Tags' do
context 'without selecting any records' do
it 'displays a notice about selection' do
visit admin_trends_tags_path
expect(page)
.to have_title(I18n.t('admin.trends.tags.title'))
click_on button_for_allow

View file

@ -61,7 +61,7 @@ RSpec.describe 'Admin Warning Presets' do
end
def submit_form
click_on I18n.t('generic.save_changes')
click_on(submit_button)
end
end

View file

@ -81,7 +81,20 @@ RSpec.describe 'Admin Webhooks' do
end
def submit_form
click_on I18n.t('generic.save_changes')
click_on(submit_button)
end
end
describe 'Rotate a webhook secret' do
let!(:webhook) { Fabricate :webhook, events: [Webhook::EVENTS.first] }
it 'rotates secret and returns to page' do
visit admin_webhook_path(webhook)
expect { click_on I18n.t('admin.webhooks.rotate_secret') }
.to(change { webhook.reload.secret })
expect(page)
.to have_title(I18n.t('admin.webhooks.title'))
end
end

View file

@ -108,6 +108,6 @@ RSpec.describe 'Filters' do
end
def filter_title_field
I18n.t('simple_form.labels.defaults.title')
form_label('defaults.title')
end
end

View file

@ -74,9 +74,9 @@ RSpec.describe 'Invites' do
def fill_invite_form
select I18n.t('invites.max_uses', count: 100),
from: I18n.t('simple_form.labels.defaults.max_uses')
from: form_label('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')
from: form_label('defaults.expires_in')
check form_label('defaults.autofollow')
end
end

View file

@ -96,7 +96,7 @@ RSpec.describe 'Settings applications page' do
end
def submit_form
click_on I18n.t('generic.save_changes')
click_on(submit_button)
end
end

View file

@ -33,18 +33,18 @@ RSpec.describe 'Settings preferences appearance page' do
end
def confirm_delete_field
I18n.t('simple_form.labels.defaults.setting_delete_modal')
form_label('defaults.setting_delete_modal')
end
def confirm_reblog_field
I18n.t('simple_form.labels.defaults.setting_boost_modal')
form_label('defaults.setting_boost_modal')
end
def theme_selection_field
I18n.t('simple_form.labels.defaults.setting_theme')
form_label('defaults.setting_theme')
end
def advanced_layout_field
I18n.t('simple_form.labels.defaults.setting_advanced_layout')
form_label('defaults.setting_advanced_layout')
end
end

View file

@ -22,6 +22,6 @@ RSpec.describe 'Settings preferences notifications page' do
end
def notifications_follow_field
I18n.t('simple_form.labels.notification_emails.follow')
form_label('notification_emails.follow')
end
end

View file

@ -29,7 +29,7 @@ RSpec.describe 'Settings preferences other page' do
end
def mark_sensitive_field
I18n.t('simple_form.labels.defaults.setting_default_sensitive')
form_label('defaults.setting_default_sensitive')
end
def language_field(key)

View file

@ -27,7 +27,7 @@ RSpec.describe 'Settings Privacy' do
.to change { user.account.reload.discoverable }.to(true)
expect(page)
.to have_content(I18n.t('privacy.title'))
.and have_content(I18n.t('generic.changes_saved_msg'))
.and have_content(success_message)
expect(ActivityPub::UpdateDistributionWorker)
.to have_received(:perform_async).with(user.account.id)
end

View file

@ -28,10 +28,10 @@ RSpec.describe 'Settings profile page' do
end
def display_name_field
I18n.t('simple_form.labels.defaults.display_name')
form_label('defaults.display_name')
end
def avatar_field
I18n.t('simple_form.labels.defaults.avatar')
form_label('defaults.avatar')
end
end

View file

@ -0,0 +1,25 @@
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe 'Settings Sessions' do
let(:user) { Fabricate(:user) }
let!(:session_activation) { Fabricate(:session_activation, user: user) }
before { sign_in(user) }
describe 'deleting a session' do
it 'deletes listed session activation from the auth page' do
visit edit_user_registration_path
expect(page)
.to have_title(I18n.t('settings.account_settings'))
expect { click_on(I18n.t('sessions.revoke')) }
.to change(SessionActivation, :count).by(-1)
expect { session_activation.reload }
.to raise_error(ActiveRecord::RecordNotFound)
expect(page)
.to have_content(I18n.t('sessions.revoke_success'))
end
end
end

View file

@ -44,6 +44,6 @@ RSpec.describe 'Settings verification page' do
end
def attribution_field
I18n.t('simple_form.labels.account.attribution_domains')
form_label('account.attribution_domains')
end
end