4062: fix greedy infinite scrolling in tabs displaying more than one kind (Jobs and...
authorradhika <radhika@curoverse.com>
Thu, 16 Oct 2014 14:45:24 +0000 (10:45 -0400)
committerradhika <radhika@curoverse.com>
Thu, 16 Oct 2014 14:45:24 +0000 (10:45 -0400)
Not only did scrolling never stopped, it never reloaded the next page and reloaded the same first page again and again.
Added test fixtures with many objects to test scrolling.
Added tests to use vertical scrollbar. The test itself is not able to test infinite scrolling by reloading the next page.
This may be because in integration testing new content is displayed only due to a click action.

apps/workbench/app/controllers/projects_controller.rb
apps/workbench/test/integration/projects_test.rb
apps/workbench/test/test_helper.rb
services/api/test/fixtures/api_client_authorizations.yml
services/api/test/fixtures/collections.yml
services/api/test/fixtures/groups.yml
services/api/test/fixtures/jobs.yml
services/api/test/fixtures/links.yml
services/api/test/fixtures/pipeline_instances.yml
services/api/test/fixtures/users.yml

index 435e0cd5d68f9086a1cf83ea8d5377d360daedac..e918099c9ed29b9e85543537f4262560d83f5204 100644 (file)
@@ -206,10 +206,12 @@ class ProjectsController < ApplicationController
         attr == 'created_at' and op == nextpage_operator
       end
       if @objects.any?
+        @offset += @objects.length
         @next_page_filters += [['created_at',
                                 nextpage_operator,
                                 @objects.last.created_at]]
         @next_page_href = url_for(partial: :contents_rows,
+                                  offset: @offset,
                                   filters: @next_page_filters.to_json)
       else
         @next_page_href = nil
index 83565f939dbeef6a2ab6afdbea375b286cc77d45..f0d612b6252e7a814fdfc63d7a674f98552e638f 100644 (file)
@@ -485,4 +485,128 @@ class ProjectsTest < ActionDispatch::IntegrationTest
     end
   end
 
+  [
+    ['project with 10 collections', 10],
+    ['project with 201 collections', 201], # two pages of data
+  ].each do |project_name, amount|
+    test "scroll collections tab for #{project_name} with #{amount} objects" do
+      visit page_with_token 'user1_with_load'
+
+      find("#projects-menu").click
+      find(".dropdown-menu a", text: project_name).click
+
+      my_collections = []
+      for i in 1..amount
+        my_collections << "Collection_#{i}"
+      end
+
+      # verify Data collections scroll
+      assert(page.has_text?("Data collections (#{amount})"), "Number of collections did not match the input amount")
+
+      click_link 'Data collections'
+      begin
+        wait_for_ajax
+      rescue
+      end
+
+      verify_collections = my_collections.dup
+      unexpected_items = []
+      collections_count = 0
+      within('.arv-project-Data_collections') do
+        scrollbar_present = page.execute_script("return document.documentElement.scrollHeight>document.documentElement.clientHeight;");
+        if scrollbar_present
+          page.execute_script "window.scrollBy(0,10000)"
+          begin
+            wait_for_ajax
+          rescue
+          end
+        end
+
+        # Visit all rows. If not all expected collections are found, retry
+        found_collections = page.all('tr[data-kind="arvados#collection"]')
+        collections_count = found_collections.count
+
+        (0..collections_count-1).each do |i|
+          # Found row text would be of the format "Show Collection_#{n} " 
+          collection_name = found_collections[i].text.split[1]
+          if !my_collections.include? collection_name
+            unexpected_items << collection_name
+          else
+            verify_collections.delete collection_name
+          end
+        end
+
+        assert_equal true, unexpected_items.empty?, "Found unexpected items #{unexpected_items.inspect}"
+        if amount > 200
+          assert_equal 200, collections_count, "Found different number of collections"
+          assert_equal amount-200, verify_collections.length, "Did not find all the collections"  
+        else
+          assert_equal amount, collections_count, "Found different number of collections"
+          assert_equal true, verify_collections.empty?, "Did not find all the collections"
+        end
+      end
+    end
+  end
+
+  [
+    ['project with 10 pipelines', 10, 0],
+    ['project with 20 pipelines and jobs', 20, 20],
+#    ['project with 250 pipelines', 250, 0],
+  ].each do |project_name, num_pipelines, num_jobs|
+    test "scroll pipeline instances tab for #{project_name} with #{num_pipelines} pipelines and #{num_jobs} jobs" do
+      visit page_with_token 'user1_with_load'
+
+      find("#projects-menu").click
+      find(".dropdown-menu a", text: project_name).click
+
+      my_pipelines = []
+      (1..num_pipelines).each do |i|
+        name = "pipeline_#{i}"
+        my_pipelines << name
+      end
+
+      # verify Jobs and pipelines tab scroll
+      assert(page.has_text?("Jobs and pipelines (#{num_pipelines+num_jobs})"), "Number of objects did not match the input counts")
+      click_link 'Jobs and pipelines'
+      begin
+        wait_for_ajax
+      rescue
+      end
+      
+      verify_pipelines = my_pipelines.dup
+      unexpected_items = []
+      object_count = 0
+      within('.arv-project-Jobs_and_pipelines') do
+        scrollbar_present = page.execute_script("return document.documentElement.scrollHeight>document.documentElement.clientHeight;");
+        if scrollbar_present
+          page.execute_script "window.scrollBy(0,10000)"
+          begin
+            wait_for_ajax
+          rescue
+          end
+        end
+
+        # Visit all rows. Repeat if not all expected my_pipelines are found (inifinite scrolling should kick in)
+        pipelines_found = page.all('tr[data-kind="arvados#pipelineInstance"]')
+        pipeline_count = pipelines_found.count
+        (0..pipeline_count-1).each do |i|
+          name = pipelines_found[i].text.split[1]
+          if !my_pipelines.include? name
+            unexpected_items << name
+          else
+            verify_pipelines.delete name
+          end
+
+          assert_equal true, unexpected_items.empty?, "Found unexpected items #{unexpected_items.inspect}"
+        end
+        assert_equal num_pipelines, pipeline_count, "Found different number of pipelines"
+        assert_equal true, verify_pipelines.empty?, "Did not find all the pipelines"
+
+        jobs_found = page.all('tr[data-kind="arvados#job"]')
+        job_count = jobs_found.count
+        assert_equal num_jobs, job_count, 'Did not find expected number of jobs'
+      end
+    end
+  end
+
 end
index 5253676578e18b4eaf0692db37c1358b34c092d3..eea81d1b775d2cc29ac07c877a2ff009f5858456 100644 (file)
@@ -61,7 +61,10 @@ module ApiFixtureLoader
       begin
         path = File.join(ApiServerForTests::ARV_API_SERVER_DIR,
                          'test', 'fixtures', "#{name}.yml")
-        YAML.load(IO.read(path))
+        file = IO.read(path)
+        trim_index = file.index('# Test Helper trims the rest of the file')
+        file = file[0, trim_index] if trim_index
+        YAML.load(file)
       end
     end
   end
index 32560c3397ffa9751155aff3da36f8988471ddea..f334281a62ee35d3abf7c0510e301c20a548b709 100644 (file)
@@ -180,3 +180,9 @@ user_foo_in_sharing_group:
   user: user_foo_in_sharing_group
   api_token: 2p1pou8p4ls208mcbedeewlotghppenobcyrmyhq8pyf51xd8u
   expires_at: 2038-01-01 00:00:00
+
+user1_with_load:
+  api_client: untrusted
+  user: user1_with_load
+  api_token: 1234k6lzmp9kj5cpkcoxie963cmvjahbt2fod9zru30k1jqdmi
+  expires_at: 2038-01-01 00:00:00
index 2fb235c7080dd674e59f5f8cf52d5f6df2a7c22d..d1f1d22780958a20e5bb152151e10a9a772e46dd 100644 (file)
@@ -257,3 +257,31 @@ collection_owned_by_foo:
   owner_uuid: zzzzz-tpzed-81hsbo6mk8nl05c
   created_at: 2014-02-03T17:22:54Z
   name: collection_owned_by_foo
+
+# Test Helper trims the rest of the file
+
+# Do not add your fixtures below this line as the rest of this file will be trimmed by test_helper
+
+# collections in project_with_10_collections
+<% for i in 1..10 do %>
+collection_<%=i%>_of_10:
+  name: Collection_<%= i %>
+  portable_data_hash: ea10d51bcf88862dbcc36eb292017dfd+45
+  manifest_text: ". 73feffa4b7f6bb68e44cf984c85f6e88+3 0:3:baz\n"
+  uuid: zzzzz-4zz18-10gneyn6brkx<%= i.to_s.rjust(3, '0') %>
+  owner_uuid: zzzzz-j7d0g-0010collections
+  created_at: <%= 1.minute.ago.to_s(:db) %>
+<% end %>
+
+# collections in project_with_201_collections
+<% for i in 1..201 do %>
+collection_<%=i%>_of_201:
+  name: Collection_<%= i %>
+  portable_data_hash: ea10d51bcf88862dbcc36eb292017dfd+45
+  manifest_text: ". 73feffa4b7f6bb68e44cf984c85f6e88+3 0:3:baz\n"
+  uuid: zzzzz-4zz18-201gneyn6brd<%= i.to_s.rjust(3, '0') %>
+  owner_uuid: zzzzz-j7d0g-0201collections
+  created_at: <%= 1.minute.ago.to_s(:db) %>
+<% end %>
+
+# Do not add your fixtures below this line as the rest of this file will be trimmed by test_helper
index 8f209e9b9c691b56da02c187aba8302932c0fe8e..3681c7e8367b96c384fef71783443546eb92b58c 100644 (file)
@@ -130,10 +130,69 @@ active_user_has_can_manage:
   name: Active user has can_manage
 
 # Group for testing granting permission between users who share a group.
-#
 group_for_sharing_tests:
   uuid: zzzzz-j7d0g-t4ucgncwteul7zt
   owner_uuid: zzzzz-tpzed-000000000000000
   name: Group for sharing tests
   description: Users who can share objects with each other
   group_class: role
+
+project_with_10_collections:
+  uuid: zzzzz-j7d0g-0010collections
+  owner_uuid: zzzzz-tpzed-user1withloadab
+  created_at: 2014-04-21 15:37:48 -0400
+  modified_by_client_uuid: zzzzz-ozdt8-brczlopd8u8d0jr
+  modified_by_user_uuid: zzzzz-tpzed-user1withloadab
+  modified_at: 2014-04-21 15:37:48 -0400
+  updated_at: 2014-04-21 15:37:48 -0400
+  name: project with 10 collections
+  description: This will result in one page in the display
+  group_class: project
+
+project_with_201_collections:
+  uuid: zzzzz-j7d0g-0201collections
+  owner_uuid: zzzzz-tpzed-user1withloadab
+  created_at: 2014-04-21 15:37:48 -0400
+  modified_by_client_uuid: zzzzz-ozdt8-brczlopd8u8d0jr
+  modified_by_user_uuid: zzzzz-tpzed-user1withloadab
+  modified_at: 2014-04-21 15:37:48 -0400
+  updated_at: 2014-04-21 15:37:48 -0400
+  name: project with 201 collections
+  description: This will result in two pages in the display
+  group_class: project
+
+project_with_10_pipelines:
+  uuid: zzzzz-j7d0g-000010pipelines
+  owner_uuid: zzzzz-tpzed-user1withloadab
+  created_at: 2014-04-21 15:37:48 -0400
+  modified_by_client_uuid: zzzzz-ozdt8-brczlopd8u8d0jr
+  modified_by_user_uuid: zzzzz-tpzed-user1withloadab
+  modified_at: 2014-04-21 15:37:48 -0400
+  updated_at: 2014-04-21 15:37:48 -0400
+  name: project with 10 pipelines
+  description: project with 10 pipelines
+  group_class: project
+
+project_with_20_jobs_and_20_pipelines:
+  uuid: zzzzz-j7d0g-20jobspipelines
+  owner_uuid: zzzzz-tpzed-user1withloadab
+  created_at: 2014-04-21 15:37:48 -0400
+  modified_by_client_uuid: zzzzz-ozdt8-brczlopd8u8d0jr
+  modified_by_user_uuid: zzzzz-tpzed-user1withloadab
+  modified_at: 2014-04-21 15:37:48 -0400
+  updated_at: 2014-04-21 15:37:48 -0400
+  name: project with 20 pipelines and jobs
+  description: This will result in two pages in the display
+  group_class: project
+
+project_with_250_pipelines:
+  uuid: zzzzz-j7d0g-000201pipelines
+  owner_uuid: zzzzz-tpzed-user1withloadab
+  created_at: 2014-04-21 15:37:48 -0400
+  modified_by_client_uuid: zzzzz-ozdt8-brczlopd8u8d0jr
+  modified_by_user_uuid: zzzzz-tpzed-user1withloadab
+  modified_at: 2014-04-21 15:37:48 -0400
+  updated_at: 2014-04-21 15:37:48 -0400
+  name: project with 250 pipelines
+  description: project with 250 pipelines
+  group_class: project
index 5836809c692163bd40288ef74c9cf8e11298a06e..0096affd462243260773ca065f2548ccae7f9461 100644 (file)
@@ -284,3 +284,19 @@ cancelled:
     done: 1
   runtime_constraints: {}
   state: Cancelled
+
+# Test Helper trims the rest of the file
+
+# Do not add your fixtures below this line as the rest of this file will be trimmed by test_helper
+
+# jobs in project_with_20_pipelines_and_20_jobs
+<% for i in 1..20 do %>
+job_<%=i%>_of_20:
+  uuid: zzzzz-8i9sb-0vsrcqi7whch<%= i.to_s.rjust(3, '0') %>
+  created_at: 2014-09-01 12:00:00
+  owner_uuid: zzzzz-j7d0g-20jobspipelines
+  script_version: 7def43a4d3f20789dda4700f703b5514cc3ed250
+  state: Complete
+<% end %>
+
+# Do not add your fixtures below this line as the rest of this file will be trimmed by test_helper
index 9e139714911f066a217468abebdbb841a03b95d4..bca925fca188ab7f873f13f708cc646bb96edd06 100644 (file)
@@ -735,3 +735,16 @@ user_bar_is_in_sharing_group:
   name: can_read
   head_uuid: zzzzz-tpzed-n3oaj4sm5fcnwib
 
+user1-with-load_member_of_all_users_group:
+  uuid: zzzzz-o0j2j-user1-with-load
+  owner_uuid: zzzzz-tpzed-000000000000000
+  created_at: 2014-01-24 20:42:26 -0800
+  modified_by_client_uuid: zzzzz-ozdt8-brczlopd8u8d0jr
+  modified_by_user_uuid: zzzzz-tpzed-d9tiejq69daie8f
+  modified_at: 2014-01-24 20:42:26 -0800
+  updated_at: 2014-01-24 20:42:26 -0800
+  tail_uuid: zzzzz-tpzed-user1withloadab
+  link_class: permission
+  name: can_read
+  head_uuid: zzzzz-j7d0g-fffffffffffffff
+  properties: {}
index a3d372bbca1a6add5c5504911ff8e1119298f3d2..8aa5977def367f03510737469ba79b0e80235be2 100644 (file)
@@ -143,3 +143,66 @@ pipeline_with_newer_template:
           required: true
           dataclass: Collection
           title: foo instance input
+
+# Test Helper trims the rest of the file
+
+# Do not add your fixtures below this line as the rest of this file will be trimmed by test_helper
+
+# pipelines in project_with_10_pipelines
+<% for i in 1..10 do %>
+pipeline_<%=i%>_of_10:
+  name: pipeline_<%= i %>
+  state: New
+  uuid: zzzzz-d1hrv-10gneyn6br1x<%= i.to_s.rjust(3, '0') %>
+  owner_uuid: zzzzz-j7d0g-000010pipelines
+  created_at: <%= 1.minute.ago.to_s(:db) %>
+  components:
+    foo:
+      script: foo
+      script_version: master
+      script_parameters:
+        input:
+          required: true
+          dataclass: Collection
+          title: foo instance input
+<% end %>
+
+# pipelines in project_with_20_pipelines_and_20_jobs
+<% for i in 1..20 do %>
+pipeline_<%=i%>_of_20_pipelines_and_20_jobs:
+  name: pipeline_<%= i %>
+  state: New
+  uuid: zzzzz-d1hrv-abcgneyn6brx<%= i.to_s.rjust(3, '0') %>
+  owner_uuid: zzzzz-j7d0g-20jobspipelines
+  created_at: <%= 1.minute.ago.to_s(:db) %>
+  components:
+    foo:
+      script: foo
+      script_version: master
+      script_parameters:
+        input:
+          required: true
+          dataclass: Collection
+          title: foo instance input
+<% end %>
+
+# pipelines in project_with_250_pipelines
+<% for i in 1..250 do %>
+pipeline_<%=i%>_of_250_pipelines:
+  name: pipeline_<%= i %>
+  state: New
+  uuid: zzzzz-d1hrv-250gneyn6brx<%= i.to_s.rjust(3, '0') %>
+  owner_uuid: zzzzz-j7d0g-000250pipelines
+  created_at: <%= 1.minute.ago.to_s(:db) %>
+  components:
+    foo:
+      script: foo
+      script_version: master
+      script_parameters:
+        input:
+          required: true
+          dataclass: Collection
+          title: foo instance input
+<% end %>
+
+# Do not add your fixtures below this line as the rest of this file will be trimmed by test_helper
index 2dd72ab4b18ed0a7f64bd1c3cf8db19ca48faacc..92fce2c7d5b746164584ec3ef6283e517fbb01f7 100644 (file)
@@ -200,3 +200,17 @@ user_bar_in_sharing_group:
   identity_url: https://user_bar_in_sharing_group.openid.local
   is_active: true
   is_admin: false
+
+user1_with_load:
+  owner_uuid: zzzzz-tpzed-000000000000000
+  uuid: zzzzz-tpzed-user1withloadab
+  email: user1_with_load@arvados.local
+  first_name: user1_with_load
+  last_name: User
+  identity_url: https://user1_with_load.openid.local
+  is_active: true
+  is_admin: false
+  prefs:
+    profile:
+      organization: example.com
+      role: IT