Skip to content

Commit

Permalink
Add two very basic system tests #367 (#373)
Browse files Browse the repository at this point in the history
Co-authored-by: Robert Waffen <rw@betadots.de>
  • Loading branch information
oneiros and rwaffen committed May 7, 2024
1 parent 0c194d9 commit 08f5924
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 1 deletion.
13 changes: 12 additions & 1 deletion test/application_system_test_case.rb
Original file line number Diff line number Diff line change
@@ -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
27 changes: 27 additions & 0 deletions test/system/access_nodes_keys_test.rb
Original file line number Diff line number Diff line change
@@ -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
29 changes: 29 additions & 0 deletions test/system/search_key_test.rb
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 08f5924

Please sign in to comment.