Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ManuelMoeri committed Jul 17, 2024
1 parent c657e8f commit bcb3ebe
Show file tree
Hide file tree
Showing 12 changed files with 23 additions and 63 deletions.
2 changes: 2 additions & 0 deletions spec/features/activities_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
let(:person) { people(:bob) }

before(:each) do
Capybara.page.driver.browser.manage.window.maximize
set_env_variables_and_stub_request
sign_in auth_users(:admin)
visit person_path(person)
end
Expand Down
1 change: 1 addition & 0 deletions spec/features/add_create_people_skills_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
let(:person) { people(:bob) }

before(:each) do
set_env_variables_and_stub_request
sign_in auth_users(:user), scope: :auth_user
visit person_people_skills_path(person)
click_link text: "Skill hinzufügen"
Expand Down
2 changes: 2 additions & 0 deletions spec/features/advanced_trainings_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
let(:person) { people(:bob) }

before(:each) do
Capybara.page.driver.browser.manage.window.maximize
set_env_variables_and_stub_request
sign_in auth_users(:admin)
visit person_path(person)
end
Expand Down
2 changes: 2 additions & 0 deletions spec/features/auth_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
context 'Check user privileges' do

before(:each) do
set_env_variables_and_stub_request
sign_in auth_users(:user), scope: :auth_user
visit root_path
end
Expand All @@ -23,6 +24,7 @@
context 'Check admin privileges' do

before(:each) do
set_env_variables_and_stub_request
sign_in(auth_users(:admin))
visit visit people_path
end
Expand Down
1 change: 1 addition & 0 deletions spec/features/core_competences_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

describe "Core competences" do
before(:each) do
set_env_variables_and_stub_request
sign_in auth_users(:user), scope: :auth_user
visit root_path
end
Expand Down
1 change: 1 addition & 0 deletions spec/features/cv_export_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

describe :people do
before(:each) do
set_env_variables_and_stub_request
sign_in auth_users(:user), scope: :auth_user
visit root_path
end
Expand Down
1 change: 1 addition & 0 deletions spec/features/cv_search_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
let(:person) { people(:bob) }

before(:each) do
set_env_variables_and_stub_request
sign_in auth_users(:admin)
visit("/cv_search")
end
Expand Down
3 changes: 3 additions & 0 deletions spec/features/edit_people_skills_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
let(:person) { people(:bob) }

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

Expand Down Expand Up @@ -119,6 +120,8 @@ def not_rated_default_skills(person)
let(:bob) { people(:bob) }

before(:each) do
Capybara.page.driver.browser.manage.window.maximize
set_env_variables_and_stub_request
sign_in auth_users(:user), scope: :auth_user
visit person_people_skills_path(bob, rating: 1)
end
Expand Down
2 changes: 2 additions & 0 deletions spec/features/educations_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
let(:person) { people(:bob) }

before(:each) do
Capybara.page.driver.browser.manage.window.maximize
set_env_variables_and_stub_request
sign_in auth_users(:admin)
visit person_path(person)
end
Expand Down
1 change: 1 addition & 0 deletions spec/features/people_show_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

describe 'People skills Show', type: :feature, js: true do
before(:each) do
set_env_variables_and_stub_request
sign_in auth_users(:user), scope: :auth_user
visit root_path
end
Expand Down
69 changes: 6 additions & 63 deletions spec/features/people_spec.rb
Original file line number Diff line number Diff line change
@@ -1,69 +1,11 @@
require 'rails_helper'

ptime_base_test_url = "www.ptime.example.com"
ptime_api_test_username = "test username"
ptime_api_test_password = "test password"
ENV["PTIME_BASE_URL"] = ptime_base_test_url
ENV["PTIME_API_USERNAME"] = ptime_api_test_username
ENV["PTIME_API_PASSWORD"] = ptime_api_test_password

describe :people do
describe 'People Search', type: :feature, js: true do
employees_json = {
'data' => [
{
'id' => 33,
'type' => 'employee',
'attributes' => {
'shortname' => 'LSM',
'firstname' => 'Longmax',
'lastname' => 'Smith',
'email' => '[email protected]',
'marital_status' => 'single',
'nationalities' => ['ZW'],
'graduation' => 'BSc in Architecture',
'department_shortname' => 'SYS',
'employment_roles' => []
}
},
{
'id' => 21,
'type' => 'employee',
'attributes' => {
'shortname' => 'AMA',
'firstname' => 'Alice',
'lastname' => 'Mante',
'full_name' => 'Alice Mante',
'email' => '[email protected]',
'marital_status' => 'single',
'nationalities' => ['AU'],
'graduation' => 'MSc in writing',
'department_shortname' => 'SYS',
'employment_roles' => [],
'is_employed' => false,
'birthdate' => '01.04.2001',
'location' => 'Bern'
}
},
{
'id' => 45,
'type' => 'employee',
'attributes' => {
'shortname' => 'CFO',
'firstname' => 'Charlie',
'lastname' => 'Ford',
'email' => '[email protected]',
'marital_status' => 'married',
'nationalities' => ['GB'],
'graduation' => 'MSc in networking',
'department_shortname' => 'SYS',
'employment_roles' => []
}
}
]
}.to_json

before(:each) do
set_env_variables_and_stub_request
ENV['LAST_PTIME_API_REQUEST'] = DateTime.current.to_s
sign_in auth_users(:user), scope: :auth_user
end

Expand Down Expand Up @@ -114,9 +56,6 @@
alice = people(:alice)
alice.ptime_employee_id = 21
alice.save!
stub_request(:get, "http://#{ptime_base_test_url}/api/v1/employees?per_page=1000").
to_return(body: employees_json, headers: { 'content-type': "application/vnd.api+json; charset=utf-8" }, status: 200)
.with(basic_auth: [ptime_api_test_username, ptime_api_test_password])
visit people_path
select_from_slim_select("#person_id_person", alice.name)
expect(page).to have_current_path(person_path(alice))
Expand Down Expand Up @@ -265,6 +204,8 @@ def add_language(language)

describe 'Edit person', type: :feature, js: true do
before(:each) do
Capybara.page.driver.browser.manage.window.maximize
set_env_variables_and_stub_request
sign_in auth_users(:user), scope: :auth_user
end

Expand Down Expand Up @@ -349,6 +290,7 @@ def add_language(language)

describe 'Create person', type: :feature, js: true do
before(:each) do
set_env_variables_and_stub_request
sign_in auth_users(:user), scope: :auth_user
end

Expand Down Expand Up @@ -382,6 +324,7 @@ def add_language(language)
let(:longmax) { people(:longmax) }

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

Expand Down
1 change: 1 addition & 0 deletions spec/support/people_skills_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ def validate_skill_level_label(level)
end

def validate_interest(interest)
require "pry"; binding.pry
star_labels = page.find_all("label[id^='star']", visible: false).to_a.reverse
star_labels.each_with_index do |label, index|
body = page.document.find('body')
Expand Down

0 comments on commit bcb3ebe

Please sign in to comment.