From 08f592437ef2b9403594af766d3fdeef4c7cff7e Mon Sep 17 00:00:00 2001 From: David Roetzel Date: Tue, 7 May 2024 10:37:54 +0200 Subject: [PATCH] Add two very basic system tests #367 (#373) Co-authored-by: Robert Waffen --- test/application_system_test_case.rb | 13 +++++++++++- test/system/access_nodes_keys_test.rb | 27 +++++++++++++++++++++++++ test/system/search_key_test.rb | 29 +++++++++++++++++++++++++++ 3 files changed, 68 insertions(+), 1 deletion(-) create mode 100644 test/system/access_nodes_keys_test.rb create mode 100644 test/system/search_key_test.rb diff --git a/test/application_system_test_case.rb b/test/application_system_test_case.rb index d19212ab..dd5f1749 100644 --- a/test/application_system_test_case.rb +++ b/test/application_system_test_case.rb @@ -1,5 +1,16 @@ require "test_helper" class ApplicationSystemTestCase < ActionDispatch::SystemTestCase - driven_by :selenium, using: :chrome, screen_size: [1400, 1400] + driven_by :selenium, using: :headless_chrome, screen_size: [1400, 1400] + + private + + def slim_select(value, from:) + select = find("select[name=\"#{from}\"]", visible: false) + slim_select_main = select.sibling("div[class=ss-main]") + slim_select_main.click + option = find("div[class=ss-option]", text: value) + option.click + page.has_css?("div[class=ss-single]", text: value) + end end diff --git a/test/system/access_nodes_keys_test.rb b/test/system/access_nodes_keys_test.rb new file mode 100644 index 00000000..2d508e6f --- /dev/null +++ b/test/system/access_nodes_keys_test.rb @@ -0,0 +1,27 @@ +require "application_system_test_case" + +class AccessNodesKeysTest < ApplicationSystemTestCase + setup do + Rails.configuration.hdm[:authentication_disabled] = true + end + + teardown do + Rails.configuration.hdm[:authentication_disabled] = false + end + + test "accessing a key of a node" do + visit root_url + + click_on "Show Environments" + + slim_select "development", from: "environment" + + slim_select "testhost (development)", from: "node" + + click_on "hdm::integer" + + click_on "common.yaml" + + assert has_css?("textarea[name=value]", text: "1") + end +end diff --git a/test/system/search_key_test.rb b/test/system/search_key_test.rb new file mode 100644 index 00000000..6b1ba303 --- /dev/null +++ b/test/system/search_key_test.rb @@ -0,0 +1,29 @@ +require "application_system_test_case" + +class SearchKeyTest < ApplicationSystemTestCase + setup do + Rails.configuration.hdm[:authentication_disabled] = true + end + + teardown do + Rails.configuration.hdm[:authentication_disabled] = false + end + + test "searching for a key" do + visit root_url + + click_on "Show Environments" + + slim_select "development", from: "environment" + + fill_in "key", with: "hdm::integer\n" + + assert has_css?("h2", text: "Search Results") + + click_on "Eyaml hierarchy" + + click_on Rails.root.join("test/fixtures/files/puppet/environments/development/data/common.yaml").to_s + + assert has_css?(".accordion-body pre", text: "1") + end +end