From 71dc0529e31b1b984fe858f6bea0a6e025af41b8 Mon Sep 17 00:00:00 2001 From: Nick Muerdter Date: Sun, 5 Feb 2017 14:45:48 -0700 Subject: [PATCH 1/2] Fix potential race condition in reordering tests loading. --- test/admin_ui/test_apis_reordering.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/test/admin_ui/test_apis_reordering.rb b/test/admin_ui/test_apis_reordering.rb index 2f8680a9f..1f76db6aa 100644 --- a/test/admin_ui/test_apis_reordering.rb +++ b/test/admin_ui/test_apis_reordering.rb @@ -19,6 +19,8 @@ def setup def test_toggle_drag_handles admin_login visit "/admin/#/apis" + refute_selector(".busy-blocker") + assert_text("API A") refute_selector("tbody td.reorder-handle") click_button "Reorder" @@ -30,6 +32,8 @@ def test_toggle_drag_handles def test_remove_filters_while_reordering admin_login visit "/admin/#/apis" + refute_selector(".busy-blocker") + assert_text("API A") assert_selector("tbody tr", :count => 4) find(".dataTables_filter input").set("testing-fi") @@ -41,6 +45,8 @@ def test_remove_filters_while_reordering def test_forces_sorting_while_reordering admin_login visit "/admin/#/apis" + refute_selector(".busy-blocker") + assert_text("API A") assert_selector("tbody tr:first-child td:first-child", :text => "API A") click_button "Reorder" @@ -50,6 +56,8 @@ def test_forces_sorting_while_reordering def test_exits_reorder_mode_on_filter admin_login visit "/admin/#/apis" + refute_selector(".busy-blocker") + assert_text("API A") click_button "Reorder" assert_selector("tbody td.reorder-handle", :count => 4) @@ -60,6 +68,8 @@ def test_exits_reorder_mode_on_filter def test_exit_reorder_mode_on_sort admin_login visit "/admin/#/apis" + refute_selector(".busy-blocker") + assert_text("API A") click_button "Reorder" assert_selector("tbody td.reorder-handle", :count => 4) @@ -70,6 +80,8 @@ def test_exit_reorder_mode_on_sort def test_reordering_on_drag admin_login visit "/admin/#/apis" + refute_selector(".busy-blocker") + assert_text("API A") names = Api.order_by(:sort_order.asc).all.map { |api| api.name } assert_equal(["API B", "API C", "API A", "API testing-filter"], names) From a83fd74052151e9ba1e397081b675d0c1c368cad Mon Sep 17 00:00:00 2001 From: Nick Muerdter Date: Sun, 5 Feb 2017 15:07:19 -0700 Subject: [PATCH 2/2] Fix some test ordering issues with new login setup. Ensure an admin account exists before all the tests hitting /admin/login, so the redirect to the first-time creation page doesn't happen. --- test/admin_ui/test_elasticsearch_proxy.rb | 2 ++ test/proxy/test_security_headers.rb | 2 ++ 2 files changed, 4 insertions(+) diff --git a/test/admin_ui/test_elasticsearch_proxy.rb b/test/admin_ui/test_elasticsearch_proxy.rb index 1ee50aafa..a5dc2c54e 100644 --- a/test/admin_ui/test_elasticsearch_proxy.rb +++ b/test/admin_ui/test_elasticsearch_proxy.rb @@ -11,6 +11,8 @@ def setup end def test_redirect_to_login_for_unauthenticated_requests + FactoryGirl.create(:admin) + visit "/admin/elasticsearch" assert_text("You need to sign in") refute_text('"lucene_version"') diff --git a/test/proxy/test_security_headers.rb b/test/proxy/test_security_headers.rb index 13768f965..32895a37d 100644 --- a/test/proxy/test_security_headers.rb +++ b/test/proxy/test_security_headers.rb @@ -18,6 +18,7 @@ def test_adds_security_headers_to_static_site end def test_adds_security_headers_to_web_app + FactoryGirl.create(:admin) response = Typhoeus.get("https://127.0.0.1:9081/admin/login", keyless_http_options) assert_response_code(200, response) assert_equal("1; mode=block", response.headers["X-XSS-Protection"]) @@ -26,6 +27,7 @@ def test_adds_security_headers_to_web_app end def test_adds_security_headers_to_admin_ui + FactoryGirl.create(:admin) response = Typhoeus.get("https://127.0.0.1:9081/admin/login", keyless_http_options) assert_response_code(200, response) assert_equal("1; mode=block", response.headers["X-XSS-Protection"])