Skip to content

Commit

Permalink
Fix jws tests
Browse files Browse the repository at this point in the history
  • Loading branch information
somathias committed Jan 22, 2024
1 parent 97496a2 commit 464ef9b
Showing 1 changed file with 34 additions and 28 deletions.
62 changes: 34 additions & 28 deletions test/functional/jws_online_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,39 +8,45 @@ class JwsOnlineTest < ActionController::TestCase
include JwsOnlineTestHelper

test 'simulate button visibility' do
model = FactoryBot.create(:teusink_model, policy: FactoryBot.create(:public_policy))
get :show, params: { id: model }
assert_response :success
assert_select '#buttons a[href=?]', simulate_model_path(model, version: 1)

model = FactoryBot.create(:non_sbml_xml_model, policy: FactoryBot.create(:public_policy))
get :show, params: { id: model }
assert_response :success
assert_select '#buttons a[href=?]', simulate_model_path(model, version: 1), count: 0

model = FactoryBot.create(:teusink_model, policy: FactoryBot.create(:publicly_viewable_policy))
get :show, params: { id: model }
assert_response :success
assert_select '#buttons a[href=?]', simulate_model_path(model, version: 1), count: 0
with_config_value(:jws_enabled, true) do
model = FactoryBot.create(:teusink_model, policy: FactoryBot.create(:public_policy))
get :show, params: { id: model }
assert_response :success
assert_select '#buttons a[href=?]', simulate_model_path(model, version: 1)

model = FactoryBot.create(:non_sbml_xml_model, policy: FactoryBot.create(:public_policy))
get :show, params: { id: model }
assert_response :success
assert_select '#buttons a[href=?]', simulate_model_path(model, version: 1), count: 0

model = FactoryBot.create(:teusink_model, policy: FactoryBot.create(:publicly_viewable_policy))
get :show, params: { id: model }
assert_response :success
assert_select '#buttons a[href=?]', simulate_model_path(model, version: 1), count: 0
end
end

test 'simulate' do
model = FactoryBot.create(:teusink_model, policy: FactoryBot.create(:public_policy))
get :simulate, params: { id: model.id, version: model.version, constraint_based:'1' }
assert_response :success
assert assigns(:simulate_url)

url = assigns(:simulate_url)
refute_nil url
assert url =~ URI.regexp, "simulate url (#{url}) should be a valid url"
assert_select 'iframe[src=?]', url
with_config_value(:jws_enabled, true) do
model = FactoryBot.create(:teusink_model, policy: FactoryBot.create(:public_policy))
get :simulate, params: { id: model.id, version: model.version, constraint_based:'1' }
assert_response :success
assert assigns(:simulate_url)

url = assigns(:simulate_url)
refute_nil url
assert url =~ URI.regexp, "simulate url (#{url}) should be a valid url"
assert_select 'iframe[src=?]', url
end
end

test 'simulate no constraint defined' do
model = FactoryBot.create(:teusink_model, policy: FactoryBot.create(:public_policy))
get :simulate, params: { id: model.id, version: model.version }
assert_response :success
refute assigns(:simulate_url)
assert_select 'input[@type=checkbox]#constraint_based',count: 1
with_config_value(:jws_enabled, true) do
model = FactoryBot.create(:teusink_model, policy: FactoryBot.create(:public_policy))
get :simulate, params: { id: model.id, version: model.version }
assert_response :success
refute assigns(:simulate_url)
assert_select 'input[@type=checkbox]#constraint_based',count: 1
end
end
end

0 comments on commit 464ef9b

Please sign in to comment.