1 # Copyright (C) The Arvados Authors. All rights reserved.
3 # SPDX-License-Identifier: AGPL-3.0
5 require 'integration_helper'
8 # Diagnostics tests are executed when "RAILS_ENV=diagnostics" is used.
9 # When "RAILS_ENV=test" is used, tests in the "diagnostics" directory
10 # will not be executed.
12 # Command to run diagnostics tests:
13 # RAILS_ENV=diagnostics bundle exec rake TEST=test/diagnostics/**/*.rb
15 class DiagnosticsTest < ActionDispatch::IntegrationTest
17 # Prepends workbench URL to the path provided and visits that page
18 # Expects path parameters such as "/collections/<uuid>"
19 def visit_page_with_token token_name, path='/'
20 workbench_url = Rails.configuration.arvados_workbench_url
21 if workbench_url.end_with? '/'
22 workbench_url = workbench_url[0, workbench_url.size-1]
24 tokens = Rails.configuration.user_tokens
25 visit page_with_token(tokens[token_name], (workbench_url + path))
28 def select_input look_for
29 inputs_needed = page.all('.btn', text: 'Choose')
30 return if (!inputs_needed || !inputs_needed.any?)
34 if look_for.andand.index('/').andand.>0
35 partitions = look_for.partition('/')
36 look_for_uuid = partitions[0]
37 look_for_file = partitions[2]
39 look_for_uuid = look_for
43 assert_triggers_dom_event 'shown.bs.modal' do
44 inputs_needed[0].click
47 within('.modal-dialog') do
49 fill_in('Search', with: look_for_uuid, exact: true)
53 page.all('.selectable').first.click
55 # ajax reload is wiping out input selection after search results; so, select again.
56 page.all('.selectable').first.click
61 within('.collection_files_name', text: look_for_file) do
62 find('.fa-file').click
66 find('button', text: 'OK').click
71 # Looks for the text_to_look_for for up to the max_time provided
72 def wait_until_page_has text_to_look_for, max_time=30
73 max_time = 30 if (!max_time || (max_time.to_s != max_time.to_i.to_s))
75 Timeout.timeout(max_time) do
77 visit_page_with_token 'active', current_path
78 text_found = has_text?(text_to_look_for)