mirror of
https://github.com/Evolix/chexpire.git
synced 2024-04-26 14:00:50 +02:00
System tests for dashboard
This commit is contained in:
parent
d7c0647f40
commit
cbb0b98898
|
@ -1,4 +1,4 @@
|
|||
.table-checks {
|
||||
.checks-table {
|
||||
.action a {
|
||||
color: black;
|
||||
}
|
||||
|
|
|
@ -37,8 +37,9 @@ module ChecksHelper
|
|||
data: {
|
||||
toggle: "tooltip",
|
||||
placement: "bottom",
|
||||
title: check_last_success_title(check)
|
||||
})
|
||||
title: check_last_success_title(check),
|
||||
},
|
||||
)
|
||||
end
|
||||
|
||||
def current_criterias
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<div class="row justify-content-md-end">
|
||||
<div class="row justify-content-md-end checks-filters">
|
||||
|
||||
<div class="col-md-6 mb-3 d-flex justify-content-between justify-content-md-start">
|
||||
<div class="btn-group mr-2">
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<div class="mb-4 table-responsive">
|
||||
<table class="table table-checks">
|
||||
<table class="table checks-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col"></th>
|
||||
|
|
4
test/system/.rubocop.yml
Normal file
4
test/system/.rubocop.yml
Normal file
|
@ -0,0 +1,4 @@
|
|||
inherit_from: ../../.rubocop.yml
|
||||
|
||||
Metrics/ClassLength:
|
||||
Enabled: false
|
|
@ -4,8 +4,6 @@ class ChecksTest < ApplicationSystemTestCase
|
|||
setup do
|
||||
@user = create(:user)
|
||||
login_as(@user)
|
||||
|
||||
@check = create(:check, :with_notifications, user: @user)
|
||||
end
|
||||
|
||||
test "create a check and a notification without kind" do
|
||||
|
@ -33,12 +31,13 @@ class ChecksTest < ApplicationSystemTestCase
|
|||
end
|
||||
|
||||
test "remove a notification" do
|
||||
visit edit_check_path(@check)
|
||||
notification = @check.notifications.first
|
||||
check = create(:check, :with_notifications, domain: "dom-with-notif.net", user: @user)
|
||||
visit edit_check_path(check)
|
||||
notification = check.notifications.first
|
||||
|
||||
selector = "[data-notification-id=\"#{notification.id}\"]"
|
||||
|
||||
assert_difference "Notification.where(check_id: #{@check.id}).count", -1 do
|
||||
assert_difference "Notification.where(check_id: #{check.id}).count", -1 do
|
||||
within selector do
|
||||
find(".btn-danger").click
|
||||
end
|
||||
|
@ -48,7 +47,8 @@ class ChecksTest < ApplicationSystemTestCase
|
|||
end
|
||||
|
||||
test "update a check" do
|
||||
visit edit_check_path(@check)
|
||||
check = create(:check, :with_notifications, domain: "dom-with-notif.net", user: @user)
|
||||
visit edit_check_path(check)
|
||||
|
||||
fill_in "check[comment]", with: "My comment"
|
||||
|
||||
|
@ -57,18 +57,19 @@ class ChecksTest < ApplicationSystemTestCase
|
|||
assert_equal checks_path, page.current_path
|
||||
|
||||
assert page.has_css?(".alert-success")
|
||||
@check.reload
|
||||
assert_equal "My comment", @check.comment
|
||||
check.reload
|
||||
assert_equal "My comment", check.comment
|
||||
end
|
||||
|
||||
test "add a notification" do
|
||||
visit edit_check_path(@check)
|
||||
check = create(:check, :with_notifications, domain: "dom-with-notif.net", user: @user)
|
||||
visit edit_check_path(check)
|
||||
|
||||
recipient = "recipient2@example.org"
|
||||
fill_in("check[notifications_attributes][2][recipient]", with: recipient)
|
||||
fill_in("check[notifications_attributes][2][interval]", with: 55)
|
||||
|
||||
assert_difference "Notification.where(check_id: #{@check.id}).count", +1 do
|
||||
assert_difference "Notification.where(check_id: #{check.id}).count", +1 do
|
||||
click_button "Update Check"
|
||||
|
||||
assert_equal checks_path, page.current_path
|
||||
|
@ -83,6 +84,176 @@ class ChecksTest < ApplicationSystemTestCase
|
|||
assert notification.pending?
|
||||
end
|
||||
|
||||
test "list my checks" do
|
||||
create(:check, :domain, domain: "dom.com", domain_expires_at: Time.new(2018, 7, 5, 12), user: @user) # rubocop:disable Metrics/LineLength
|
||||
create(:check, :ssl, domain: "ssldom.com", user: @user)
|
||||
create(:check, :ssl, domain: "ssldom2.com", user: @user)
|
||||
|
||||
visit checks_path
|
||||
|
||||
within ".checks-table" do
|
||||
assert page.has_content?("SSL", count: 2)
|
||||
assert page.has_content?("Domain", count: 1)
|
||||
end
|
||||
|
||||
within ".check-row:first-of-type" do
|
||||
assert page.has_content?("Domain")
|
||||
assert page.has_content?("dom.com")
|
||||
assert page.has_content?("Thursday, July 5, 2018")
|
||||
end
|
||||
end
|
||||
|
||||
test "list filterable by domain and ssl" do
|
||||
create_list(:check, 2, :domain, domain: "mydom.fr", user: @user)
|
||||
create_list(:check, 1, :ssl, domain: "ssl.com", user: @user)
|
||||
|
||||
visit checks_path
|
||||
|
||||
assert page.has_css?(".check-row", count: 3)
|
||||
|
||||
within ".checks-filters" do
|
||||
click_on "Domain"
|
||||
assert find_link("Domain").matches_css? ".active"
|
||||
assert find_link("SSL").not_matches_css? ".active"
|
||||
end
|
||||
|
||||
within ".checks-table" do
|
||||
assert page.has_css?(".check-row", count: 2)
|
||||
assert page.has_content?("Domain", count: 2)
|
||||
end
|
||||
|
||||
within ".checks-filters" do
|
||||
click_on "SSL"
|
||||
assert find_link("SSL").matches_css? ".active"
|
||||
assert find_link("Domain").not_matches_css? ".active"
|
||||
end
|
||||
|
||||
within ".checks-table" do
|
||||
assert page.has_css?(".check-row", count: 1)
|
||||
assert page.has_content?("SSL", count: 1)
|
||||
assert page.has_content?("ssl.com")
|
||||
end
|
||||
end
|
||||
|
||||
test "list filterable by check in error" do
|
||||
create(:check, user: @user)
|
||||
create(:check, :last_runs_failed, created_at: 1.week.ago, user: @user)
|
||||
|
||||
visit checks_path
|
||||
|
||||
within ".checks-table" do
|
||||
assert page.has_css?(".check-row", count: 2)
|
||||
assert page.has_css?(".in-error", count: 1)
|
||||
end
|
||||
|
||||
within ".checks-filters" do
|
||||
click_on(I18n.t("checks.filters.with_error"))
|
||||
end
|
||||
|
||||
within ".checks-table" do
|
||||
assert page.has_css?(".check-row", count: 1)
|
||||
assert page.has_css?(".in-error", count: 1)
|
||||
end
|
||||
end
|
||||
|
||||
test "list filterable by name string" do
|
||||
create(:check, user: @user)
|
||||
create(:check, domain: "chexpire.org", user: @user)
|
||||
create(:check, domain: "chexpire.net", user: @user)
|
||||
|
||||
visit checks_path
|
||||
|
||||
within ".checks-filters" do
|
||||
fill_in("by_domain", with: "chex")
|
||||
click_button
|
||||
end
|
||||
|
||||
within ".checks-table" do
|
||||
assert page.has_css?(".check-row", count: 2)
|
||||
assert page.has_content?("chexpire.", count: 2)
|
||||
end
|
||||
end
|
||||
|
||||
test "list is paginated" do
|
||||
create(:check, user: @user)
|
||||
|
||||
visit checks_path
|
||||
assert page.has_no_css?("ul.pagination")
|
||||
|
||||
create_list(:check, 50, user: @user)
|
||||
|
||||
visit checks_path
|
||||
assert page.has_css?("ul.pagination")
|
||||
end
|
||||
|
||||
test "list is sortable by name" do
|
||||
visit checks_path
|
||||
|
||||
create(:check, domain: "a.org", user: @user)
|
||||
create(:check, domain: "b.org", user: @user)
|
||||
|
||||
visit checks_path
|
||||
|
||||
within ".checks-table thead th:nth-of-type(2)" do
|
||||
find(".sort-links:first-child").click
|
||||
end
|
||||
|
||||
within ".check-row:first-of-type" do
|
||||
page.has_content? "a.org"
|
||||
end
|
||||
|
||||
within ".checks-table thead th:nth-of-type(2)" do
|
||||
find(".sort-links:last-child").click
|
||||
end
|
||||
|
||||
within ".check-row:first-of-type" do
|
||||
page.has_content? "b.org"
|
||||
end
|
||||
end
|
||||
|
||||
test "list is sorted by expiration date by default" do
|
||||
visit checks_path
|
||||
|
||||
create(:check, domain_expires_at: Time.new(2018, 7, 6, 12), user: @user)
|
||||
create(:check, domain_expires_at: Time.new(2018, 7, 5, 12), user: @user)
|
||||
|
||||
visit checks_path
|
||||
|
||||
within ".check-row:first-of-type" do
|
||||
page.has_content? "Thursday, July 5, 2018"
|
||||
end
|
||||
end
|
||||
|
||||
test "list is sortable by expiration date" do
|
||||
visit checks_path
|
||||
|
||||
create(:check, domain_expires_at: Time.new(2018, 7, 5, 12), user: @user)
|
||||
create(:check, domain_expires_at: Time.new(2018, 7, 6, 12), user: @user)
|
||||
|
||||
visit checks_path
|
||||
|
||||
within ".check-row:first-of-type" do
|
||||
page.has_content? "Thursday, July 5, 2018"
|
||||
end
|
||||
|
||||
# only a desc link because of default sort
|
||||
within ".checks-table thead th:nth-of-type(3)" do
|
||||
find(".sort-links a").click
|
||||
end
|
||||
|
||||
within ".check-row:first-of-type" do
|
||||
page.has_content? "Friday, July 6, 2018"
|
||||
end
|
||||
|
||||
within ".checks-table thead th:nth-of-type(3)" do
|
||||
find(".sort-links a").click
|
||||
end
|
||||
|
||||
within ".check-row:first-of-type" do
|
||||
page.has_content? "Thursday, July 5, 2018"
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
# rubocop:disable Metrics/AbcSize
|
||||
|
|
Loading…
Reference in a new issue