- Added fonts:sync-google command (uses GOOGLE_FONTS_API_KEY, generates /public/fonts/google files, manifest, CSS, cache flush) and
exposed manifest via new GET /api/v1/tenant/fonts endpoint with fallbacks for existing local fonts.
- Imported generated fonts CSS, added API client + font loader hook, and wired branding page font fields to searchable selects (with
custom override) that auto-load selected fonts.
- Invites layout editor now offers font selection per element with runtime font loading for previews/export alignment.
- New tests cover font sync command and font manifest API.
Tests run: php artisan test --filter=Fonts --testsuite=Feature.
Note: repository already has other modified files (e.g., EventPublicController, SettingsStoreRequest, guest components, etc.); left
untouched. Run php artisan fonts:sync-google after setting the API key to populate /public/fonts/google.
72 lines
2.0 KiB
PHP
72 lines
2.0 KiB
PHP
<?php
|
|
|
|
namespace Tests\Feature\Api;
|
|
|
|
use App\Models\Tenant;
|
|
use App\Models\User;
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
use Illuminate\Support\Facades\File;
|
|
use Tests\TestCase;
|
|
|
|
class TenantFontsTest extends TestCase
|
|
{
|
|
use RefreshDatabase;
|
|
|
|
private ?string $manifestBackup = null;
|
|
|
|
protected function setUp(): void
|
|
{
|
|
parent::setUp();
|
|
|
|
$manifestPath = public_path('fonts/google/manifest.json');
|
|
if (File::exists($manifestPath)) {
|
|
$this->manifestBackup = File::get($manifestPath);
|
|
}
|
|
}
|
|
|
|
protected function tearDown(): void
|
|
{
|
|
$manifestPath = public_path('fonts/google/manifest.json');
|
|
if ($this->manifestBackup !== null) {
|
|
File::put($manifestPath, $this->manifestBackup);
|
|
} else {
|
|
File::delete($manifestPath);
|
|
}
|
|
|
|
parent::tearDown();
|
|
}
|
|
|
|
public function test_tenant_can_fetch_font_manifest(): void
|
|
{
|
|
$manifestPath = public_path('fonts/google/manifest.json');
|
|
File::ensureDirectoryExists(dirname($manifestPath));
|
|
|
|
File::put($manifestPath, json_encode([
|
|
'fonts' => [
|
|
[
|
|
'family' => 'Manifest Font',
|
|
'category' => 'sans-serif',
|
|
'variants' => [
|
|
['variant' => 'regular', 'weight' => 400, 'style' => 'normal', 'url' => '/fonts/google/manifest-font/regular.woff2'],
|
|
],
|
|
],
|
|
],
|
|
]));
|
|
|
|
$tenant = Tenant::factory()->create();
|
|
$user = User::factory()->create([
|
|
'tenant_id' => $tenant->id,
|
|
'role' => 'tenant_admin',
|
|
]);
|
|
|
|
$token = $user->createToken('test')->plainTextToken;
|
|
|
|
$response = $this->withHeader('Authorization', 'Bearer '.$token)
|
|
->getJson('/api/v1/tenant/fonts');
|
|
|
|
$response->assertOk();
|
|
$response->assertJsonStructure(['data']);
|
|
$this->assertTrue(collect($response->json('data'))->pluck('family')->contains('Manifest Font'));
|
|
}
|
|
}
|