|
96 | 96 | ->major_outage->toBe(1) |
97 | 97 | ->under_maintenance->toBe(1); |
98 | 98 | }); |
| 99 | + |
| 100 | +it('excludes disabled components from component overview', function () { |
| 101 | + Component::factory()->create([ |
| 102 | + 'status' => ComponentStatusEnum::operational->value, |
| 103 | + 'enabled' => true, |
| 104 | + ]); |
| 105 | + |
| 106 | + Component::factory()->create([ |
| 107 | + 'status' => ComponentStatusEnum::major_outage->value, |
| 108 | + 'enabled' => false, |
| 109 | + ]); |
| 110 | + |
| 111 | + $components = (new Status)->components(); |
| 112 | + |
| 113 | + expect($components) |
| 114 | + ->total->toBe(1) |
| 115 | + ->operational->toBe(1) |
| 116 | + ->major_outage->toBe(0); |
| 117 | +}); |
| 118 | + |
| 119 | +it('excludes disabled components from system status calculation', function () { |
| 120 | + Component::factory()->create([ |
| 121 | + 'status' => ComponentStatusEnum::operational->value, |
| 122 | + 'enabled' => true, |
| 123 | + ]); |
| 124 | + |
| 125 | + Component::factory()->create([ |
| 126 | + 'status' => ComponentStatusEnum::partial_outage->value, |
| 127 | + 'enabled' => false, |
| 128 | + ]); |
| 129 | + |
| 130 | + $this->assertEquals((new Status)->current(), SystemStatusEnum::operational); |
| 131 | +}); |
| 132 | + |
| 133 | +it('excludes disabled components from major outage calculation', function () { |
| 134 | + $status = new Status; |
| 135 | + |
| 136 | + Component::factory()->create([ |
| 137 | + 'status' => ComponentStatusEnum::major_outage->value, |
| 138 | + 'enabled' => false, |
| 139 | + ]); |
| 140 | + |
| 141 | + Component::factory()->create([ |
| 142 | + 'status' => ComponentStatusEnum::operational->value, |
| 143 | + 'enabled' => true, |
| 144 | + ]); |
| 145 | + |
| 146 | + assertFalse($status->majorOutage()); |
| 147 | +}); |
| 148 | + |
| 149 | +it('excludes disabled components from under maintenance status', function () { |
| 150 | + Component::factory()->create([ |
| 151 | + 'status' => ComponentStatusEnum::under_maintenance->value, |
| 152 | + 'enabled' => false, |
| 153 | + ]); |
| 154 | + |
| 155 | + Component::factory()->create([ |
| 156 | + 'status' => ComponentStatusEnum::operational->value, |
| 157 | + 'enabled' => true, |
| 158 | + ]); |
| 159 | + |
| 160 | + $this->assertEquals((new Status)->current(), SystemStatusEnum::operational); |
| 161 | +}); |
0 commit comments