1 require 'integration_helper'
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.
8 # Command to run diagnostics tests:
9 # RAILS_ENV=diagnostics bundle exec rake TEST=test/diagnostics/**/*.rb
11 class DiagnosticsTest < ActionDispatch::IntegrationTest
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]
20 tokens = Rails.configuration.user_tokens
21 visit page_with_token(tokens[token_name], (workbench_url + path))
24 def select_input look_for
25 inputs_needed = page.all('.btn', text: 'Choose')
26 return if (!inputs_needed || !inputs_needed.any?)
30 if look_for.andand.index('/').andand.>0
31 partitions = look_for.partition('/')
32 look_for_uuid = partitions[0]
33 look_for_file = partitions[2]
35 look_for_uuid = look_for
39 assert_triggers_dom_event 'shown.bs.modal' do
40 inputs_needed[0].click
43 within('.modal-dialog') do
45 fill_in('Search', with: look_for_uuid, exact: true)
49 page.all('.selectable').first.click
51 # ajax reload is wiping out input selection after search results; so, select again.
52 page.all('.selectable').first.click
57 within('.collection_files_name', text: look_for_file) do
58 find('.fa-file').click
62 find('button', text: 'OK').click
67 # Looks for the text_to_look_for for up to the max_time provided
68 def wait_until_page_has text_to_look_for, max_time=30
69 max_time = 30 if (!max_time || (max_time.to_s != max_time.to_i.to_s))
71 Timeout.timeout(max_time) do
73 visit_page_with_token 'active', current_path
74 text_found = has_text?(text_to_look_for)