funcional a parte de token

This commit is contained in:
2026-05-19 14:48:58 -05:00
parent abb1fae70d
commit cd38287503
12 changed files with 863 additions and 10 deletions

View File

@@ -54,6 +54,15 @@ class GameRankingApiTest extends TestCase
->assertJsonPath('9.name', 'Game 3');
}
public function test_games_route_returns_ids_for_frontend_selection(): void
{
$this->getJsonWithJwt('/api/v1/games')
->assertOk()
->assertJsonCount(12)
->assertJsonPath('0.id', 1)
->assertJsonPath('0.name', 'Game 1');
}
public function test_history_returns_score_evolution_for_a_game(): void
{
$this->getJsonWithJwt('/api/v1/rankings/history/5')
@@ -67,6 +76,14 @@ class GameRankingApiTest extends TestCase
->assertJsonPath('history.2.points', 50000);
}
public function test_history_can_be_requested_with_query_string_id(): void
{
$this->getJsonWithJwt('/api/v1/rankings/history?id=6')
->assertOk()
->assertJsonPath('game', 'Game 6')
->assertJsonPath('history.0.points', 600);
}
public function test_platform_ranking_returns_only_requested_platform_ordered_by_active_players(): void
{
$this->getJsonWithJwt('/api/v1/rankings/platforms/Steam')
@@ -84,6 +101,16 @@ class GameRankingApiTest extends TestCase
->assertJson(['userId' => 'consumer-project']);
}
public function test_can_accept_any_bearer_token_when_enabled_for_demo_integration(): void
{
config(['jwt.allow_any_token' => true]);
$this->withHeader('Authorization', 'Bearer token-do-front')
->getJson('/api/v1/rankings/weekly')
->assertOk()
->assertJsonCount(10);
}
private function getJsonWithJwt(string $uri)
{
return $this->withHeader('Authorization', 'Bearer '.$this->jwt)