Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lint a random file #3751

Merged
merged 1 commit into from
Aug 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# frozen_string_literal: true

require 'test_helper'

class BatchConnectConcernTest < ActiveSupport::TestCase

url_helpers = Rails.application.routes.url_helpers

class TestClass
Expand All @@ -12,19 +13,19 @@ class TestClass

def setup
# Defaults
SysRouter.stubs(:base_path).returns(Rails.root.join("test/fixtures/sys_with_gateway_apps"))
OodAppkit.stubs(:clusters).returns(OodCore::Clusters.load_file("test/fixtures/config/clusters.d"))
SysRouter.stubs(:base_path).returns(Rails.root.join('test/fixtures/sys_with_gateway_apps'))
OodAppkit.stubs(:clusters).returns(OodCore::Clusters.load_file('test/fixtures/config/clusters.d'))
@target = TestClass.new
@target.user_configuration = stub(:interactive_apps_menu => [])
@target.nav_bar = []
end

test "bc_custom_apps_group should return nil when no interactive_apps_menu and nav_bar defined" do
test 'bc_custom_apps_group should return nil when no interactive_apps_menu and nav_bar defined' do
assert_nil @target.bc_custom_apps_group
end

test "bc_custom_apps_group should return a navigation menu based on interactive_apps_menu property when defined" do
@target.user_configuration = stub(:interactive_apps_menu => {title: "Custom Apps Menu", links: []})
test 'bc_custom_apps_group should return a navigation menu based on interactive_apps_menu property when defined' do
@target.user_configuration = stub(:interactive_apps_menu => { title: 'Custom Apps Menu', links: [] })

result = @target.bc_custom_apps_group

Expand All @@ -34,30 +35,33 @@ def setup
assert_equal false, result.sort
end

test "bc_custom_apps_group should return a navigation menu based on @nav_bar when interactive_apps_menu is not defined and @nav_bar is" do
@target.nav_bar = NavBar.items([{title: "Primary Menu", apps: "sys/bc_jupyter"}, {title: "Secondary Menu", apps: "sys/bc_paraview"}])
test 'bc_custom_apps_group should return a navigation menu based on @nav_bar when interactive_apps_menu is not defined and @nav_bar is' do
@target.nav_bar = NavBar.items([{ title: 'Primary Menu', apps: 'sys/bc_jupyter' },
{ title: 'Secondary Menu', apps: 'sys/bc_paraview' }])
@target.expects(:t).with('dashboard.batch_connect_apps_menu_title').returns('menu title from translation')

result = @target.bc_custom_apps_group

assert_equal 'menu title from translation', result.title
assert_equal 2, result.apps.size
assert_equal [url_helpers.new_batch_connect_session_context_path('sys/bc_jupyter'), url_helpers.new_batch_connect_session_context_path('sys/bc_paraview')], result.apps.map(&:links).flatten.map(&:url)
assert_equal [url_helpers.new_batch_connect_session_context_path('sys/bc_jupyter'), url_helpers.new_batch_connect_session_context_path('sys/bc_paraview')],
result.apps.map(&:links).flatten.map(&:url)
# Sorting should be enabled. Apps come from different menus in the navigation
assert_equal true, result.sort
end

test "bc_custom_apps_group should dedupe links when app links are based on configured @nav_bar applications" do
@target.nav_bar = NavBar.items([{title: "Primary Menu", apps: "sys/bc_jupyter"}, {title: "Secondary Menu", apps: "sys/bc_jupyter"}])
test 'bc_custom_apps_group should dedupe links when app links are based on configured @nav_bar applications' do
@target.nav_bar = NavBar.items([{ title: 'Primary Menu', apps: 'sys/bc_jupyter' },
{ title: 'Secondary Menu', apps: 'sys/bc_jupyter' }])
@target.expects(:t).with('dashboard.batch_connect_apps_menu_title').returns('menu title from translation')

result = @target.bc_custom_apps_group

assert_equal 'menu title from translation', result.title
assert_equal 1, result.apps.size
assert_equal [url_helpers.new_batch_connect_session_context_path("sys/bc_jupyter")], result.apps.map(&:links).flatten.map(&:url)
assert_equal [url_helpers.new_batch_connect_session_context_path('sys/bc_jupyter')],
result.apps.map(&:links).flatten.map(&:url)
# Sorting should be enabled. Apps come from different menus in the navigation
assert_equal true, result.sort
end

end
end
Loading