diff --git a/apps/dashboard/test/fixtures/sys_with_gateway_apps/bc_paraview/completed.html.erb b/apps/dashboard/test/fixtures/sys_with_gateway_apps/bc_paraview/completed.html.erb new file mode 100644 index 0000000000..dd53be731b --- /dev/null +++ b/apps/dashboard/test/fixtures/sys_with_gateway_apps/bc_paraview/completed.html.erb @@ -0,0 +1 @@ +
This is a test message for a completed view.
diff --git a/apps/dashboard/test/fixtures/sys_with_gateway_apps/bc_paraview/info.html.erb b/apps/dashboard/test/fixtures/sys_with_gateway_apps/bc_paraview/info.html.erb new file mode 100644 index 0000000000..6ae8e90dd5 --- /dev/null +++ b/apps/dashboard/test/fixtures/sys_with_gateway_apps/bc_paraview/info.html.erb @@ -0,0 +1 @@ +
This is a test message for an info view.
\ No newline at end of file diff --git a/apps/dashboard/test/system/batch_connect_sessions_test.rb b/apps/dashboard/test/system/batch_connect_sessions_test.rb index f61a6b0142..e14ff3cf19 100644 --- a/apps/dashboard/test/system/batch_connect_sessions_test.rb +++ b/apps/dashboard/test/system/batch_connect_sessions_test.rb @@ -11,14 +11,14 @@ def setup stub_sys_apps end - def test_data + def test_data(token: 'sys/bc_paraview', title: 'Paraview') { 'id': test_bc_id, 'cluster_id': 'owens', "job_id": test_job_id, "created_at": 1_701_184_869, - "token": 'sys/bc_paraview', - "title": 'Code Server', + "token": token, + "title": title, "script_type": 'basic', "cache_completed": false } @@ -32,9 +32,9 @@ def test_bc_id 'abc-123' end - def create_test_file(dir) + def create_test_file(dir, token: 'sys/bc_paraview', title: 'Paraview') BatchConnect::Session.stubs(:db_root).returns(Pathname.new(dir)) - File.write("#{dir}/#{test_bc_id}", test_data.to_json) + File.write("#{dir}/#{test_bc_id}", test_data(token: token, title: title).to_json) end def stub_scheduler(state) @@ -53,12 +53,74 @@ def stub_scheduler(state) create_test_file(dir) stub_scheduler(:queued) visit(batch_connect_sessions_path) - + + card = find("#id_#{test_bc_id}") + assert_not_nil(card) + + header_text = card.find('.h5').text + assert_equal("Paraview (#{test_job_id})\nQueued", header_text) + end + end + + test 'completed session' do + Dir.mktmpdir do |dir| + create_test_file(dir, token: 'sys/bc_jupyter', title: 'Jupyter') + stub_scheduler(:completed) + visit(batch_connect_sessions_path) + + card = find("#id_#{test_bc_id}") + assert_not_nil(card) + + header_text = card.find('.h5').text + assert_equal("Jupyter (#{test_job_id})\nCompleted | |", header_text) + end + end + + test 'completed session with completed view' do + Dir.mktmpdir do |dir| + create_test_file(dir) + stub_scheduler(:completed) + visit(batch_connect_sessions_path) + card = find("#id_#{test_bc_id}") assert_not_nil(card) header_text = card.find('.h5').text - assert_equal("Code Server (#{test_job_id})\nQueued", header_text) + assert_equal("Paraview (#{test_job_id})\nCompleted | |", header_text) + + completed_text = card.find('#completed_test_div').text + assert_equal('This is a test message for a completed view.', completed_text) + end + end + + test 'running session' do + Dir.mktmpdir do |dir| + create_test_file(dir, token: 'sys/bc_jupyter', title: 'Jupyter') + stub_scheduler(:running) + visit(batch_connect_sessions_path) + + card = find("#id_#{test_bc_id}") + assert_not_nil(card) + + header_text = card.find('.h5').text + assert_equal("Jupyter (#{test_job_id})\n0 nodes | 0 cores | Starting", header_text) + end + end + + test 'running session with info view' do + Dir.mktmpdir do |dir| + create_test_file(dir, token: 'sys/bc_paraview', title: 'Paraview') + stub_scheduler(:running) + visit(batch_connect_sessions_path) + + card = find("#id_#{test_bc_id}") + assert_not_nil(card) + + header_text = card.find('.h5').text + assert_equal("Paraview (#{test_job_id})\n0 nodes | 0 cores | Starting", header_text) + + info_text = card.find("#info_test_div").text + assert_equal('This is a test message for an info view.', info_text) end end end