1
0
Fork 0
mirror of https://github.com/mastodon/mastodon.git synced 2024-08-20 21:08:15 -07:00

Compare commits

...

5 commits

Author SHA1 Message Date
Matt Jankowski
33880a8d02
Merge 4b4da73dc6 into a50c8e951f 2024-07-31 14:07:13 +00:00
Claire
a50c8e951f
Fix issue with grouped notifications UI due to recent API change (#31224) 2024-07-31 13:23:08 +00:00
Claire
2c1e75727d
Change filtered notification banner design to take up less space (#31222) 2024-07-31 12:36:08 +00:00
Matt Jankowski
4b4da73dc6 Add have_http_header rspec matcher 2024-07-26 09:07:59 -04:00
Matt Jankowski
2224f22b4d Add have_http_header rspec matcher 2024-07-26 09:07:56 -04:00
35 changed files with 156 additions and 168 deletions

View file

@ -60,7 +60,7 @@ export interface BaseNotificationGroupJSON {
interface NotificationGroupWithStatusJSON extends BaseNotificationGroupJSON {
type: NotificationWithStatusType;
status: ApiStatusJSON;
status_id: string;
}
interface NotificationWithStatusJSON extends BaseNotificationJSON {

View file

@ -49,21 +49,14 @@ export const FilteredNotificationsBanner: React.FC = () => {
<span>
<FormattedMessage
id='filtered_notifications_banner.pending_requests'
defaultMessage='Notifications from {count, plural, =0 {no one} one {one person} other {# people}} you may know'
defaultMessage='From {count, plural, =0 {no one} one {one person} other {# people}} you may know'
values={{ count: policy.summary.pending_requests_count }}
/>
</span>
</div>
<div className='filtered-notifications-banner__badge'>
<div className='filtered-notifications-banner__badge__badge'>
{toCappedNumber(policy.summary.pending_notifications_count)}
</div>
<FormattedMessage
id='filtered_notifications_banner.mentions'
defaultMessage='{count, plural, one {mention} other {mentions}}'
values={{ count: policy.summary.pending_notifications_count }}
/>
{toCappedNumber(policy.summary.pending_notifications_count)}
</div>
</Link>
);

View file

@ -300,8 +300,7 @@
"filter_modal.select_filter.subtitle": "Use an existing category or create a new one",
"filter_modal.select_filter.title": "Filter this post",
"filter_modal.title.status": "Filter a post",
"filtered_notifications_banner.mentions": "{count, plural, one {mention} other {mentions}}",
"filtered_notifications_banner.pending_requests": "Notifications from {count, plural, =0 {no one} one {one person} other {# people}} you may know",
"filtered_notifications_banner.pending_requests": "From {count, plural, =0 {no one} one {one person} other {# people}} you may know",
"filtered_notifications_banner.title": "Filtered notifications",
"firehose.all": "All",
"firehose.local": "This server",

View file

@ -124,9 +124,9 @@ export function createNotificationGroupFromJSON(
case 'mention':
case 'poll':
case 'update': {
const { status, ...groupWithoutStatus } = group;
const { status_id: statusId, ...groupWithoutStatus } = group;
return {
statusId: status.id,
statusId,
sampleAccountIds,
...groupWithoutStatus,
};

View file

@ -10171,25 +10171,10 @@ noscript {
}
&__badge {
display: flex;
align-items: center;
border-radius: 999px;
background: var(--background-border-color);
color: $darker-text-color;
padding: 4px;
padding-inline-end: 8px;
gap: 6px;
font-weight: 500;
font-size: 11px;
line-height: 16px;
word-break: keep-all;
&__badge {
background: $ui-button-background-color;
color: $white;
border-radius: 100px;
padding: 2px 8px;
}
background: $ui-button-background-color;
color: $white;
border-radius: 100px;
padding: 2px 8px;
}
}

View file

@ -89,9 +89,10 @@ RSpec.describe ActivityPub::CollectionsController do
end
it 'returns http success and correct media type and cache headers and empty items' do
expect(response).to have_http_status(200)
expect(response)
.to have_http_status(200)
.and have_http_header('Cache-Control', 'private')
expect(response.media_type).to eq 'application/activity+json'
expect(response.headers['Cache-Control']).to include 'private'
expect(body_as_json[:orderedItems])
.to be_an(Array)
@ -105,9 +106,10 @@ RSpec.describe ActivityPub::CollectionsController do
end
it 'returns http success and correct media type and cache headers and empty items' do
expect(response).to have_http_status(200)
expect(response)
.to have_http_status(200)
.and have_http_header('Cache-Control', 'private')
expect(response.media_type).to eq 'application/activity+json'
expect(response.headers['Cache-Control']).to include 'private'
expect(body_as_json[:orderedItems])
.to be_an(Array)

View file

@ -38,8 +38,9 @@ RSpec.describe ActivityPub::FollowersSynchronizationsController do
let(:remote_account) { Fabricate(:account, domain: 'example.com', uri: 'https://example.com/instance') }
it 'returns http success and cache control and activity json types and correct items' do
expect(response).to have_http_status(200)
expect(response.headers['Cache-Control']).to eq 'max-age=0, private'
expect(response)
.to have_http_status(200)
.and have_http_header('Cache-Control', 'max-age=0, private')
expect(response.media_type).to eq 'application/activity+json'
expect(body[:orderedItems])

View file

@ -62,7 +62,10 @@ RSpec.describe ActivityPub::OutboxesController do
it_behaves_like 'cacheable response'
it 'returns http success and correct media type and vary header and items' do
expect(response).to have_http_status(200)
expect(response)
.to have_http_status(200)
.and have_http_header('Vary', 'Signature')
expect(response.media_type).to eq 'application/activity+json'
expect(response.headers['Vary']).to include 'Signature'
@ -104,10 +107,11 @@ RSpec.describe ActivityPub::OutboxesController do
end
it 'returns http success and correct media type and headers and items' do
expect(response).to have_http_status(200)
expect(response.media_type).to eq 'application/activity+json'
expect(response.headers['Cache-Control']).to eq 'max-age=60, private'
expect(response)
.to have_http_status(200)
.and have_http_header('Cache-Control', 'max-age=60, private')
expect(response.media_type).to eq 'application/activity+json'
expect(body_as_json[:orderedItems]).to be_an Array
expect(body_as_json[:orderedItems].size).to eq 2
expect(body_as_json[:orderedItems].all? { |item| targets_public_collection?(item) }).to be true
@ -121,9 +125,10 @@ RSpec.describe ActivityPub::OutboxesController do
end
it 'returns http success and correct media type and headers and items' do
expect(response).to have_http_status(200)
expect(response)
.to have_http_status(200)
.and have_http_header('Cache-Control', 'max-age=60, private')
expect(response.media_type).to eq 'application/activity+json'
expect(response.headers['Cache-Control']).to eq 'max-age=60, private'
expect(body_as_json[:orderedItems]).to be_an Array
expect(body_as_json[:orderedItems].size).to eq 3
@ -138,10 +143,10 @@ RSpec.describe ActivityPub::OutboxesController do
end
it 'returns http success and correct media type and headers and items' do
expect(response).to have_http_status(200)
expect(response)
.to have_http_status(200)
.and have_http_header('Cache-Control', 'max-age=60, private')
expect(response.media_type).to eq 'application/activity+json'
expect(response.headers['Cache-Control']).to eq 'max-age=60, private'
expect(body_as_json[:orderedItems])
.to be_an(Array)
.and be_empty
@ -155,10 +160,10 @@ RSpec.describe ActivityPub::OutboxesController do
end
it 'returns http success and correct media type and headers and items' do
expect(response).to have_http_status(200)
expect(response)
.to have_http_status(200)
.and have_http_header('Cache-Control', 'max-age=60, private')
expect(response.media_type).to eq 'application/activity+json'
expect(response.headers['Cache-Control']).to eq 'max-age=60, private'
expect(body_as_json[:orderedItems])
.to be_an(Array)
.and be_empty

View file

@ -23,7 +23,7 @@ describe Admin::BaseController do
sign_in(Fabricate(:user, role: UserRole.find_by(name: 'Moderator')))
get :success
expect(response.headers['Cache-Control']).to include('private, no-store')
expect(response).to have_http_header('Cache-Control', 'private, no-store')
end
it 'renders admin layout as a moderator' do

View file

@ -16,7 +16,7 @@ describe Api::BaseController do
it 'returns private cache control headers by default' do
routes.draw { get 'success' => 'api/base#success' }
get :success
expect(response.headers['Cache-Control']).to include('private, no-store')
expect(response).to have_http_header('Cache-Control', 'private, no-store')
end
describe 'forgery protection' do

View file

@ -14,9 +14,10 @@ RSpec.describe Api::OEmbedController do
get :show, params: { url: short_account_status_url(alice, status) }, format: :json
end
it 'returns private cache control headers', :aggregate_failures do
expect(response).to have_http_status(200)
expect(response.headers['Cache-Control']).to include('private, no-store')
it 'returns http success and private cache control' do
expect(response)
.to have_http_status(200)
.and have_http_header('Cache-Control', 'private, no-store')
end
end
end

View file

@ -35,12 +35,10 @@ RSpec.describe Auth::RegistrationsController do
get :edit
end
it 'returns http success' do
expect(response).to have_http_status(200)
end
it 'returns private cache control header' do
expect(response.headers['Cache-Control']).to include('private, no-store')
it 'returns http success and private cache control' do
expect(response)
.to have_http_status(200)
.and have_http_header('Cache-Control', 'private, no-store')
end
end
@ -51,16 +49,13 @@ RSpec.describe Auth::RegistrationsController do
before do
request.env['devise.mapping'] = Devise.mappings[:user]
sign_in(user, scope: :user)
put :update
end
it 'returns http success' do
put :update
expect(response).to have_http_status(200)
end
it 'returns private cache control headers' do
put :update
expect(response.headers['Cache-Control']).to include('private, no-store')
it 'returns http success and private cache control' do
expect(response)
.to have_http_status(200)
.and have_http_header('Cache-Control', 'private, no-store')
end
it 'can update the user email' do

View file

@ -23,12 +23,10 @@ describe Filters::StatusesController do
get :index, params: { filter_id: filter }
end
it 'returns http success' do
expect(response).to have_http_status(200)
end
it 'returns private cache control headers' do
expect(response.headers['Cache-Control']).to include('private, no-store')
it 'returns http success and private cache control' do
expect(response)
.to have_http_status(200)
.and have_http_header('Cache-Control', 'private, no-store')
end
end

View file

@ -22,12 +22,10 @@ describe FiltersController do
get :index
end
it 'returns http success' do
expect(response).to have_http_status(200)
end
it 'returns private cache control headers' do
expect(response.headers['Cache-Control']).to include('private, no-store')
it 'returns http success and private cache control' do
expect(response)
.to have_http_status(200)
.and have_http_header('Cache-Control', 'private, no-store')
end
end
end

View file

@ -22,12 +22,10 @@ describe InvitesController do
get :index
end
it 'returns http success' do
expect(response).to have_http_status(:success)
end
it 'returns private cache control headers' do
expect(response.headers['Cache-Control']).to include('private, no-store')
it 'returns http success and private cache control' do
expect(response)
.to have_http_status(:success)
.and have_http_header('Cache-Control', 'private, no-store')
end
end

View file

@ -24,14 +24,12 @@ RSpec.describe Oauth::AuthorizationsController do
sign_in user, scope: :user
end
it 'returns http success' do
it 'returns http success and private cache control and authorize body' do
subject
expect(response).to have_http_status(200)
end
it 'returns private cache control headers' do
subject
expect(response.headers['Cache-Control']).to include('private, no-store')
expect(response)
.to have_http_status(200)
.and have_http_header('Cache-Control', 'private, no-store')
end
include_examples 'stores location for user'

View file

@ -22,14 +22,12 @@ describe Oauth::AuthorizedApplicationsController do
sign_in Fabricate(:user), scope: :user
end
it 'returns http success' do
it 'returns http success and private cache control' do
subject
expect(response).to have_http_status(200)
end
it 'returns private cache control headers' do
subject
expect(response.headers['Cache-Control']).to include('private, no-store')
expect(response)
.to have_http_status(200)
.and have_http_header('Cache-Control', 'private, no-store')
end
include_examples 'stores location for user'

View file

@ -14,12 +14,10 @@ describe RelationshipsController do
get :show, params: { page: 2, relationship: 'followed_by' }
end
it 'returns http success' do
expect(response).to have_http_status(200)
end
it 'returns private cache control headers' do
expect(response.headers['Cache-Control']).to include('private, no-store')
it 'returns http success and private cache control' do
expect(response)
.to have_http_status(200)
.and have_http_header('Cache-Control', 'private, no-store')
end
end

View file

@ -17,9 +17,10 @@ describe Settings::AliasesController do
get :index
end
it 'returns http success with private cache control headers', :aggregate_failures do
expect(response).to have_http_status(200)
expect(response.headers['Cache-Control']).to include('private, no-store')
it 'returns http success and private cache control' do
expect(response)
.to have_http_status(200)
.and have_http_header('Cache-Control', 'private, no-store')
end
end

View file

@ -18,9 +18,10 @@ describe Settings::ApplicationsController do
get :index
end
it 'returns http success with private cache control headers', :aggregate_failures do
expect(response).to have_http_status(200)
expect(response.headers['Cache-Control']).to include('private, no-store')
it 'returns http success and private cache control' do
expect(response)
.to have_http_status(200)
.and have_http_header('Cache-Control', 'private, no-store')
end
end

View file

@ -14,17 +14,19 @@ describe Settings::DeletesController do
get :show
end
it 'renders confirmation page with private cache control headers', :aggregate_failures do
expect(response).to have_http_status(200)
expect(response.headers['Cache-Control']).to include('private, no-store')
it 'returns http success and private cache control' do
expect(response)
.to have_http_status(200)
.and have_http_header('Cache-Control', 'private, no-store')
end
context 'when suspended' do
let(:user) { Fabricate(:user, account_attributes: { suspended_at: Time.now.utc }) }
it 'returns http forbidden with private cache control headers', :aggregate_failures do
expect(response).to have_http_status(403)
expect(response.headers['Cache-Control']).to include('private, no-store')
it 'returns http forbidden and private cache control' do
expect(response)
.to have_http_status(403)
.and have_http_header('Cache-Control', 'private, no-store')
end
end
end

View file

@ -14,9 +14,10 @@ describe Settings::ExportsController do
get :show
end
it 'returns http success with private cache control headers', :aggregate_failures do
expect(response).to have_http_status(200)
expect(response.headers['Cache-Control']).to include('private, no-store')
it 'returns http success and private cache control' do
expect(response)
.to have_http_status(200)
.and have_http_header('Cache-Control', 'private, no-store')
end
end

View file

@ -19,11 +19,13 @@ RSpec.describe Settings::ImportsController do
get :index
end
it 'assigns the expected imports', :aggregate_failures do
expect(response).to have_http_status(200)
expect(assigns(:recent_imports)).to eq [import]
expect(assigns(:recent_imports)).to_not include(other_import)
expect(response.headers['Cache-Control']).to include('private, no-store')
it 'assigns expected imports and returns http success and private cache control' do
expect(response)
.to have_http_status(200)
.and have_http_header('Cache-Control', 'private, no-store')
expect(assigns(:recent_imports))
.to eq([import])
.and not_include(other_import)
end
end

View file

@ -18,8 +18,9 @@ describe Settings::LoginActivitiesController do
end
it 'returns http success with private cache control headers', :aggregate_failures do
expect(response).to have_http_status(200)
expect(response.headers['Cache-Control']).to include('private, no-store')
expect(response)
.to have_http_status(200)
.and have_http_header('Cache-Control', 'private, no-store')
expect(response.body)
.to include(login_activity.user_agent)
.and include(login_activity.authentication_method)

View file

@ -16,9 +16,10 @@ describe Settings::Migration::RedirectsController do
get :new
end
it 'returns http success with private cache control headers', :aggregate_failures do
expect(response).to have_http_status(200)
expect(response.headers['Cache-Control']).to include('private, no-store')
it 'returns http success and private cache control' do
expect(response)
.to have_http_status(200)
.and have_http_header('Cache-Control', 'private, no-store')
end
end

View file

@ -16,9 +16,10 @@ describe Settings::Preferences::AppearanceController do
get :show
end
it 'returns http success with private cache control headers', :aggregate_failures do
expect(response).to have_http_status(200)
expect(response.headers['Cache-Control']).to include('private, no-store')
it 'returns http success and private cache control' do
expect(response)
.to have_http_status(200)
.and have_http_header('Cache-Control', 'private, no-store')
end
end

View file

@ -16,9 +16,10 @@ describe Settings::Preferences::NotificationsController do
get :show
end
it 'returns http success with private cache control headers', :aggregate_failures do
expect(response).to have_http_status(200)
expect(response.headers['Cache-Control']).to include('private, no-store')
it 'returns http success and private cache control' do
expect(response)
.to have_http_status(200)
.and have_http_header('Cache-Control', 'private, no-store')
end
end

View file

@ -16,9 +16,10 @@ describe Settings::Preferences::OtherController do
get :show
end
it 'returns http success with private cache control headers', :aggregate_failures do
expect(response).to have_http_status(200)
expect(response.headers['Cache-Control']).to include('private, no-store')
it 'returns http success and private cache control' do
expect(response)
.to have_http_status(200)
.and have_http_header('Cache-Control', 'private, no-store')
end
end

View file

@ -17,9 +17,10 @@ RSpec.describe Settings::ProfilesController do
get :show
end
it 'returns http success with private cache control headers', :aggregate_failures do
expect(response).to have_http_status(200)
expect(response.headers['Cache-Control']).to include('private, no-store')
it 'returns http success and private cache control' do
expect(response)
.to have_http_status(200)
.and have_http_header('Cache-Control', 'private, no-store')
end
end

View file

@ -29,9 +29,10 @@ describe Settings::TwoFactorAuthenticationMethodsController do
get :index
end
it 'returns http success with private cache control headers', :aggregate_failures do
expect(response).to have_http_status(200)
expect(response.headers['Cache-Control']).to include('private, no-store')
it 'returns http success and private cache control' do
expect(response)
.to have_http_status(200)
.and have_http_header('Cache-Control', 'private, no-store')
end
end

View file

@ -16,12 +16,10 @@ RSpec.describe StatusesCleanupController do
get :show
end
it 'returns http success' do
expect(response).to have_http_status(200)
end
it 'returns private cache control headers' do
expect(response.headers['Cache-Control']).to include('private, no-store')
it 'returns http success and private cache control' do
expect(response)
.to have_http_status(200)
.and have_http_header('Cache-Control', 'private, no-store')
end
end

View file

@ -159,12 +159,11 @@ describe 'Accounts show response' do
it 'returns a private JSON version of the account', :aggregate_failures do
expect(response)
.to have_http_status(200)
.and have_http_header('Cache-Control', 'private')
.and have_attributes(
media_type: eq('application/activity+json')
)
expect(response.headers['Cache-Control']).to include 'private'
expect(body_as_json).to include(:id, :type, :preferredUsername, :inbox, :publicKey, :name, :summary)
end
end
@ -194,13 +193,12 @@ describe 'Accounts show response' do
it 'returns a private signature JSON version of the account', :aggregate_failures do
expect(response)
.to have_http_status(200)
.and have_http_header('Cache-Control', 'private')
.and have_http_header('Vary', 'Signature')
.and have_attributes(
media_type: eq('application/activity+json')
)
expect(response.headers['Cache-Control']).to include 'private'
expect(response.headers['Vary']).to include 'Signature'
expect(body_as_json).to include(:id, :type, :preferredUsername, :inbox, :publicKey, :name, :summary)
end
end

View file

@ -18,9 +18,9 @@ describe 'The /.well-known/webfinger endpoint' do
shared_examples 'a successful response' do
it 'returns http success with correct media type and headers and body json' do
expect(response).to have_http_status(200)
expect(response.headers['Vary']).to eq('Origin')
expect(response)
.to have_http_status(200)
.and have_http_header('Vary', 'Origin')
expect(response.media_type).to eq 'application/jrd+json'
@ -116,12 +116,10 @@ describe 'The /.well-known/webfinger endpoint' do
perform_request!
end
it 'returns http success' do
expect(response).to have_http_status(200)
end
it 'sets only a Vary Origin header' do
expect(response.headers['Vary']).to eq('Origin')
it 'returns http success and vary origin header' do
expect(response)
.to have_http_status(200)
.and have_http_header('Vary', 'Origin')
end
it 'returns application/jrd+json' do

View file

@ -7,8 +7,8 @@ shared_examples 'cacheable response' do |expects_vary: false|
expect(session).to be_empty
expect(response.headers['Vary']).to include(expects_vary) if expects_vary
expect(response).to have_http_header('Vary', expects_vary) if expects_vary
expect(response.headers['Cache-Control']).to include('public')
expect(response).to have_http_header('Cache-Control', 'public')
end
end

View file

@ -0,0 +1,11 @@
# frozen_string_literal: true
RSpec::Matchers.define :have_http_header do |header, values|
match do |response|
response.headers[header].match?(values)
end
failure_message do |response|
"Expected that `#{header}` would have values of `#{values}` but was `#{response.headers[header]}`"
end
end