Skip to content

Commit

Permalink
Removed edit session button in Session card for preset applications (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
abujeda authored Mar 6, 2024
1 parent 6d413e4 commit dcc7943
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,11 @@
<span class="card-text"> | </span>
<%- end -%>
<%= status(session) %>
<%- if session.completed? -%>
<%- if session.completed? && !session.app.preset? -%>
<span class="card-text"> | </span>
<%= edit(session) %>
<%- end -%>
<%- if session.completed? -%>
<span class="card-text"> | </span>
<%= relaunch(session) %>
<%- end -%>
Expand Down
29 changes: 25 additions & 4 deletions apps/dashboard/test/integration/sessions_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -97,18 +97,39 @@ def setup
end
end

test 'should render session panel with relaunch button' do
test 'should render session panel with edit and relaunch button for completed sessions' do
value = '{"id":"1234","job_id":"1","created_at":1669139262,"token":"sys/token","title":"session title","cache_completed":true}'
session = BatchConnect::Session.new.from_json(value)
session.stubs(:status).returns(OodCore::Job::Status.new(state: :completed))
session.stubs(:app).returns(stub(valid?: true, token: 'sys/token', attributes: [], session_info_view: nil, session_completed_view: nil, ssh_allow?: true))
session.stubs(:app).returns(stub(valid?: true, preset?: false, token: 'sys/token', attributes: [], session_info_view: nil, session_completed_view: nil, ssh_allow?: true))
BatchConnect::Session.stubs(:all).returns([session])

get batch_connect_sessions_path
assert_response :success

assert_select 'div#id_1234 div.card-heading div.float-right form.relaunch' do |form|
assert_equal batch_connect_session_contexts_path(token: 'sys/token'), form.first['action']
assert_select 'div#id_1234 div.card-heading div.float-right form' do |forms|
assert_equal 2, forms.size
assert_equal true, forms[0]['class'].include?('edit-session')
assert_equal new_batch_connect_session_context_path(token: 'sys/token'), forms[0]['action']

assert_equal true, forms[1]['class'].include?('relaunch')
assert_equal batch_connect_session_contexts_path(token: 'sys/token'), forms[1]['action']
end
end

test 'should not render edit button for preset applications sessions' do
value = '{"id":"1234","job_id":"1","created_at":1669139262,"token":"sys/token","title":"session title","cache_completed":true}'
session = BatchConnect::Session.new.from_json(value)
session.stubs(:status).returns(OodCore::Job::Status.new(state: :completed))
session.stubs(:app).returns(stub(valid?: true, preset?: true, token: 'sys/token', attributes: [], session_info_view: nil, session_completed_view: nil, ssh_allow?: true))
BatchConnect::Session.stubs(:all).returns([session])

get batch_connect_sessions_path
assert_response :success

assert_select 'div#id_1234 div.card-heading div.float-right form' do |forms|
assert_equal 1, forms.size
assert_equal true, forms.first['class'].include?('relaunch')
end
end
end

0 comments on commit dcc7943

Please sign in to comment.