Skip to content

Commit

Permalink
More tests for #55
Browse files Browse the repository at this point in the history
Merge branch '20240716-system-tests' into develop
  • Loading branch information
amtuannguyen committed Jul 22, 2024
2 parents b616177 + 0f13471 commit 62a4a8b
Show file tree
Hide file tree
Showing 3 changed files with 115 additions and 18 deletions.
1 change: 0 additions & 1 deletion app/assets/stylesheets/bootstrap_and_overrides.css.scss
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ $theme-colors-rgb: map-loop($theme-colors, to-rgb, "$value");
h3, .h3 {
color: darken($info, 30%);
font-weight: 500;
text-transform: uppercase;
}

h4, .h4, h5, .h5, h6, .h6 {
Expand Down
60 changes: 44 additions & 16 deletions test/system/students_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

class StudentsTest < ApplicationSystemTestCase
include SystemTestHelper # Include the SystemTestHelper module here


setup do
@gem_record = FactoryGirl.create(:gem_record)
Expand All @@ -20,6 +20,35 @@ class StudentsTest < ApplicationSystemTestCase
click_link('Start this thesis')
end

test 'Starting a thesis' do
visit root_url
click_link('Gem Records')
click_link(@gem_record.studentname)
click_link('Create ETD Student Record')
page.accept_alert
click_link('Start this thesis')
select "EMBA", from: "thesis_degree_name"
select "Master's", from: "thesis_degree_level"
click_button('Create Thesis')
assert_selector "a", text: @gem_record.studentname
end

test 'Editing a student' do
visit root_url
click_link('Gem Records')
click_link(@gem_record.studentname)
click_link('Create ETD Student Record')
page.accept_alert
click_link('Make changes')

fill_in('Email *', with: "[email protected]")
fill_in('Name *', with: "#{@gem_record.studentname} (test)")
click_button('Update Student')

assert_selector 'p', text: "[email protected]", visible: true
assert_selector 'h1', text: "#{@gem_record.studentname} (test)", visible: true
end

test 'Gem Record has committee members' do
visit root_url
click_link('Gem Records')
Expand All @@ -31,7 +60,6 @@ class StudentsTest < ApplicationSystemTestCase
assert_selector "p", text: committee_member.full_name
end
end

end

test 'Log in as Student and add a thesis' do
Expand Down Expand Up @@ -82,14 +110,14 @@ class StudentsTest < ApplicationSystemTestCase

# Ensure Add Committee Members button is not present.
assert_no_selector '.student-view .card .card-body a.btn.btn-success', text: 'Add committee member'

# Ensure that the close links are not present within the #committee_members section
refute_selector("#committee_members .btn-close")

end

## Page 2 and 3 tests
should "upload primary file" do
should "upload primary file" do
@thesis = FactoryGirl.create(:thesis)
create(:loc_subject, name: "Accounting", category: "BUSINESS")
create(:loc_subject, name: "Management", category: "BUSINESS")
Expand Down Expand Up @@ -132,7 +160,7 @@ class StudentsTest < ApplicationSystemTestCase

# Set Page size
page.driver.browser.manage.window.resize_to(1920, 2500)

## Page 1
click_link("My ETD Submission")
assert_selector "input#student_email_external"
Expand All @@ -155,22 +183,22 @@ class StudentsTest < ApplicationSystemTestCase
fill_in "thesis_keywords", with: "accounting-kw, management-kw"
click_on("Continue")

## Page 3
## Page 3

click_on("Upload Primary File")
assert_selector "p", text: "Your primary file should be in PDF format.", visible: :all

# assert_no_selector("p", text: "Smith_Jane_E_2014_PhD.pdf", visible: :all)
assert_not(page.has_css?("p", text: "Smith_Jane_E_2014_PhD.pdf"), "Should not show 'example text' as per Spring 2024 requirements")

attach_file("document_file", Rails.root.join('test/fixtures/files/Tony_Rich_E_2012_Phd.pdf'))
click_button('Upload')

assert_selector(".name", text: /Primary\.pdf/)

click_on("Continue")


## Page 4

# assert_text "LAC Supplementary Licence File Upload".upcase
Expand All @@ -193,16 +221,16 @@ class StudentsTest < ApplicationSystemTestCase
# Ensure the checkbox is enabled
# assert find('#thesis_yorkspace_licence_agreement').enabled?
# assert_not find('#thesis_yorkspace_licence_agreement').disabled?, "ERROR: Yorkspace licence agreement checkbox is not enabled."

checkbox = find('#thesis_yorkspace_licence_agreement')
assert_not checkbox.disabled?, "ERROR: Yorkspace licence agreement checkbox is not enabled."

# Check the checkbox
checkbox.check

# Verify that the checkbox is checked
assert checkbox.checked?, "ERROR: Yorkspace licence agreement checkbox is not checked."

end
end

Expand All @@ -211,6 +239,6 @@ class StudentsTest < ApplicationSystemTestCase
# page.driver.browser.manage.window.resize_to(1920, 2500)
# save_screenshot()
## HTML Save
# File.open("tmp/test-screenshots/error.html", "w") { |file| file.write(page.html) }
# File.open("tmp/test-screenshots/error.html", "w") { |file| file.write(page.html) }
# save_page()
########################################
########################################
72 changes: 71 additions & 1 deletion test/system/theses_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class ThesesTest < ApplicationSystemTestCase
setup do
FactoryGirl.create(:user, role: User::ADMIN)
FactoryGirl.create(:user, role: User::MANAGER)
@thesis_01 = FactoryGirl.create(:thesis)
@thesis_01 = FactoryGirl.create(:thesis, degree_name: 'IMBA', degree_level: 'Master\'s')
@thesis_02 = FactoryGirl.create(:thesis, status: Thesis::UNDER_REVIEW)
end

Expand Down Expand Up @@ -45,6 +45,76 @@ class ThesesTest < ApplicationSystemTestCase
assert_selector 'span', text: 'test2, test1'
end

test 'Remove committee member' do
visit root_url
click_link(@thesis_01.title)
click_on('Make Changes')
click_on('Add committee member')
click_on('Close')
click_on('Add committee member')

fill_in('First Name', with: 'test1')
fill_in('Last Name', with: 'test2')
choose('Committee Member')
click_on('Add Member')
assert_selector 'span', text: 'test2, test1'

accept_confirm do
find('span.fw-bold', text: 'test2, test1').find(:xpath, '../../div[@class="col-1"]/a[@class="btn btn-close pull-right"]').click
end

assert_no_selector 'span', text: 'test2, test1'
end

test 'Edit a thesis' do
visit root_url
click_link(@thesis_01.title)
click_on('Make Changes')

fill_in "thesis_title", with: "title 10 (test)"
fill_in "thesis_program", with: "program 10 (test)"
fill_in "thesis_abstract", with: "Testing Abstract"
click_button('Update Thesis')

assert_selector 'h3', text: 'title 10 (test)', visible: true

assert_selector 'p', text: 'program 10 (test)', visible: true

assert_selector 'p', text: 'Testing Abstract', visible: true
end

test 'Returning a thesis' do
visit root_url
click_link(@thesis_01.title)

find('a.btn.btn-secondary.btn-sm.dropdown-toggle').click
choose('status', option: 'under_review')
click_on('Change Status')


find('a.btn.btn-secondary.btn-sm.dropdown-toggle').click
choose('status', option: 'returned')
click_on('Change Status')

assert_selector 'span.badge.bg-primary', text: 'Returned'
end

test 'Accepting a thesis' do
visit root_url
click_link(@thesis_01.title)

find('a.btn.btn-secondary.btn-sm.dropdown-toggle').click
choose('status', option: 'under_review')
click_on('Change Status')


find('a.btn.btn-secondary.btn-sm.dropdown-toggle').click
choose('status', option: 'accepted')
click_on('Change Status')

assert_selector 'span.badge.bg-primary', text: 'Accepted'
end

test 'Add an embargo' do
visit root_url
click_link(@thesis_01.title)
Expand Down

0 comments on commit 62a4a8b

Please sign in to comment.