Add Departure Time Slot and Catalog read API (T2.4, T2.5)
Adds the shared DepartureTimeSlot catalog entity with its Filament resource, and public GET /api/v1/companies + /api/v1/destinations endpoints (auth:sanctum + throttled) for the mini app/mobile/agent clients to consume.
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
use App\Models\User;
|
||||
use Modules\Catalog\Models\Destination;
|
||||
use Modules\Catalog\Models\EvCompany;
|
||||
|
||||
beforeEach(function () {
|
||||
$this->token = User::factory()->create()->createToken('test-token')->plainTextToken;
|
||||
});
|
||||
|
||||
test('lists active ev companies', function () {
|
||||
$active = EvCompany::factory()->create(['is_active' => true]);
|
||||
EvCompany::factory()->create(['is_active' => false]);
|
||||
|
||||
$this->withHeader('Authorization', "Bearer {$this->token}")
|
||||
->getJson('/api/v1/companies')
|
||||
->assertSuccessful()
|
||||
->assertJsonCount(1, 'data')
|
||||
->assertJsonFragment(['id' => $active->id]);
|
||||
});
|
||||
|
||||
test('lists active destinations', function () {
|
||||
$active = Destination::factory()->create(['is_active' => true]);
|
||||
Destination::factory()->create(['is_active' => false]);
|
||||
|
||||
$this->withHeader('Authorization', "Bearer {$this->token}")
|
||||
->getJson('/api/v1/destinations')
|
||||
->assertSuccessful()
|
||||
->assertJsonCount(1, 'data')
|
||||
->assertJsonFragment(['id' => $active->id]);
|
||||
});
|
||||
|
||||
test('companies endpoint rejects unauthenticated requests', function () {
|
||||
$this->getJson('/api/v1/companies')->assertUnauthorized();
|
||||
});
|
||||
|
||||
test('destinations endpoint rejects unauthenticated requests', function () {
|
||||
$this->getJson('/api/v1/destinations')->assertUnauthorized();
|
||||
});
|
||||
Reference in New Issue
Block a user