Skip to content

Commit

Permalink
add tests to check lanugage selection
Browse files Browse the repository at this point in the history
  • Loading branch information
kcinay055679 committed Aug 2, 2024
1 parent 7df7e6e commit b518243
Show file tree
Hide file tree
Showing 2 changed files with 82 additions and 48 deletions.
48 changes: 36 additions & 12 deletions spec/features/routing_spec.rb
Original file line number Diff line number Diff line change
@@ -1,21 +1,45 @@
require 'rails_helper'

describe 'Check routes', type: :feature, js: true do
ROUTES = {
"/": "/de/people",
"/de/": "/de/people",
"/people": "/de/people",
"/people_skills": "/de/people_skills",
"/en": "/en/people",
}
describe 'Routing', type: :feature, js: true do

let(:bob) { people(:bob) }

before(:each) do
sign_in auth_users(:user), scope: :auth_user
end

ROUTES.each do |url, target|
it "Should route from '#{url}' to #{target}" do
visit url
expect(current_path).to eq(target)
describe "Check auto rerouting" do
ROUTES = {
"/": "/de/people",
"/de/": "/de/people",
"/people": "/de/people",
"/people_skills": "/de/people_skills",
"/en": "/en/people",
}



ROUTES.each do |url, target|
it "Should route from '#{url}' to #{target}" do
visit url
expect(current_path).to eq(target)
end
end
end

describe "Check if language is applied correctly" do
context "Set locale via dropdown" do
before(:each) do
visit root_path
select 'Italienisch', from: "i18n_language"
end

it "Should open profile with correct language" do
select_from_slim_select("#person_id_person", bob.name)
expect(page).to have_text("Dati personali")
click_link(href: person_people_skills_path(bob))
expect(page).to have_text("Nuove competenze per la valutazione")
end
end
end
end
82 changes: 46 additions & 36 deletions spec/features/tabbar_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,53 +19,63 @@
]
}

before(:each) do
sign_in auth_users(:admin)
visit root_path
end

describe 'Global' do
it 'Should highlight right tab using click' do
global_tabs.each do |hash|
click_link(href: hash[:path])
check_highlighted_tab(hash[:title])

[:de, :en, :it, :fr].each do |locale|
describe "Check if tabbar works for #{locale}" do

before(:each) do
sign_in auth_users(:admin)
visit root_path(locale: locale)
end
end

it 'Should highlight right tab after visit by url' do
global_tabs.each do |hash|
visit (hash[:path])
check_highlighted_tab(hash[:title])
after(:each) do
expect(current_path).to start_with("/#{locale}")
end
end

describe 'Global' do
it 'Should highlight right tab using click' do
global_tabs.each do |hash|
click_link(href: hash[:path])
check_highlighted_tab(hash[:title])
end
end

def check_highlighted_tab(text)
expect(page).to have_selector("div.skills-navbar .btn .nav-link.active", text: text)
end
end
it 'Should highlight right tab after visit by url' do
global_tabs.each do |hash|
visit (hash[:path])
check_highlighted_tab(hash[:title])
end
end

describe 'Person' do

it 'Should highlight right tab using dropdown' do
person_tabs.each do |hash|
visit root_path
select_from_slim_select("#person_id_person", bob.name)
check_highlighted_tab("CV")
click_link(href: hash[:path])
check_highlighted_tab(hash[:title])
def check_highlighted_tab(text)
expect(page).to have_selector("div.skills-navbar .btn .nav-link.active", text: text)
end
end
end

it 'Should highlight right tab after visit by url' do
person_tabs.each do |hash|
visit (hash[:path])
check_highlighted_tab(hash[:title])
end
end
describe 'Person' do
it 'Should highlight right tab using dropdown' do
person_tabs.each do |hash|
visit root_path
select_from_slim_select("#person_id_person", bob.name)
check_highlighted_tab("CV")
click_link(href: hash[:path])
check_highlighted_tab(hash[:title])
end
end

it 'Should highlight right tab after visit by url' do
person_tabs.each do |hash|
visit (hash[:path])
check_highlighted_tab(hash[:title])
end
end

def check_highlighted_tab(text)
expect(page).to have_selector(".nav.nav-tabs .btn .nav-link.active", text: text)
def check_highlighted_tab(text)
expect(page).to have_selector(".nav.nav-tabs .btn .nav-link.active", text: text)
end
end
end
end
end

0 comments on commit b518243

Please sign in to comment.