5261: Redirect to destination project's Collections tab when copying/moving collections.
[arvados.git] / apps / workbench / test / diagnostics_test_helper.rb
1 require 'integration_helper'
2 require 'yaml'
3
4 # Diagnostics tests are executed when "RAILS_ENV=diagnostics" is used.
5 # When "RAILS_ENV=test" is used, tests in the "diagnostics" directory
6 # will not be executed.
7
8 # Command to run diagnostics tests:
9 #   RAILS_ENV=diagnostics bundle exec rake TEST=test/diagnostics/**/*.rb
10
11 class DiagnosticsTest < ActionDispatch::IntegrationTest
12
13   # Prepends workbench URL to the path provided and visits that page
14   # Expects path parameters such as "/collections/<uuid>"
15   def visit_page_with_token token_name, path='/'
16     workbench_url = Rails.configuration.arvados_workbench_url
17     if workbench_url.end_with? '/'
18       workbench_url = workbench_url[0, workbench_url.size-1]
19     end
20     tokens = Rails.configuration.user_tokens
21     visit page_with_token(tokens[token_name], (workbench_url + path))
22   end
23
24   # Looks for the text_to_look_for for up to the max_time provided
25   def wait_until_page_has text_to_look_for, max_time=30
26     max_time = 30 if (!max_time || (max_time.to_s != max_time.to_i.to_s))
27     Timeout.timeout(max_time) do
28       loop until page.has_text?(text_to_look_for)
29     end
30   end
31
32 end