diff --git a/apps/dashboard/app/models/batch_connect/session.rb b/apps/dashboard/app/models/batch_connect/session.rb index 0d34a71996..f3f21640d2 100644 --- a/apps/dashboard/app/models/batch_connect/session.rb +++ b/apps/dashboard/app/models/batch_connect/session.rb @@ -76,7 +76,7 @@ def render_info_view # Return parsed markdown from completed.{md, html}.erb # @return [String, nil] return HTML if no error while parsing, else return nil def render_completed_view - @render_completed_view ||= OodAppkit.markdown.render(ERB.new(self.app.session_completed_view, nil, "-").result(binding)).html_safe if self.app.session_completed_view + @render_completed_view ||= OodAppkit.markdown.render(ERB.new(self.app.session_completed_view, trim_mode: '-').result(binding)).html_safe if self.app.session_completed_view rescue => e @render_completed_view_error_message = "Error when rendering completed view: #{e.class} - #{e.message}" Rails.logger.error(@render_completed_view_error_message) diff --git a/apps/dashboard/app/views/batch_connect/sessions/card/_card_body.html.erb b/apps/dashboard/app/views/batch_connect/sessions/card/_card_body.html.erb index 94ef42aad5..6f8ceb90e2 100644 --- a/apps/dashboard/app/views/batch_connect/sessions/card/_card_body.html.erb +++ b/apps/dashboard/app/views/batch_connect/sessions/card/_card_body.html.erb @@ -7,6 +7,8 @@ <%= render_card_partial('id', session) %> <%= render_card_partial('support_ticket', session) if Configuration.support_ticket_enabled? %> <%= render_card_partial('display_choices', session) %> + <%= render_card_partial('custom_info_view', session) if session.app.session_info_view %> + <%= render_card_partial('completed_view', session) if session.app.session_completed_view && session.completed? %> <%= render_connection(session) %> 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