8784: Fix test for latest firefox.
[arvados.git] / apps / workbench / test / integration_performance / collections_perf_test.rb
1 require 'integration_helper'
2
3 # The tests in the "integration_performance" dir are not included in regular
4 #   build pipeline since it is not one of the "standard" test directories.
5 #
6 # To run tests in this directory use the following command:
7 # ./run-tests.sh WORKSPACE=~/arvados --only apps/workbench apps/workbench_test="TEST=test/integration_performance/*.rb"
8 #
9
10 class CollectionsPerfTest < ActionDispatch::IntegrationTest
11   setup do
12     Capybara.current_driver = :rack_test
13   end
14
15   def create_large_collection size, file_name_prefix
16     manifest_text = ". d41d8cd98f00b204e9800998ecf8427e+0"
17
18     i = 0
19     until manifest_text.length > size do
20       manifest_text << " 0:0:#{file_name_prefix}#{i.to_s}"
21       i += 1
22     end
23     manifest_text << "\n"
24
25     Rails.logger.info "Creating collection at #{Time.now.to_f}"
26     collection = Collection.create! ({manifest_text: manifest_text})
27     Rails.logger.info "Done creating collection at #{Time.now.to_f}"
28
29     collection
30   end
31
32   [
33     1000000,
34     10000000,
35     20000000,
36   ].each do |size|
37     test "Create and show large collection with manifest text of #{size}" do
38       use_token :active
39       new_collection = create_large_collection size, 'collection_file_name_with_prefix_'
40
41       Rails.logger.info "Visiting collection at #{Time.now.to_f}"
42       visit page_with_token('active', "/collections/#{new_collection.uuid}")
43       Rails.logger.info "Done visiting collection at #{Time.now.to_f}"
44
45       assert_selector "input[value=\"#{new_collection.uuid}\"]"
46       assert(page.has_link?('collection_file_name_with_prefix_0'), "Collection page did not include file link")
47     end
48   end
49
50   # This does not work with larger sizes because of need_javascript.
51   # Just use one test with 100,000 for now.
52   [
53     100000,
54   ].each do |size|
55     test "Create, show, and update description for large collection with manifest text of #{size}" do
56       need_javascript
57
58       use_token :active
59       new_collection = create_large_collection size, 'collection_file_name_with_prefix_'
60
61       Rails.logger.info "Visiting collection at #{Time.now.to_f}"
62       visit page_with_token('active', "/collections/#{new_collection.uuid}")
63       Rails.logger.info "Done visiting collection at #{Time.now.to_f}"
64
65       assert_selector "input[value=\"#{new_collection.uuid}\"]"
66       assert(page.has_link?('collection_file_name_with_prefix_0'), "Collection page did not include file link")
67
68       # edit description
69       Rails.logger.info "Editing description at #{Time.now.to_f}"
70       within('.arv-description-as-subtitle') do
71         find('.fa-pencil').click
72         find('.editable-input textarea').set('description for this large collection')
73         find('.editable-submit').click
74       end
75       Rails.logger.info "Done editing description at #{Time.now.to_f}"
76
77       assert_text 'description for this large collection'
78     end
79   end
80
81   [
82     [1000000, 10000],
83     [10000000, 10000],
84     [20000000, 10000],
85   ].each do |size1, size2|
86     test "Create one large collection of #{size1} and one small collection of #{size2} and combine them" do
87       use_token :active
88       first_collection = create_large_collection size1, 'collection_file_name_with_prefix_1_'
89       second_collection = create_large_collection size2, 'collection_file_name_with_prefix_2_'
90
91       Rails.logger.info "Visiting collections page at #{Time.now.to_f}"
92       visit page_with_token('active', "/collections")
93       Rails.logger.info "Done visiting collections page at at #{Time.now.to_f}"
94
95       assert_text first_collection.uuid
96       assert_text second_collection.uuid
97
98       within('tr', text: first_collection['uuid']) do
99         find('input[type=checkbox]').click
100       end
101
102       within('tr', text: second_collection['uuid']) do
103         find('input[type=checkbox]').click
104       end
105
106       Rails.logger.info "Clicking on combine collections option at #{Time.now.to_f}"
107       click_button 'Selection...'
108       within('.selection-action-container') do
109         click_link 'Create new collection with selected collections'
110       end
111       Rails.logger.info "Done combining collections at #{Time.now.to_f}"
112
113       assert(page.has_link?('collection_file_name_with_prefix_1_0'), "Collection page did not include file link")
114     end
115   end
116 end