From 98c17528a655148bf4c01629ea36cf249441c213 Mon Sep 17 00:00:00 2001 From: Amir Fefer Date: Thu, 16 Dec 2021 17:48:14 +0200 Subject: [PATCH] Fixes #34166 - opt in the new host page by default --- app/registries/foreman/settings/general.rb | 2 +- test/controllers/hosts_controller_test.rb | 10 +++++----- test/integration/host_js_test.rb | 21 +++++++++++++-------- test/integration/host_test.rb | 9 --------- 4 files changed, 19 insertions(+), 23 deletions(-) diff --git a/app/registries/foreman/settings/general.rb b/app/registries/foreman/settings/general.rb index 7cd506c8414..f0838e77647 100644 --- a/app/registries/foreman/settings/general.rb +++ b/app/registries/foreman/settings/general.rb @@ -97,7 +97,7 @@ setting('host_details_ui', type: :boolean, description: N_("Foreman will load the new UI for host details"), - default: false, + default: true, full_name: N_('New host details UI')) end end diff --git a/test/controllers/hosts_controller_test.rb b/test/controllers/hosts_controller_test.rb index 8613c650edc..b4f42238ae6 100644 --- a/test/controllers/hosts_controller_test.rb +++ b/test/controllers/hosts_controller_test.rb @@ -29,7 +29,7 @@ def host_attributes(host) test 'create_valid' do Host.any_instance.stubs(:valid?).returns(true) post :create, params: { :host => {:name => "test"} }, session: set_session_user - assert_redirected_to host_url(assigns('host')) + assert_redirected_to host_details_page_url(assigns('host')) end test "should get index" do @@ -101,7 +101,7 @@ def host_attributes(host) }, }, session: set_session_user end - assert_redirected_to host_url(assigns['host']) + assert_redirected_to host_details_page_url(assigns['host']) end context "with libvirt" do @@ -186,7 +186,7 @@ def teardown assert new_host.puppet_proxy.present? assert_equal hostgroup.puppet_proxy, new_host.puppet_proxy end - assert_redirected_to host_url(assigns['host']) + assert_redirected_to host_details_page_url(assigns['host']) end test "should get edit" do @@ -210,7 +210,7 @@ def test_update_invalid def test_update_valid Host.any_instance.stubs(:valid?).returns(true) put :update, params: { :id => Host.first.name, :host => {:name => "Updated_#{Host.first.name}"} }, session: set_session_user - assert_redirected_to host_url(assigns(:host)) + assert_redirected_to host_details_page_url(assigns(:host)) end test "should destroy host" do @@ -1432,7 +1432,7 @@ class Host::Test < Host::Base; end host: { compute_attributes: { scsi_controllers: { 'scsiControllers' => scsi_controllers, 'volumes' => [volume_params] }.to_json } }, }, session: set_session_user - assert_redirected_to host_path(@vmware_host.to_param) + assert_redirected_to host_details_page_path(@vmware_host.to_param) end end end diff --git a/test/integration/host_js_test.rb b/test/integration/host_js_test.rb index 9b2bc223a8c..5e40bbf4918 100644 --- a/test/integration/host_js_test.rb +++ b/test/integration/host_js_test.rb @@ -35,9 +35,7 @@ class HostJSTest < IntegrationTestWithJavascript end test "has proper title and links" do - visit hosts_path - click_link @host.fqdn - assert_breadcrumb_text(@host.fqdn) + visit host_path @host assert page.has_link?("Properties", :href => "#properties") assert page.has_link?("Metrics", :href => "#metrics") assert page.has_link?("Templates", :href => "#template") @@ -76,6 +74,12 @@ class HostJSTest < IntegrationTestWithJavascript Setting[:host_details_ui] = false end + test "assert breadcrumbs" do + visit hosts_path + click_link @host.fqdn + find('.pf-c-breadcrumb__item', :text => @host.fqdn) + end + test "new show page" do visit hosts_path click_link @host.fqdn @@ -95,7 +99,7 @@ class HostJSTest < IntegrationTestWithJavascript assert_equal '', page.find('#host_name').value end - test "delete host" do + test "delete host redirects to hosts index" do host = FactoryBot.create(:host) visit host_details_page_path(host) find('#hostdetails-kebab').click @@ -302,8 +306,8 @@ class HostJSTest < IntegrationTestWithJavascript select2 domains(:mydomain).name, :from => 'host_interfaces_attributes_0_domain_id' fill_in 'host_interfaces_attributes_0_ip', :with => '1.1.1.1' close_interfaces_modal - click_on_submit - find('#host-show') # wait for host details page + click_button('Submit') + find('h5', :text => /myhost1*/) host = Host::Managed.search_for('name ~ "myhost1"').first assert_equal compute_resource.name, host.compute_resource.name @@ -341,7 +345,8 @@ class HostJSTest < IntegrationTestWithJavascript close_interfaces_modal - click_on_submit + click_button('Submit') + find('h5', :text => /myhost1*/) host = Host::Managed.search_for('name ~ "myhost1"').first assert_equal hg.compute_resource.name, host.compute_resource.name @@ -471,7 +476,7 @@ class HostJSTest < IntegrationTestWithJavascript assert page.has_selector?(id) page.find(id).click assert page.has_no_selector?(id) - click_on_submit + click_button('Submit') visit edit_host_path(host) switch_form_tab('Parameters') diff --git a/test/integration/host_test.rb b/test/integration/host_test.rb index 52e7db6393c..110581416c1 100644 --- a/test/integration/host_test.rb +++ b/test/integration/host_test.rb @@ -24,15 +24,6 @@ class HostIntegrationTest < ActionDispatch::IntegrationTest end end - test "destroy redirects to hosts index" do - disable_orchestration # Avoid DNS errors - visit hosts_path - click_link @host.fqdn - assert page.has_link?("Delete", :href => "/hosts/#{@host.fqdn}") - first(:link, "Delete").click - assert_current_path hosts_path - end - describe 'edit page' do test 'displays warning when vm not found by uuid' do ComputeResource.any_instance.stubs(:find_vm_by_uuid).raises(ActiveRecord::RecordNotFound)