Skip to content

Commit

Permalink
updated system tests to load LOC subject
Browse files Browse the repository at this point in the history
  • Loading branch information
amtuannguyen committed Oct 22, 2024
1 parent 7899dda commit 2f5f212
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 30 deletions.
3 changes: 2 additions & 1 deletion db/seeds.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# frozen_string_literal: true

# rails db:seed
LocSubject.load_from_file('lib/loc_subjects.txt') if LocSubject.all.count.zero?
LocSubject.delete_all
LocSubject.load_from_file('lib/loc_subjects.txt')

if (Rails.env != 'test') && User.all.count.zero?
[User::ADMIN, User::MANAGER, User::STAFF].each do |role|
Expand Down
3 changes: 3 additions & 0 deletions test/application_system_test_case.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ def setup

user = FactoryGirl.create(:user)
login_as(user, role: User::STAFF)

LocSubject.delete_all
LocSubject.load_from_file('lib/loc_subjects.txt')
end

end
18 changes: 15 additions & 3 deletions test/system/app_settings_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,11 @@ class AppSettingsTest < ApplicationSystemTestCase
click_button('Continue')
fill_in 'thesis_abstract', with: 'Abstract Text Test'
find('#select_subjects_11_chosen a.chosen-default').click
first('#select_subjects_11_chosen .active-result').click
find('#select_subjects_11_chosen .active-result:nth-child(1)').click
find('#select_subjects_12_chosen a.chosen-default').click
find('#select_subjects_12_chosen .active-result:nth-child(2)').click
find('#select_subjects_13_chosen a.chosen-default').click
find('#select_subjects_13_chosen .active-result:nth-child(3)').click
click_link('Continue')
assert_text "Upload Files Text Test"
click_link_or_button('Upload Supplementary Thesis Files')
Expand Down Expand Up @@ -144,7 +148,11 @@ class AppSettingsTest < ApplicationSystemTestCase
click_button('Continue')
fill_in 'thesis_abstract', with: 'Abstract Text Test'
find('#select_subjects_11_chosen a.chosen-default').click
first('#select_subjects_11_chosen .active-result').click
find('#select_subjects_11_chosen .active-result:nth-child(1)').click
find('#select_subjects_12_chosen a.chosen-default').click
find('#select_subjects_12_chosen .active-result:nth-child(2)').click
find('#select_subjects_13_chosen a.chosen-default').click
find('#select_subjects_13_chosen .active-result:nth-child(3)').click
click_link('Continue')
click_link_or_button('Upload Primary Thesis File')
attach_file('document_file', Rails.root.join('test/fixtures/files/pdf-document.pdf'))
Expand Down Expand Up @@ -180,7 +188,11 @@ class AppSettingsTest < ApplicationSystemTestCase
click_button('Continue')
fill_in 'thesis_abstract', with: 'Abstract Text Test'
find('#select_subjects_11_chosen a.chosen-default').click
first('#select_subjects_11_chosen .active-result').click
find('#select_subjects_11_chosen .active-result:nth-child(1)').click
find('#select_subjects_12_chosen a.chosen-default').click
find('#select_subjects_12_chosen .active-result:nth-child(2)').click
find('#select_subjects_13_chosen a.chosen-default').click
find('#select_subjects_13_chosen .active-result:nth-child(3)').click
click_link('Continue')
click_link_or_button('Upload Primary Thesis File')
attach_file('document_file', Rails.root.join('test/fixtures/files/pdf-document.pdf'))
Expand Down
32 changes: 6 additions & 26 deletions test/system/students_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -242,32 +242,12 @@ class StudentsTest < ApplicationSystemTestCase
select "English", from: "thesis_language"
fill_in "thesis_abstract", with: Faker::Lorem.paragraph


execute_script("document.getElementById('select_subjects_11').style.display = 'block';")
select "Accounting", from: 'select_subjects_11'

execute_script("document.getElementById('select_subjects_12').style.display = 'block';")
select "Management", from: 'select_subjects_12'

execute_script("document.getElementById('select_subjects_13').style.display = 'block';")
select "Finance", from: 'select_subjects_13'

select "Accounting", from: 'select_subjects_11'
select "Management", from: 'select_subjects_12'
select "Finance", from: 'select_subjects_13'

execute_script("document.getElementById('select_subjects_11').style.display = 'block';")
select "Accounting", from: 'select_subjects_11'

execute_script("document.getElementById('select_subjects_12').style.display = 'block';")
select "Management", from: 'select_subjects_12'

execute_script("document.getElementById('select_subjects_13').style.display = 'block';")
select "Finance", from: 'select_subjects_13'

select "Accounting", from: 'select_subjects_11'
select "Management", from: 'select_subjects_12'
select "Finance", from: 'select_subjects_13'
find('#select_subjects_11_chosen a.chosen-default').click
find('#select_subjects_11_chosen .active-result:nth-child(1)').click
find('#select_subjects_12_chosen a.chosen-default').click
find('#select_subjects_12_chosen .active-result:nth-child(2)').click
find('#select_subjects_13_chosen a.chosen-default').click
find('#select_subjects_13_chosen .active-result:nth-child(3)').click

save_screenshot

Expand Down

0 comments on commit 2f5f212

Please sign in to comment.