Skip to content

Commit 32846c4

Browse files
cursoragentdobrac
andcommitted
cover component status
Co-authored-by: Jakub Dobry <dobrac@users.noreply.github.com>
1 parent 717c042 commit 32846c4

2 files changed

Lines changed: 55 additions & 5 deletions

File tree

src/features/dashboard/layouts/status-indicator.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,13 @@ function getWorstComponentState(
4747

4848
function hasMaintenanceInProgress(
4949
maintenances: IncidentIOStatusPageSummaryResponse['scheduled_maintenances']
50-
) {
51-
return maintenances?.some(
52-
(maintenance) =>
53-
maintenance.status === 'in_progress' ||
54-
maintenance.status === 'maintenance_in_progress'
50+
): boolean {
51+
return (
52+
maintenances?.some(
53+
(maintenance) =>
54+
maintenance.status === 'in_progress' ||
55+
maintenance.status === 'maintenance_in_progress'
56+
) ?? false
5557
)
5658
}
5759

tests/unit/status-indicator.test.ts

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,54 @@ describe('status-indicator', () => {
5151
).toBe('downtime')
5252
})
5353

54+
it('should report downtime for major outage components', () => {
55+
expect(
56+
getStatusPageStateFromSummary({
57+
status: {
58+
indicator: 'none',
59+
},
60+
components: [
61+
{
62+
status: 'degraded_performance',
63+
},
64+
{
65+
status: 'major_outage',
66+
},
67+
],
68+
})
69+
).toBe('downtime')
70+
})
71+
72+
it('should report degraded for partial outage components', () => {
73+
expect(
74+
getStatusPageStateFromSummary({
75+
status: {
76+
indicator: 'none',
77+
},
78+
components: [
79+
{
80+
status: 'partial_outage',
81+
},
82+
],
83+
})
84+
).toBe('degraded')
85+
})
86+
87+
it('should prioritize degraded components over maintenance indicator', () => {
88+
expect(
89+
getStatusPageStateFromSummary({
90+
status: {
91+
indicator: 'maintenance',
92+
},
93+
components: [
94+
{
95+
status: 'degraded_performance',
96+
},
97+
],
98+
})
99+
).toBe('degraded')
100+
})
101+
54102
it('should report downtime for critical summary indicator', () => {
55103
expect(
56104
getStatusPageStateFromSummary({

0 commit comments

Comments
 (0)