From cb1ea5ea4f163d87053285d3fb7999b12a3558b9 Mon Sep 17 00:00:00 2001 From: Christian Cleberg Date: Sun, 12 Apr 2026 00:15:13 -0500 Subject: harden system status and app reliability --- HutchTests/SystemStatusServiceTests.swift | 63 +++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) (limited to 'HutchTests/SystemStatusServiceTests.swift') diff --git a/HutchTests/SystemStatusServiceTests.swift b/HutchTests/SystemStatusServiceTests.swift index 58ace33..d1577b6 100644 --- a/HutchTests/SystemStatusServiceTests.swift +++ b/HutchTests/SystemStatusServiceTests.swift @@ -19,6 +19,18 @@ struct SystemStatusServiceTests { #expect(snapshot.activeIncidents[0].url?.absoluteString == "https://status.sr.ht/issues/2026-04-06-ddos-attack/") } + @Test + func parsesStatusHTMLWithClassOrderChangesAndTimeElements() throws { + let snapshot = try SystemStatusService.parseSnapshotHTML(Self.variantHTML, fetchedAt: .now) + + #expect(snapshot.services.count == 2) + #expect(snapshot.services[0].status == .operational) + #expect(snapshot.services[1].status == .majorOutage) + #expect(snapshot.activeIncidents.count == 1) + #expect(snapshot.activeIncidents[0].title == "builds.sr.ht outage") + #expect(snapshot.activeIncidents[0].publishedAt == ISO8601DateFormatter().date(from: "2026-04-07T12:00:00Z")) + } + @Test func parsesIncidentFeedRSS() async throws { let incidents = try await SystemStatusService.parseIncidentFeedXML(Data(Self.sampleRSS.utf8)) @@ -32,6 +44,15 @@ struct SystemStatusServiceTests { #expect(incidents[1].updatedAt != nil) } + @Test + func parsesIncidentFeedWithISO8601Dates() async throws { + let incidents = try await SystemStatusService.parseIncidentFeedXML(Data(Self.variantRSS.utf8)) + + #expect(incidents.count == 1) + #expect(incidents[0].title == "Status feed moved") + #expect(incidents[0].publishedAt == ISO8601DateFormatter().date(from: "2026-04-07T15:30:00Z")) + } + @Test func bannerSummaryPrefersSpecificServiceThenCount() { let operational = SystemStatusSnapshot( @@ -102,6 +123,32 @@ struct SystemStatusServiceTests { """# + private static let variantHTML = #""" + + +
+ meta.sr.ht + All systems operational +
+
+ builds.sr.ht +
Outage
+
+
+
+

builds.sr.ht outage

+

Build jobs are currently failing.

+
+
+ + +

builds.sr.ht outage

+ Investigating elevated failures +
+ + + """# + private static let sampleRSS = #""" @@ -126,4 +173,20 @@ struct SystemStatusServiceTests { """# + + private static let variantRSS = #""" + + + + sr.ht status + + Status feed moved + https://status.sr.ht/issues/2026-04-07-feed-moved/ + 2026-04-07T15:30:00Z + https://status.sr.ht/issues/2026-04-07-feed-moved/ + <p>Use the new feed endpoint.</p> + + + + """# } -- cgit v1.2.3