1 # Copyright (C) The Arvados Authors. All rights reserved.
3 # SPDX-License-Identifier: AGPL-3.0
7 class WorkUnitsControllerTest < ActionController::TestCase
8 # These tests don't do state-changing API calls.
9 # Save some time by skipping the database reset.
10 reset_api_fixtures :after_each_test, false
11 reset_api_fixtures :after_suite, true
15 ['/pipeline_instances/zzzzz-d1hrv-1xfj6xkicf2muk2',
16 '/pipeline_instances/zzzzz-d1hrv-1yfj61234abcdk4',
17 '/jobs/zzzzz-8i9sb-grx15v5mjnsyxk7'],
18 ['/pipeline_instances/zzzzz-d1hrv-1yfj61234abcdk3',
19 '/jobs/zzzzz-8i9sb-n7omg50bvt0m1nf',
20 '/container_requests/zzzzz-xvhdp-cr4completedcr2']],
21 ['pipeline_with_tagged_collection_input', 1, 1,
22 ['/pipeline_instances/zzzzz-d1hrv-1yfj61234abcdk3'],
23 ['/pipeline_instances/zzzzz-d1hrv-1yfj61234abcdk4',
24 '/jobs/zzzzz-8i9sb-pshmckwoma9plh7',
25 '/jobs/zzzzz-8i9sb-n7omg50bvt0m1nf',
26 '/container_requests/zzzzz-xvhdp-cr4completedcr2']],
27 ['no_such_match', 0, 0,
29 ['/pipeline_instances/zzzzz-d1hrv-1yfj61234abcdk4',
30 '/jobs/zzzzz-8i9sb-pshmckwoma9plh7',
31 '/jobs/zzzzz-8i9sb-n7omg50bvt0m1nf',
32 '/container_requests/zzzzz-xvhdp-cr4completedcr2']],
33 ].each do |search_filter, expected_min, expected_max, expected, not_expected|
34 test "all_processes page for search filter '#{search_filter}'" do
35 work_units_index(filters: [['any','ilike', "%#{search_filter}%"]], show_children: true)
36 assert_response :success
38 # Verify that expected number of processes are found
39 found_count = json_response['content'].scan('<tr').count
40 if expected_min == expected_max
41 assert_equal(true, found_count == expected_min,
42 "Not found expected number of items. Expected #{expected_min} and found #{found_count}")
44 assert_equal(true, found_count>=expected_min,
45 "Found too few items. Expected at least #{expected_min} and found #{found_count}")
46 assert_equal(true, found_count<=expected_max,
47 "Found too many items. Expected at most #{expected_max} and found #{found_count}")
50 # verify that all expected uuid links are found
51 expected.each do |link|
52 assert_match /href="#{link}"/, json_response['content']
55 # verify that none of the not_expected uuid links are found
56 not_expected.each do |link|
57 assert_no_match /href="#{link}"/, json_response['content']
62 def work_units_index params
64 partial: :all_processes_rows,
67 encoded_params = Hash[params.map { |k,v|
68 [k, (v.is_a?(Array) || v.is_a?(Hash)) ? v.to_json : v]
70 get :index, params: encoded_params, session: session_for(:active)