mirror of
https://github.com/HolgerHatGarKeineNode/einundzwanzig-app.git
synced 2026-03-14 14:23:18 +00:00
🛠️ Remove deprecated Forge deployment workflow, add logic for fetching missing highscore names via Nostr, and update API routes with refined highscore endpoints.
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
<?php
|
||||
|
||||
use App\Http\Controllers\Api\HighscoreController;
|
||||
use App\Models\Highscore;
|
||||
use Carbon\CarbonImmutable;
|
||||
|
||||
@@ -66,6 +67,35 @@ test('highscore submission updates existing attempt for same npub and datetime',
|
||||
$this->assertSame(1, Highscore::query()->count());
|
||||
});
|
||||
|
||||
test('missing name is fetched from nostr when available', function () {
|
||||
$fetchedName = 'Fetched Player';
|
||||
|
||||
$controllerMock = \Mockery::mock(HighscoreController::class)->makePartial();
|
||||
$controllerMock->shouldAllowMockingProtectedMethods();
|
||||
$controllerMock->shouldReceive('fetchNostrName')->once()->andReturn($fetchedName);
|
||||
|
||||
app()->instance(HighscoreController::class, $controllerMock);
|
||||
|
||||
$payload = [
|
||||
'npub' => 'npub1fetchnamevalue',
|
||||
'satoshis' => 1337,
|
||||
'blocks' => 2,
|
||||
'datetime' => CarbonImmutable::now()->subMinute()->toIso8601String(),
|
||||
];
|
||||
|
||||
$response = $this->postJson(route('api.highscores.store'), $payload);
|
||||
|
||||
$response->assertAccepted()
|
||||
->assertJsonPath('data.name', $fetchedName);
|
||||
|
||||
$this->assertDatabaseHas('highscores', [
|
||||
'npub' => $payload['npub'],
|
||||
'name' => $fetchedName,
|
||||
'satoshis' => $payload['satoshis'],
|
||||
'blocks' => $payload['blocks'],
|
||||
]);
|
||||
});
|
||||
|
||||
test('highscore submission does not clear existing name when omitted', function () {
|
||||
$datetime = CarbonImmutable::now()->subMinutes(15);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user