3 class WorkUnitsControllerTest < ActionController::TestCase
4 # These tests don't do state-changing API calls.
5 # Save some time by skipping the database reset.
6 reset_api_fixtures :after_each_test, false
7 reset_api_fixtures :after_suite, true
11 ['/pipeline_instances/zzzzz-d1hrv-1xfj6xkicf2muk2',
12 '/pipeline_instances/zzzzz-d1hrv-jobspeccomponts',
13 '/jobs/zzzzz-8i9sb-grx15v5mjnsyxk7'],
14 ['/pipeline_instances/zzzzz-d1hrv-1yfj61234abcdk3',
15 '/jobs/zzzzz-8i9sb-n7omg50bvt0m1nf',
16 '/container_requests/zzzzz-xvhdp-cr4completedcr2']],
17 ['pipeline_with_tagged_collection_input', 1, 1,
18 ['/pipeline_instances/zzzzz-d1hrv-1yfj61234abcdk3'],
19 ['/pipeline_instances/zzzzz-d1hrv-jobspeccomponts',
20 '/jobs/zzzzz-8i9sb-pshmckwoma9plh7',
21 '/jobs/zzzzz-8i9sb-n7omg50bvt0m1nf',
22 '/container_requests/zzzzz-xvhdp-cr4completedcr2']],
23 ['no_such_match', 0, 0,
25 ['/pipeline_instances/zzzzz-d1hrv-jobspeccomponts',
26 '/jobs/zzzzz-8i9sb-pshmckwoma9plh7',
27 '/jobs/zzzzz-8i9sb-n7omg50bvt0m1nf',
28 '/container_requests/zzzzz-xvhdp-cr4completedcr2']],
29 ].each do |search_filter, expected_min, expected_max, expected, not_expected|
30 test "all_processes page for search filter '#{search_filter}'" do
31 work_units_index(filters: [['any','@@', search_filter]])
32 assert_response :success
34 # Verify that expected number of processes are found
35 found_count = json_response['content'].scan('<tr').count
36 if expected_min == expected_max
37 assert_equal(true, found_count == expected_min,
38 "Not found expected number of items. Expected #{expected_min} and found #{found_count}")
40 assert_equal(true, found_count>=expected_min,
41 "Found too few items. Expected at least #{expected_min} and found #{found_count}")
42 assert_equal(true, found_count<=expected_max,
43 "Found too many items. Expected at most #{expected_max} and found #{found_count}")
46 # verify that all expected uuid links are found
47 expected.each do |link|
48 assert_match /href="#{link}"/, json_response['content']
51 # verify that none of the not_expected uuid links are found
52 not_expected.each do |link|
53 assert_no_match /href="#{link}"/, json_response['content']
58 def work_units_index params
60 partial: :all_processes_rows,
63 encoded_params = Hash[params.map { |k,v|
64 [k, (v.is_a?(Array) || v.is_a?(Hash)) ? v.to_json : v]
66 get :index, encoded_params, session_for(:active)