Skip to content

Commit be795b7

Browse files
committed
Consolidate fail / error states
1 parent a496e17 commit be795b7

8 files changed

Lines changed: 12 additions & 13 deletions

File tree

app/assets/stylesheets/upright/application.css

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -594,8 +594,7 @@
594594
font-weight: 500;
595595
}
596596

597-
.status-fail,
598-
.status-error {
597+
.status-fail {
599598
color: var(--color-negative);
600599
font-weight: 600;
601600
}

app/models/concerns/upright/probeable.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,10 @@ def failsafe_check
7676
end
7777

7878
def result_description(result, error = nil)
79-
if error
80-
:error
79+
if error || !result
80+
:fail
8181
else
82-
result ? :ok : :fail
82+
:ok
8383
end
8484
end
8585

app/models/upright/probe_result.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class Upright::ProbeResult < Upright::ApplicationRecord
88
scope :by_name, ->(name) { where(probe_name: name) if name.present? }
99
scope :stale, -> { where(created_at: ...24.hours.ago) }
1010

11-
enum :status, [ :ok, :fail, :error ]
11+
enum :status, [ :ok, :fail ]
1212

1313
has_many_attached :artifacts
1414

test/controllers/probe_results_controller_test.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class ProbeResultsControllerTest < ActionDispatch::IntegrationTest
1414
test "filters by probe type when signed in" do
1515
get upright.site_root_path(probe_type: "playwright")
1616
assert_response :success
17-
assert_select "p", text: /for playwright probes/
17+
assert_select "p", text: /for Playwright probes/
1818
assert_select "td", text: /#{upright_probe_results(:playwright_probe_result).probe_name}/
1919
assert_select "td", text: /#{upright_probe_results(:http_probe_result).probe_name}/, count: 0
2020
end
@@ -60,7 +60,7 @@ class ProbeResultsControllerTest < ActionDispatch::IntegrationTest
6060
chart_data = JSON.parse(css_select("[data-probe-results-chart-results-value]").first["data-probe-results-chart-results-value"])
6161

6262
assert chart_data.all? { |r| r["status"] == "fail" }
63-
assert_equal 1, chart_data.length
63+
assert_equal 2, chart_data.length
6464
end
6565

6666
test "paginates results when there are many" do

test/fixtures/upright_probe_results.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,6 @@ http_probe_result_error:
4646
probe_name: HTTP Probe
4747
probe_target: https://example.com
4848
duration: 1.0
49-
status: "error"
49+
status: "fail"
5050
created_at: <%= Time.current %>
5151
updated_at: <%= Time.current %>

test/models/upright/probe_result_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class Upright::ProbeResultTest < ActiveSupport::TestCase
2525

2626
result = Upright::ProbeResult.create!(
2727
probe_name: "test", probe_type: "http", probe_target: "https://example.com",
28-
status: :error, duration: 1.0, error: exception
28+
status: :fail, duration: 1.0, error: exception
2929
)
3030

3131
expected = <<~REPORT.chomp

test/models/upright/probes/http_probe_test.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ class Upright::Probes::HTTPProbeTest < ActiveSupport::TestCase
124124
assert_equal "https://example.com/", result.probe_target
125125
end
126126

127-
test "check_and_record creates error result with exception artifact when check raises" do
127+
test "check_and_record creates fail result with exception artifact when check raises" do
128128
stub_request(:get, "https://example.com/").to_return(status: 200)
129129
set_test_site
130130
probe = Upright::Probes::HTTPProbe.new(name: "test", url: "https://example.com/")
@@ -135,7 +135,7 @@ class Upright::Probes::HTTPProbeTest < ActiveSupport::TestCase
135135
probe.check_and_record
136136

137137
result = Upright::ProbeResult.last
138-
assert_equal "error", result.status
138+
assert_equal "fail", result.status
139139
assert_match(/RuntimeError: connection refused/, result.exception_report)
140140
end
141141

test/models/upright/probes/playwright_probe_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ def check
8787
probe.check_and_record
8888

8989
probe_result = Upright::ProbeResult.last
90-
assert_equal "error", probe_result.status
90+
assert_equal "fail", probe_result.status
9191
assert_equal "playwright", probe_result.probe_type
9292
assert_equal "failing_probe", probe_result.probe_name
9393
assert probe_result.artifacts.attached?, "Expected artifacts to be attached"

0 commit comments

Comments
 (0)