Files
vkv/tests/Feature/Logs/LogQsoTableTest.php
Zdeněk Burda 1e484aef47 Skrytí osobních údajů #1
Nezobrazovat detail logu anonymnímu uživateli #2
2026-01-10 12:50:45 +01:00

122 lines
3.8 KiB
PHP

<?php
namespace Tests\Feature\Logs;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
class LogQsoTableTest extends TestCase
{
use RefreshDatabase;
public function test_qso_table_uses_latest_succeeded_non_claimed_run_by_default(): void
{
$this->actingAsAdmin();
$round = $this->createRound();
$log = $this->createLog(['round_id' => $round->id]);
$qsoA = $this->createLogQso([
'log_id' => $log->id,
'qso_index' => 1,
'dx_call' => 'OK1AAA',
]);
$qsoB = $this->createLogQso([
'log_id' => $log->id,
'qso_index' => 2,
'dx_call' => 'OK1BBB',
]);
$claimedRun = $this->createEvaluationRun([
'round_id' => $round->id,
'rules_version' => 'CLAIMED',
'status' => 'SUCCEEDED',
]);
$this->createQsoResult([
'evaluation_run_id' => $claimedRun->id,
'log_qso_id' => $qsoA->id,
'error_code' => 'DUP',
]);
$officialRun = $this->createEvaluationRun([
'round_id' => $round->id,
'rules_version' => 'OFFICIAL',
'status' => 'SUCCEEDED',
]);
$this->createQsoResult([
'evaluation_run_id' => $officialRun->id,
'log_qso_id' => $qsoA->id,
'error_code' => 'OK',
'penalty_points' => 5,
]);
$this->createQsoOverride([
'evaluation_run_id' => $officialRun->id,
'log_qso_id' => $qsoB->id,
'forced_status' => 'AUTO',
'reason' => 'Manual override',
]);
$response = $this->getJson("/api/logs/{$log->id}/qso-table");
$response->assertStatus(200)
->assertJsonFragment(['evaluation_run_id' => $officialRun->id]);
$rows = collect($response->json('data'));
$this->assertCount(2, $rows);
$rowA = $rows->firstWhere('id', $qsoA->id);
$rowB = $rows->firstWhere('id', $qsoB->id);
$this->assertSame('OK1AAA', $rowA['dx_call']);
$this->assertSame('OK', $rowA['result']['error_code']);
$this->assertSame(5, $rowA['result']['penalty_points']);
$this->assertNull($rowA['override']);
$this->assertSame('OK1BBB', $rowB['dx_call']);
$this->assertNull($rowB['result']);
$this->assertSame('Manual override', $rowB['override']['reason']);
}
public function test_qso_table_respects_explicit_evaluation_run_id(): void
{
$this->actingAsAdmin();
$round = $this->createRound();
$log = $this->createLog(['round_id' => $round->id]);
$qso = $this->createLogQso([
'log_id' => $log->id,
'qso_index' => 1,
]);
$claimedRun = $this->createEvaluationRun([
'round_id' => $round->id,
'rules_version' => 'CLAIMED',
'status' => 'SUCCEEDED',
]);
$this->createQsoResult([
'evaluation_run_id' => $claimedRun->id,
'log_qso_id' => $qso->id,
'error_code' => 'DUP',
]);
$officialRun = $this->createEvaluationRun([
'round_id' => $round->id,
'rules_version' => 'OFFICIAL',
'status' => 'SUCCEEDED',
]);
$this->createQsoResult([
'evaluation_run_id' => $officialRun->id,
'log_qso_id' => $qso->id,
'error_code' => 'OK',
]);
$response = $this->getJson("/api/logs/{$log->id}/qso-table?evaluation_run_id={$claimedRun->id}");
$response->assertStatus(200)
->assertJsonFragment(['evaluation_run_id' => $claimedRun->id]);
$rows = collect($response->json('data'));
$row = $rows->firstWhere('id', $qso->id);
$this->assertSame('DUP', $row['result']['error_code']);
}
}