Skip to content

Commit

Permalink
add routing and tabbar specs
Browse files Browse the repository at this point in the history
  • Loading branch information
kcinay055679 committed Jul 31, 2024
1 parent d74b5aa commit 6bec7da
Show file tree
Hide file tree
Showing 4 changed files with 98 additions and 11 deletions.
9 changes: 6 additions & 3 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,17 @@
delete 'sign_out', :to => 'devise/sessions#destroy', :as => :destroy_auth_user_session
end

get "/:locale", locale: LOCALE_REGEX, to: 'people#index'

# Status
scope 'status' do
get 'health', to: 'status#health'
get 'readiness', to: 'status#readiness'
end

scope "(:locale)", locale: LOCALE_REGEX do
get root to: 'people#index'
get "/", to: redirect(path: "/people")

scope "/:locale", locale: LOCALE_REGEX, defaults: {locale: I18n.locale} do
get root to: redirect(path: "/%{locale}/people")

resources :skills do
collection do
Expand Down Expand Up @@ -66,6 +67,8 @@
end
end
end
match '*path', to: redirect("/#{I18n.locale}/%{path}"), :via => [:get, :post]


# Outdated api routes
namespace :api do
Expand Down
9 changes: 1 addition & 8 deletions spec/features/cv_search_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,7 @@
fill_in 'cv_search_field', with: education_location
check_search_results(Person.human_attribute_name(:educations))
click_link(Person.human_attribute_name(:educations))
url = URI.parse(current_url)
path = url.path
query_params = url.query.split("&")

# expect(path).to eq(person_people_skills_path(person))
expect(path).to include(person.id.to_s)

expect(query_params).to include({q: education_location}.to_query)
expect(current_url).to eq(person_path(person, q: education_location))
end

it 'should only display results when length of search-text is > 3' do
Expand Down
20 changes: 20 additions & 0 deletions spec/features/routing_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
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"
}
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)
end
end
end
71 changes: 71 additions & 0 deletions spec/features/tabbar_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
require 'rails_helper'

describe 'Tabbar', type: :feature, js:true do
let(:bob) { people(:bob) }

let(:global_tabs){
[
{ title: t('global.navbar.profile'), path: people_path },
{ title: t('global.navbar.skill_search'), path: people_skills_path },
{ title: t('global.navbar.cv_search'), path: cv_search_index_path },
{ title: t('global.navbar.skillset'), path: skills_path }
]
}

let(:person_tabs) {
[
{ title: 'CV', path: person_path(bob) },
{ title: 'Skills', path: person_people_skills_path(bob) }
]
}

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])
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


def check_highlighted_tab(text)
expect(page).to have_selector("div.skills-navbar .btn .nav-link.active", text: text)
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)
end
end
end

0 comments on commit 6bec7da

Please sign in to comment.