createLogOverride(); $response = $this->getJson('/api/log-overrides'); $response->assertStatus(200) ->assertJsonFragment(['id' => $override->id]); } public function test_index_can_filter_by_evaluation_run(): void { $runA = $this->createEvaluationRun(); $runB = $this->createEvaluationRun(); $overrideA = $this->createLogOverride(['evaluation_run_id' => $runA->id]); $this->createLogOverride(['evaluation_run_id' => $runB->id]); $response = $this->getJson("/api/log-overrides?evaluation_run_id={$runA->id}"); $response->assertStatus(200) ->assertJsonFragment(['id' => $overrideA->id]); $ids = collect($response->json('data'))->pluck('id')->all(); $this->assertCount(1, $ids); } public function test_show_returns_log_override(): void { $override = $this->createLogOverride(); $response = $this->getJson("/api/log-overrides/{$override->id}"); $response->assertStatus(200) ->assertJsonFragment(['id' => $override->id]); } public function test_admin_can_create_update_and_delete_override(): void { $this->actingAsAdmin(); $run = $this->createEvaluationRun(); $log = $this->createLog(['round_id' => $run->round_id]); $createResponse = $this->postJson('/api/log-overrides', [ 'evaluation_run_id' => $run->id, 'log_id' => $log->id, 'forced_log_status' => 'CHECK', 'reason' => 'Test důvod', ]); $createResponse->assertStatus(201); $overrideId = $createResponse->json('id'); $updateResponse = $this->putJson("/api/log-overrides/{$overrideId}", [ 'evaluation_run_id' => $run->id, 'log_id' => $log->id, 'forced_log_status' => 'OK', 'reason' => 'Aktualizace', ]); $updateResponse->assertStatus(200) ->assertJsonFragment(['id' => $overrideId]); $this->deleteJson("/api/log-overrides/{$overrideId}") ->assertStatus(204); } public function test_non_admin_cannot_create_override(): void { $this->actingAsUser(); $run = $this->createEvaluationRun(); $log = $this->createLog(['round_id' => $run->round_id]); $this->postJson('/api/log-overrides', [ 'evaluation_run_id' => $run->id, 'log_id' => $log->id, 'forced_log_status' => 'CHECK', ])->assertStatus(403); } }