Convert `shares` controller spec to system spec (#31619)

This commit is contained in:
Matt Jankowski 2024-08-28 03:58:40 -04:00 committed by GitHub
parent 00586d27cb
commit 0ef636f72d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 27 additions and 36 deletions

View File

@ -1,22 +0,0 @@
# frozen_string_literal: true
require 'rails_helper'
describe SharesController do
render_views
let(:user) { Fabricate(:user) }
before { sign_in user }
describe 'GET #show' do
subject(:body_classes) { assigns(:body_classes) }
before { get :show, params: { title: 'test title', text: 'test text', url: 'url1 url2' } }
it 'returns http success' do
expect(response).to have_http_status 200
expect(body_classes).to eq 'modal-layout compose-standalone'
end
end
end

View File

@ -2,32 +2,45 @@
require 'rails_helper' require 'rails_helper'
describe 'ShareEntrypoint', :js, :streaming do describe 'Share page', :js, :streaming do
include ProfileStories include ProfileStories
subject { page }
let(:email) { 'test@example.com' } let(:email) { 'test@example.com' }
let(:password) { 'password' } let(:password) { 'password' }
let(:confirmed_at) { Time.zone.now } let(:confirmed_at) { Time.zone.now }
let(:finished_onboarding) { true } let(:finished_onboarding) { true }
before do before { as_a_logged_in_user }
as_a_logged_in_user
it 'allows posting a new status' do
visit share_path visit share_path
expect(page)
.to have_css('.modal-layout__mastodon')
.and have_css('div#mastodon-compose')
.and have_css('.compose-form__submit')
fill_in_form
expect(page)
.to have_css('.notification-bar-message', text: translations['compose.published.body'])
end end
it 'can be used to post a new status' do def fill_in_form
expect(subject).to have_css('div#mastodon-compose')
expect(subject).to have_css('.compose-form__submit')
status_text = 'This is a new status!'
within('.compose-form') do within('.compose-form') do
fill_in "What's on your mind?", with: status_text fill_in translations['compose_form.placeholder'],
click_on 'Post' with: 'This is a new status!'
click_on translations['compose_form.publish']
end end
end
expect(subject).to have_css('.notification-bar-message', text: 'Post published.') def translations
# TODO: Extract to system spec helper for re-use?
JSON.parse(
Rails
.root
.join('app', 'javascript', 'mastodon', 'locales', 'en.json')
.read
)
end end
end end