9319: /all_processes index page.
[arvados.git] / apps / workbench / test / integration / work_units_test.rb
1 require 'integration_helper'
2
3 class WorkUnitsTest < ActionDispatch::IntegrationTest
4   setup do
5     need_javascript
6   end
7
8   test "scroll all_processes page" do
9       expected_min, expected_max, expected, not_expected = [
10         25, 100,
11         ['/pipeline_instances/zzzzz-d1hrv-1yfj61234abcdk3',
12          '/pipeline_instances/zzzzz-d1hrv-jobspeccomponts',
13          '/jobs/zzzzz-8i9sb-grx15v5mjnsyxk7',
14          '/jobs/zzzzz-8i9sb-n7omg50bvt0m1nf',
15          '/container_requests/zzzzz-xvhdp-cr4completedcr2',
16          '/container_requests/zzzzz-xvhdp-cr4requestercn2'],
17         ['/pipeline_instances/zzzzz-d1hrv-scarxiyajtshq3l',
18          '/container_requests/zzzzz-xvhdp-oneof60crs00001']
19       ]
20
21       visit page_with_token('active', "/all_processes")
22
23       page_scrolls = expected_max/20 + 2
24       within('.arv-recent-all-processes') do
25         (0..page_scrolls).each do |i|
26           page.driver.scroll_to 0, 999000
27           begin
28             wait_for_ajax
29           rescue
30           end
31         end
32       end
33
34       # Verify that expected number of processes are found
35       found_items = page.all('tr[data-object-uuid]')
36       found_count = found_items.count
37       if expected_min == expected_max
38         assert_equal(true, found_count == expected_min,
39           "Not found expected number of items. Expected #{expected_min} and found #{found_count}")
40         assert page.has_no_text? 'request failed'
41       else
42         assert_equal(true, found_count>=expected_min,
43           "Found too few items. Expected at least #{expected_min} and found #{found_count}")
44         assert_equal(true, found_count<=expected_max,
45           "Found too many items. Expected at most #{expected_max} and found #{found_count}")
46       end
47
48       # verify that all expected uuid links are found
49       expected.each do |link|
50         assert_selector "a[href=\"#{link}\"]"
51       end
52
53       # verify that none of the not_expected uuid links are found
54       not_expected.each do |link|
55         assert_no_selector "a[href=\"#{link}\"]"
56       end
57   end
58 end