Initial commit
This commit is contained in:
119
tests/Feature/Logs/LogQsoTableTest.php
Normal file
119
tests/Feature/Logs/LogQsoTableTest.php
Normal file
@@ -0,0 +1,119 @@
|
||||
<?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
|
||||
{
|
||||
$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
|
||||
{
|
||||
$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']);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user