added a help system, replaced the words "tenant" and "Pwa" with better alternatives. corrected and implemented cron jobs. prepared going live on a coolify-powered system.
This commit is contained in:
59
tests/Feature/Api/HelpControllerTest.php
Normal file
59
tests/Feature/Api/HelpControllerTest.php
Normal file
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature\Api;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Laravel\Sanctum\Sanctum;
|
||||
use Tests\TestCase;
|
||||
|
||||
class HelpControllerTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
Storage::fake('local');
|
||||
$this->artisan('help:sync');
|
||||
}
|
||||
|
||||
public function test_guest_help_listing_is_public(): void
|
||||
{
|
||||
$response = $this->getJson('/api/v1/help?audience=guest&locale=en');
|
||||
|
||||
$response->assertOk()
|
||||
->assertJsonStructure(['data' => [['slug', 'title', 'summary']]])
|
||||
->assertJsonFragment(['slug' => 'getting-started']);
|
||||
}
|
||||
|
||||
public function test_guest_help_detail_returns_article(): void
|
||||
{
|
||||
$response = $this->getJson('/api/v1/help/getting-started?audience=guest&locale=en');
|
||||
|
||||
$response->assertOk()
|
||||
->assertJsonPath('data.slug', 'getting-started');
|
||||
|
||||
$this->assertStringContainsString('When to read this', $response->json('data.body_html'));
|
||||
}
|
||||
|
||||
public function test_admin_help_requires_authentication(): void
|
||||
{
|
||||
$this->getJson('/api/v1/help?audience=admin&locale=en')->assertStatus(401);
|
||||
}
|
||||
|
||||
public function test_admin_help_allows_authenticated_users(): void
|
||||
{
|
||||
$user = User::factory()->create([
|
||||
'role' => 'tenant_admin',
|
||||
]);
|
||||
|
||||
Sanctum::actingAs($user);
|
||||
|
||||
$response = $this->getJson('/api/v1/help?audience=admin&locale=en');
|
||||
|
||||
$response->assertOk()
|
||||
->assertJsonFragment(['slug' => 'tenant-dashboard-overview']);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user