mirror of
https://github.com/glitch-soc/mastodon
synced 2025-04-24 21:14:51 +00:00
Extract frontend_translations
helper to support module (#34400)
This commit is contained in:
parent
4c2f64907b
commit
de19af3650
5 changed files with 19 additions and 32 deletions
|
@ -1,6 +1,8 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
module SystemHelpers
|
module SystemHelpers
|
||||||
|
FRONTEND_TRANSLATIONS = JSON.parse Rails.root.join('app', 'javascript', 'mastodon', 'locales', 'en.json').read
|
||||||
|
|
||||||
def submit_button
|
def submit_button
|
||||||
I18n.t('generic.save_changes')
|
I18n.t('generic.save_changes')
|
||||||
end
|
end
|
||||||
|
@ -16,4 +18,8 @@ module SystemHelpers
|
||||||
def css_id(record)
|
def css_id(record)
|
||||||
"##{dom_id(record)}"
|
"##{dom_id(record)}"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def frontend_translations(key)
|
||||||
|
FRONTEND_TRANSLATIONS[key]
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -18,7 +18,7 @@ RSpec.describe 'Account notes', :inline_jobs, :js, :streaming do
|
||||||
visit_profile(other_account)
|
visit_profile(other_account)
|
||||||
|
|
||||||
note_text = 'This is a personal note'
|
note_text = 'This is a personal note'
|
||||||
fill_in 'Click to add note', with: note_text
|
fill_in frontend_translations('account_note.placeholder'), with: note_text
|
||||||
|
|
||||||
# This is a bit awkward since there is no button to save the change
|
# This is a bit awkward since there is no button to save the change
|
||||||
# The easiest way is to send ctrl+enter ourselves
|
# The easiest way is to send ctrl+enter ourselves
|
||||||
|
|
|
@ -17,8 +17,9 @@ RSpec.describe 'Log out' do
|
||||||
click_on 'Logout'
|
click_on 'Logout'
|
||||||
end
|
end
|
||||||
|
|
||||||
expect(page).to have_title(I18n.t('auth.login'))
|
expect(page)
|
||||||
expect(page).to have_current_path('/auth/sign_in')
|
.to have_title(I18n.t('auth.login'))
|
||||||
|
.and have_current_path('/auth/sign_in')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -28,6 +29,8 @@ RSpec.describe 'Log out' do
|
||||||
ignore_js_error(/Failed to load resource: the server responded with a status of 422/)
|
ignore_js_error(/Failed to load resource: the server responded with a status of 422/)
|
||||||
|
|
||||||
visit root_path
|
visit root_path
|
||||||
|
expect(page)
|
||||||
|
.to have_css('body', class: 'app-body')
|
||||||
|
|
||||||
within '.navigation-bar' do
|
within '.navigation-bar' do
|
||||||
click_on 'Menu'
|
click_on 'Menu'
|
||||||
|
@ -39,8 +42,9 @@ RSpec.describe 'Log out' do
|
||||||
|
|
||||||
click_on 'Log out'
|
click_on 'Log out'
|
||||||
|
|
||||||
expect(page).to have_title(I18n.t('auth.login'))
|
expect(page)
|
||||||
expect(page).to have_current_path('/auth/sign_in')
|
.to have_title(I18n.t('auth.login'))
|
||||||
|
.and have_current_path('/auth/sign_in')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -17,20 +17,7 @@ RSpec.describe 'NewStatuses', :inline_jobs, :js, :streaming do
|
||||||
status_text = 'This is a new status!'
|
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 frontend_translations('compose_form.placeholder'), with: status_text
|
||||||
click_on 'Post'
|
|
||||||
end
|
|
||||||
|
|
||||||
expect(page)
|
|
||||||
.to have_css('.status__content__text', text: status_text)
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'can be posted again' do
|
|
||||||
visit_homepage
|
|
||||||
status_text = 'This is a second status!'
|
|
||||||
|
|
||||||
within('.compose-form') do
|
|
||||||
fill_in "What's on your mind?", with: status_text
|
|
||||||
click_on 'Post'
|
click_on 'Post'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -23,24 +23,14 @@ RSpec.describe 'Share page', :js, :streaming do
|
||||||
fill_in_form
|
fill_in_form
|
||||||
|
|
||||||
expect(page)
|
expect(page)
|
||||||
.to have_css('.notification-bar-message', text: translations['compose.published.body'])
|
.to have_css('.notification-bar-message', text: frontend_translations('compose.published.body'))
|
||||||
end
|
end
|
||||||
|
|
||||||
def fill_in_form
|
def fill_in_form
|
||||||
within('.compose-form') do
|
within('.compose-form') do
|
||||||
fill_in translations['compose_form.placeholder'],
|
fill_in frontend_translations('compose_form.placeholder'),
|
||||||
with: 'This is a new status!'
|
with: 'This is a new status!'
|
||||||
click_on translations['compose_form.publish']
|
click_on frontend_translations('compose_form.publish')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
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
|
||||||
|
|
Loading…
Add table
Reference in a new issue