Skip to content

Commit

Permalink
some small tweaks in these test cases (#3019)
Browse files Browse the repository at this point in the history
Some small tweaks in these test cases to prefer regular string interpolation over `%Q`.
  • Loading branch information
johrstrom authored Sep 8, 2023
1 parent 63ffad9 commit a9056f6
Showing 1 changed file with 27 additions and 27 deletions.
54 changes: 27 additions & 27 deletions apps/dashboard/test/system/jobs_app_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def setup_project(root_dir, override_project_dir = nil)
project_element = find('.project-card')
project_id = project_element[:id]

project_dir = override_project_dir ? override_project_dir : "#{root_dir}/projects/#{project_id}"
project_dir = override_project_dir || "#{root_dir}/projects/#{project_id}"
`echo 'some_other_command' > #{project_dir}/my_cool_script.sh`
`echo 'hostname' > #{project_dir}/my_cooler_script.bash`

Expand All @@ -52,7 +52,7 @@ def setup_script(project_id)
def add_account(project_id, script_id)
visit project_path(project_id)
edit_script_path = edit_project_script_path(project_id, script_id)
find(%Q{[href="#{edit_script_path}"]}).click
find("[href='#{edit_script_path}']").click

# now add 'auto_accounts'
click_on('Add new option')
Expand All @@ -64,7 +64,7 @@ def add_account(project_id, script_id)
def add_bc_num_hours(project_id, script_id)
visit project_path(project_id)
edit_script_path = edit_project_script_path(project_id, script_id)
find(%Q{[href="#{edit_script_path}"]}).click
find("[href='#{edit_script_path}']").click

# now add 'bc_num_hours'
click_on('Add new option')
Expand All @@ -79,7 +79,7 @@ def add_bc_num_hours(project_id, script_id)
project_id = setup_project(dir)

assert_selector '.alert-success', text: 'Project successfully created!'
assert_selector %Q{[href="/projects/#{project_id}"]}, text: 'Test Project'
assert_selector "[href='/projects/#{project_id}']", text: 'Test Project'
assert File.directory? File.join("#{dir}/projects", project_id)
end
end
Expand All @@ -98,10 +98,10 @@ def add_bc_num_hours(project_id, script_id)
Pathname(project_override_dir).mkpath
setup_project(dir, project_override_dir)

assert File.directory?(File.join("#{project_override_dir}", '.ondemand'))
assert File.exist?(File.join("#{project_override_dir}", '.ondemand', 'manifest.yml'))
assert File.directory?(File.join(project_override_dir.to_s, '.ondemand'))
assert File.exist?(File.join(project_override_dir.to_s, '.ondemand', 'manifest.yml'))

#Cleanup to avoid side effects
# Cleanup to avoid side effects
accept_confirm do
click_on 'Delete'
end
Expand All @@ -112,24 +112,24 @@ def add_bc_num_hours(project_id, script_id)
test 'delete a project from the fs and ensure no table entry' do
Dir.mktmpdir do |dir|
project_id = setup_project(dir)
assert File.directory? File.join(dir, "projects", project_id)
assert File.directory? File.join(dir, 'projects', project_id)

accept_confirm do
click_on 'Delete'
end

assert_selector '.alert-success', text: 'Project successfully deleted!'
assert_no_selector %Q{[href="/projects/#{project_id}"]}, text: 'Test Project'
assert File.directory? File.join(dir, "projects", project_id)
assert_not File.directory? File.join(dir, "projects", project_id, '.ondemand')
assert_no_selector "[href='/projects/#{project_id}']", text: 'Test Project'
assert File.directory? File.join(dir, 'projects', project_id)
assert_not File.directory? File.join(dir, 'projects', project_id, '.ondemand')
end
end

test 'work in a project' do
Dir.mktmpdir do |dir|
project_id = setup_project(dir)

find(%Q{[href="/projects/#{project_id}"]}).click
find("[href='/projects/#{project_id}']").click
assert_selector 'h1', text: 'Test Project'
assert_selector '.btn.btn-default', text: 'Back'
end
Expand All @@ -142,7 +142,7 @@ def add_bc_num_hours(project_id, script_id)
click_on 'Edit'
find('#project_name').set('my-test-project')
click_on 'Save'
assert_selector %Q{[href="/projects/#{project_id}"]}, text: 'My Test Project'
assert_selector "[href='/projects/#{project_id}']", text: 'My Test Project'
click_on 'Edit'
assert_selector 'h1', text: 'Editing: My Test Project'
assert_equal 'my-test-project', find('#project_name').value
Expand Down Expand Up @@ -216,7 +216,7 @@ def add_bc_num_hours(project_id, script_id)
assert_equal(expected_yml, File.read("#{dir}/projects/#{project_id}/.ondemand/scripts/#{script_id}/form.yml"))

script_path = project_script_path(project_id, script_id)
find(%Q{[href="#{script_path}"].btn-success}).click
find("[href='#{script_path}'].btn-success").click
assert_selector('h1', text: 'the script title', count: 1)
end
end
Expand All @@ -229,7 +229,7 @@ def add_bc_num_hours(project_id, script_id)
add_account(project_id, script_id)

script_path = project_script_path(project_id, script_id)
find(%Q{[href="#{script_path}"].btn-success}).click
find("[href='#{script_path}'].btn-success").click
assert_selector('h1', text: 'the script title', count: 1)

expected_accounts = ['pas1604', 'pas1754', 'pas1871', 'pas2051', 'pde0006', 'pzs0714', 'pzs0715', 'pzs1010',
Expand Down Expand Up @@ -280,7 +280,7 @@ def add_bc_num_hours(project_id, script_id)


script_path = project_script_path(project_id, script_id)
find(%Q{[href="#{script_path}"].btn-success}).click
find("[href='#{script_path}'].btn-success").click
assert_selector('h1', text: 'the script title', count: 1)

# assert defaults
Expand Down Expand Up @@ -320,7 +320,7 @@ def add_bc_num_hours(project_id, script_id)
add_account(project_id, script_id)

script_path = project_script_path(project_id, script_id)
find(%Q{[href="#{script_path}"].btn-success}).click
find("[href='#{script_path}'].btn-success").click
assert_selector('h1', text: 'the script title', count: 1)

# assert defaults
Expand Down Expand Up @@ -353,7 +353,7 @@ def add_bc_num_hours(project_id, script_id)
visit project_path(project_id)

edit_script_path = edit_project_script_path(project_id, script_id)
find(%Q{[href="#{edit_script_path}"]}).click
find("[href='#{edit_script_path}']").click

click_on('Add new option')
new_field_id = 'add_new_field_select'
Expand All @@ -372,7 +372,7 @@ def add_bc_num_hours(project_id, script_id)
visit project_path(project_id)

edit_script_path = edit_project_script_path(project_id, script_id)
find(%Q{[href="#{edit_script_path}"]}).click
find("[href='#{edit_script_path}']").click

# only shows 'cluster' & 'auto_scripts'
assert_equal 2, page.all('.form-group').size
Expand All @@ -386,7 +386,7 @@ def add_bc_num_hours(project_id, script_id)
# add bc_num_hours
add_bc_num_hours(project_id, script_id)
script_edit_path = edit_project_script_path(project_id, script_id)
find(%Q{[href="#{script_edit_path}"]}).click
find("[href='#{script_edit_path}']").click

# now shows 'cluster', 'auto_scripts' & the newly added'bc_num_hours'
assert_equal 3, page.all('.form-group').size
Expand Down Expand Up @@ -462,7 +462,7 @@ def add_bc_num_hours(project_id, script_id)
# go to edit it and see that there is cluster and bc_num_hours
visit project_path(project_id)
edit_script_path = edit_project_script_path(project_id, script_id)
find(%Q{[href="#{edit_script_path}"]}).click
find("[href='#{edit_script_path}']").click
# puts page.body
assert_equal 4, page.all('.form-group').size
assert_not_nil find('#script_auto_batch_clusters')
Expand Down Expand Up @@ -616,13 +616,13 @@ def add_bc_num_hours(project_id, script_id)
assert(!!add_btn[:disabled])
end

find("#save_script_edit").click
find('#save_script_edit').click
assert_current_path(project_path(project_id))
script_path = project_script_path(project_id, script_id)
find(%Q{[href="#{script_path}"].btn-success}).click
find("[href='#{script_path}'].btn-success").click

# now let's check scripts#show to see if they've actually been excluded.
show_account_options = page.all("#script_auto_accounts option").map(&:value)
show_account_options = page.all('#script_auto_accounts option').map(&:value)
exclude_accounts.each do |acct|
assert(!show_account_options.include?(acct))
end
Expand All @@ -644,13 +644,13 @@ def add_bc_num_hours(project_id, script_id)
assert(!!rm_btn[:disabled])
end

find("#save_script_edit").click
find('#save_script_edit').click
assert_current_path(project_path(project_id))
script_path = project_script_path(project_id, script_id)
find(%Q{[href="#{script_path}"].btn-success}).click
find("[href='#{script_path}'].btn-success").click

# now let's check scripts#show and they should be back.
show_account_options = page.all("#script_auto_accounts option").map(&:value)
show_account_options = page.all('#script_auto_accounts option').map(&:value)
exclude_accounts.each do |acct|
assert(show_account_options.include?(acct))
end
Expand Down

0 comments on commit a9056f6

Please sign in to comment.