parent
3036453a0f
commit
d7cdb308dd
3 changed files with 241 additions and 343 deletions
@ -0,0 +1,236 @@ |
||||
# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/ |
||||
|
||||
require 'rails_helper' |
||||
|
||||
RSpec.describe 'Profile > Language', type: :system do |
||||
let(:group) { create(:group) } |
||||
let(:session_user) { create(:admin, preferences: { locale: locale }, groups: Group.all) } |
||||
let(:path) { 'profile/language' } |
||||
|
||||
shared_examples 'having translated content in' do |current_element| |
||||
it "the '#{current_element}' element" do |
||||
within current_element do |
||||
expect(page).to have_text(translated_content) |
||||
end |
||||
end |
||||
end |
||||
|
||||
shared_examples 'having translated content in the page title' do |
||||
it 'shows the translated content' do |
||||
expect(page).to have_title(translated_content) |
||||
end |
||||
end |
||||
|
||||
shared_examples 'displaying the current language' do |
||||
it 'shows the current language' do |
||||
within :active_content do |
||||
within '.page-content' do |
||||
expect(page).to have_field(with: full_current_locale) |
||||
end |
||||
end |
||||
end |
||||
end |
||||
|
||||
shared_examples 'have translations in ticket page' do |translated_element| |
||||
it_behaves_like 'having translated content in the page title' |
||||
|
||||
context 'when translated content is ticket priority' do |
||||
let(:translated_content) { priority } |
||||
|
||||
it_behaves_like 'having translated content in', translated_element |
||||
end |
||||
|
||||
context 'when translated content is ticket owner' do |
||||
let(:translated_content) { owner } |
||||
|
||||
it_behaves_like 'having translated content in', translated_element |
||||
end |
||||
|
||||
context 'when translated content is ticket title' do |
||||
let(:translated_content) { title } |
||||
|
||||
it_behaves_like 'having translated content in', :active_content |
||||
end |
||||
end |
||||
|
||||
context 'when user locale is English (en-gb)', authenticated_as: :session_user do |
||||
let(:locale) { 'en-gb' } |
||||
let(:translated_content) { 'Overview' } |
||||
let(:full_current_locale) { 'English (Great Britain)' } |
||||
let(:priority) { 'PRIORITY' } |
||||
let(:owner) { 'OWNER' } |
||||
|
||||
before { visit path } |
||||
|
||||
it_behaves_like 'displaying the current language' |
||||
|
||||
it_behaves_like 'having translated content in', '.js-menu' |
||||
|
||||
context 'when profile language is changed' do |
||||
let(:new_locale) { 'de-de' } |
||||
let(:full_current_locale) { 'Deutsch' } |
||||
|
||||
before do |
||||
within :active_content do |
||||
within '.page-content' do |
||||
find('input.searchableSelect-main.js-input').click |
||||
find("[data-value=#{new_locale}].js-option").click |
||||
|
||||
click_button |
||||
session_user.reload |
||||
end |
||||
end |
||||
end |
||||
|
||||
it 'changes the user preference language' do |
||||
expect(session_user.preferences[:locale]).to eq(new_locale) |
||||
end |
||||
|
||||
it_behaves_like 'displaying the current language' |
||||
end |
||||
|
||||
context 'with language page visited' do |
||||
let(:translated_content) { 'Language' } |
||||
|
||||
it_behaves_like 'having translated content in', '.page-header' |
||||
it_behaves_like 'having translated content in', '.sidebar.NavBarProfile' |
||||
end |
||||
|
||||
context 'with dashboard page visited' do |
||||
let(:path) { 'dashboard' } |
||||
let(:translated_content) { 'My Stats' } |
||||
|
||||
it_behaves_like 'having translated content in', :active_content |
||||
end |
||||
|
||||
context 'with overview page visited' do |
||||
let(:path) { 'ticket/view' } |
||||
let(:translated_content) { 'My assigned Tickets' } |
||||
|
||||
it_behaves_like 'having translated content in the page title' |
||||
it_behaves_like 'having translated content in', :active_content |
||||
end |
||||
|
||||
context 'with drafted ticket create' do |
||||
let(:path) { 'ticket/create' } |
||||
let(:title) { 'preferences lang check #1' } |
||||
let(:customer) { 'nicole' } |
||||
let(:translated_content) { "Call Inbound: #{title}" } |
||||
|
||||
translated_element = '.newTicket .ticket-create' |
||||
|
||||
before do |
||||
fill_in 'title', with: title |
||||
fill_in 'customer_id_completion', with: customer |
||||
send_keys(:enter, :tab) |
||||
find('[data-name="body"]').set(title) |
||||
select 'Users', from: 'group_id' |
||||
end |
||||
|
||||
include_examples 'have translations in ticket page', translated_element |
||||
end |
||||
|
||||
context 'with ticket zoom page' do |
||||
let(:path) { "ticket/zoom/#{ticket.id}" } |
||||
let(:title) { 'preferences lang check #2' } |
||||
let(:translated_content) { title } |
||||
let(:user_group) { Group.lookup(name: 'Users') } |
||||
let(:ticket) { create(:ticket, group: user_group, title: title) } |
||||
|
||||
translated_element = '.content.active .sidebar-content' |
||||
|
||||
include_examples 'have translations in ticket page', translated_element |
||||
end |
||||
end |
||||
|
||||
context 'when user locale is Deutsch', authenticated_as: :session_user do |
||||
let(:locale) { 'de-de' } |
||||
let(:translated_content) { 'Übersichten' } |
||||
let(:full_current_locale) { 'Deutsch' } |
||||
let(:priority) { 'PRIORITÄT' } |
||||
let(:owner) { 'BESITZER' } |
||||
|
||||
before { visit path } |
||||
|
||||
it_behaves_like 'displaying the current language' |
||||
|
||||
it_behaves_like 'having translated content in', '.js-menu' |
||||
|
||||
context 'when profile language is changed' do |
||||
let(:new_locale) { 'en-gb' } |
||||
let(:full_current_locale) { 'English (Great Britain)' } |
||||
let(:translated_content) { 'Übersichten' } |
||||
|
||||
before do |
||||
within :active_content do |
||||
within '.page-content' do |
||||
find('input.searchableSelect-main.js-input').click |
||||
find("[data-value=#{new_locale}].js-option").click |
||||
|
||||
click_button |
||||
session_user.reload |
||||
end |
||||
end |
||||
end |
||||
|
||||
it 'changes the user preference language' do |
||||
expect(session_user.preferences[:locale]).to eq(new_locale) |
||||
end |
||||
|
||||
it_behaves_like 'displaying the current language' |
||||
end |
||||
|
||||
context 'with language page visited' do |
||||
let(:translated_content) { 'Sprache' } |
||||
|
||||
it_behaves_like 'having translated content in', '.page-header' |
||||
it_behaves_like 'having translated content in', '.sidebar.NavBarProfile' |
||||
end |
||||
|
||||
context 'with dashboard page visited' do |
||||
let(:path) { 'dashboard' } |
||||
let(:translated_content) { 'Meine Statistik' } |
||||
|
||||
it_behaves_like 'having translated content in', :active_content |
||||
end |
||||
|
||||
context 'with overview page visited' do |
||||
let(:path) { 'ticket/view' } |
||||
let(:translated_content) { 'Meine zugewiesenen Tickets' } |
||||
|
||||
it_behaves_like 'having translated content in the page title' |
||||
it_behaves_like 'having translated content in', :active_content |
||||
end |
||||
|
||||
context 'with drafted ticket create' do |
||||
let(:path) { 'ticket/create' } |
||||
let(:title) { 'preferences lang check #1' } |
||||
let(:customer) { 'nicole' } |
||||
let(:translated_content) { "Anruf eingehend: #{title}" } |
||||
|
||||
translated_element = '.newTicket .ticket-create' |
||||
|
||||
before do |
||||
fill_in 'title', with: title |
||||
fill_in 'customer_id_completion', with: customer |
||||
send_keys(:enter, :tab) |
||||
find('[data-name="body"]').set(title) |
||||
select 'Users', from: 'group_id' |
||||
end |
||||
|
||||
include_examples 'have translations in ticket page', translated_element |
||||
end |
||||
|
||||
context 'with ticket zoom page' do |
||||
let(:path) { "ticket/zoom/#{ticket.id}" } |
||||
let(:title) { 'preferences lang check #2' } |
||||
let(:translated_content) { title } |
||||
let(:user_group) { Group.lookup(name: 'Users') } |
||||
let(:ticket) { create(:ticket, group: user_group, title: title) } |
||||
|
||||
translated_element = '.content.active .sidebar-content' |
||||
|
||||
include_examples 'have translations in ticket page', translated_element |
||||
end |
||||
end |
||||
end |
@ -1,337 +0,0 @@ |
||||
# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/ |
||||
|
||||
require 'browser_test_helper' |
||||
|
||||
class PreferencesLanguageTest < TestCase |
||||
|
||||
def test_lang_change |
||||
@browser = browser_instance |
||||
login( |
||||
username: 'admin@example.com', |
||||
password: 'test', |
||||
url: browser_url, |
||||
) |
||||
tasks_close_all |
||||
|
||||
# start ticket create |
||||
ticket_create( |
||||
data: { |
||||
customer: 'nicole', |
||||
group: 'Users', |
||||
title: 'preferences lang check #1', |
||||
body: 'preferences lang check #1', |
||||
}, |
||||
do_not_submit: true, |
||||
) |
||||
|
||||
# start ticket zoom |
||||
ticket_create( |
||||
data: { |
||||
customer: 'nicole', |
||||
group: 'Users', |
||||
title: 'preferences lang check #2', |
||||
body: 'preferences lang check #2', |
||||
}, |
||||
) |
||||
|
||||
# start user profile |
||||
user_open_by_search( |
||||
value: 'Nicole', |
||||
) |
||||
|
||||
# start organization profile |
||||
organization_open_by_search( |
||||
value: 'Zammad Foundation', |
||||
) |
||||
|
||||
click(css: 'a[href="#current_user"]') |
||||
click(css: 'a[href="#profile"]') |
||||
click(css: 'a[href="#profile/language"]') |
||||
select( |
||||
css: '.js-language [name="locale"]', |
||||
value: 'Deutsch', |
||||
) |
||||
click(css: '.content.active button[type="submit"]') |
||||
watch_for( |
||||
css: 'body', |
||||
value: 'Sprache', |
||||
) |
||||
|
||||
# check language in navbar |
||||
watch_for( |
||||
css: '.js-menu', |
||||
value: 'Übersicht' |
||||
) |
||||
|
||||
# check language in dashboard |
||||
click(css: '.js-menu a[href="#dashboard"]') |
||||
watch_for( |
||||
css: '.content.active', |
||||
value: 'Meine Statistik' |
||||
) |
||||
|
||||
# check language in overview |
||||
click(css: '.js-menu a[href="#ticket/view"]') |
||||
watch_for( |
||||
css: '.content.active', |
||||
value: 'Meine' |
||||
) |
||||
verify_title( |
||||
value: 'Meine zugewiesenen', |
||||
) |
||||
|
||||
# check language in ticket create |
||||
open_task( |
||||
data: { |
||||
title: 'Anruf', |
||||
} |
||||
) |
||||
verify_task( |
||||
data: { |
||||
title: 'Anruf', |
||||
} |
||||
) |
||||
open_task( |
||||
data: { |
||||
title: 'preferences lang check #1', |
||||
} |
||||
) |
||||
watch_for( |
||||
css: '.content.active', |
||||
value: 'kunde' |
||||
) |
||||
watch_for( |
||||
css: '.content.active', |
||||
value: 'priorität' |
||||
) |
||||
watch_for( |
||||
css: '.content.active [data-name="body"]', |
||||
value: 'preferences lang check #1' |
||||
) |
||||
verify_title( |
||||
value: 'anruf', |
||||
) |
||||
|
||||
# check language in ticket zoom |
||||
open_task( |
||||
data: { |
||||
title: 'preferences lang check #2', |
||||
} |
||||
) |
||||
watch_for( |
||||
css: '.content.active', |
||||
value: 'erstellt' |
||||
) |
||||
watch_for( |
||||
css: '.content.active', |
||||
value: 'priorität' |
||||
) |
||||
|
||||
# check language in user profile |
||||
open_task( |
||||
data: { |
||||
title: 'Nicole', |
||||
} |
||||
) |
||||
watch_for( |
||||
css: '.content.active', |
||||
value: 'notiz' |
||||
) |
||||
watch_for( |
||||
css: '.content.active', |
||||
value: 'e-mail' |
||||
) |
||||
watch_for( |
||||
css: '.content.active', |
||||
value: 'aktion' |
||||
) |
||||
|
||||
# check language in organization profile |
||||
open_task( |
||||
data: { |
||||
title: 'Zammad', |
||||
} |
||||
) |
||||
watch_for( |
||||
css: '.content.active', |
||||
value: 'notiz' |
||||
) |
||||
|
||||
click(css: 'a[href="#current_user"]') |
||||
click(css: 'a[href="#profile"]') |
||||
click(css: 'a[href="#profile/language"]') |
||||
select( |
||||
css: '.js-language [name="locale"]', |
||||
value: 'English (United States)', |
||||
) |
||||
click(css: '.content.active button[type="submit"]') |
||||
sleep 2 |
||||
watch_for( |
||||
css: 'body', |
||||
value: 'Language', |
||||
) |
||||
|
||||
# check language in navbar |
||||
watch_for( |
||||
css: '.js-menu', |
||||
value: 'Overview' |
||||
) |
||||
|
||||
# check language in dashboard |
||||
click(css: '.js-menu a[href="#dashboard"]') |
||||
watch_for( |
||||
css: '.content.active', |
||||
value: 'My Stats' |
||||
) |
||||
|
||||
# check language in overview |
||||
click(css: '.js-menu a[href="#ticket/view"]') |
||||
watch_for( |
||||
css: '.content.active', |
||||
value: 'My' |
||||
) |
||||
verify_title( |
||||
value: 'My assig', |
||||
) |
||||
|
||||
# check language in ticket create |
||||
open_task( |
||||
data: { |
||||
title: 'Call', |
||||
} |
||||
) |
||||
verify_task( |
||||
data: { |
||||
title: 'Call', |
||||
} |
||||
) |
||||
open_task( |
||||
data: { |
||||
title: 'preferences lang check #1', |
||||
} |
||||
) |
||||
watch_for( |
||||
css: '.content.active', |
||||
value: 'customer' |
||||
) |
||||
watch_for( |
||||
css: '.content.active', |
||||
value: 'priority' |
||||
) |
||||
watch_for( |
||||
css: '.content.active [data-name="body"]', |
||||
value: 'preferences lang check #1' |
||||
) |
||||
verify_title( |
||||
value: 'call', |
||||
) |
||||
|
||||
# check language in ticket zoom |
||||
open_task( |
||||
data: { |
||||
title: 'preferences lang check #2', |
||||
} |
||||
) |
||||
watch_for( |
||||
css: '.content.active', |
||||
value: 'create' |
||||
) |
||||
watch_for( |
||||
css: '.content.active', |
||||
value: 'priority' |
||||
) |
||||
|
||||
# check language in user profile |
||||
open_task( |
||||
data: { |
||||
title: 'Nicole', |
||||
} |
||||
) |
||||
watch_for( |
||||
css: '.content.active', |
||||
value: 'note' |
||||
) |
||||
watch_for( |
||||
css: '.content.active', |
||||
value: 'email' |
||||
) |
||||
|
||||
# check language in organization profile |
||||
open_task( |
||||
data: { |
||||
title: 'Zammad', |
||||
} |
||||
) |
||||
watch_for( |
||||
css: '.content.active', |
||||
value: 'note' |
||||
) |
||||
watch_for( |
||||
css: '.content.active', |
||||
value: 'action' |
||||
) |
||||
|
||||
# switch to de again |
||||
click(css: 'a[href="#current_user"]') |
||||
click(css: 'a[href="#profile"]') |
||||
click(css: 'a[href="#profile/language"]') |
||||
sleep 4 |
||||
select( |
||||
css: '.js-language [name="locale"]', |
||||
value: 'Deutsch', |
||||
) |
||||
click(css: '.content.active button[type="submit"]') |
||||
sleep 4 |
||||
watch_for( |
||||
css: 'body', |
||||
value: 'Sprache', |
||||
) |
||||
sleep 6 |
||||
|
||||
# check if language is still used after reload |
||||
reload |
||||
sleep 2 |
||||
|
||||
watch_for( |
||||
css: 'body', |
||||
value: 'Sprache', |
||||
) |
||||
|
||||
# check language in navbar |
||||
watch_for( |
||||
css: '.js-menu', |
||||
value: 'Übersicht' |
||||
) |
||||
|
||||
# check language in dashboard |
||||
click(css: '.js-menu a[href="#dashboard"]') |
||||
watch_for( |
||||
css: '.content.active', |
||||
value: 'Meine Statistik' |
||||
) |
||||
|
||||
# check language in overview |
||||
click(css: '.js-menu a[href="#ticket/view"]') |
||||
watch_for( |
||||
css: '.content.active', |
||||
value: 'Meine' |
||||
) |
||||
|
||||
# switch to en again |
||||
click(css: 'a[href="#current_user"]') |
||||
click(css: 'a[href="#profile"]') |
||||
click(css: 'a[href="#profile/language"]') |
||||
select( |
||||
css: '.js-language [name="locale"]', |
||||
value: 'English (United States)', |
||||
) |
||||
click(css: '.content.active button[type="submit"]') |
||||
sleep 2 |
||||
watch_for( |
||||
css: 'body', |
||||
value: 'Language', |
||||
) |
||||
|
||||
end |
||||
|
||||
end |
Loading…
Reference in new issue