chore: commit remaining workspace changes
This commit is contained in:
@@ -5,9 +5,11 @@ use App\Models\Category;
|
||||
use App\Models\ContentType;
|
||||
use App\Models\Tag;
|
||||
use App\Models\User;
|
||||
use App\Support\Seo\SeoFactory;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Str;
|
||||
use Inertia\Testing\AssertableInertia;
|
||||
|
||||
uses(RefreshDatabase::class);
|
||||
|
||||
@@ -50,15 +52,90 @@ it('renders JSON-LD structured data on published artwork page', function () {
|
||||
$tagB->id => ['source' => 'user', 'confidence' => 0.8],
|
||||
]);
|
||||
|
||||
$html = view('artworks.show', ['artwork' => $artwork])->render();
|
||||
$artwork->load(['user', 'tags', 'categories.contentType']);
|
||||
|
||||
expect($html)
|
||||
->toContain('application/ld+json')
|
||||
expect(json_encode(app(SeoFactory::class)->artwork(
|
||||
$artwork,
|
||||
[
|
||||
'md' => ['url' => 'https://files.skinbase.org/md/schema-ready.webp', 'width' => 600, 'height' => 400],
|
||||
'lg' => ['url' => 'https://files.skinbase.org/lg/schema-ready.webp', 'width' => 1200, 'height' => 800],
|
||||
'xl' => ['url' => 'https://files.skinbase.org/xl/schema-ready.webp', 'width' => 2400, 'height' => 1600],
|
||||
],
|
||||
route('art.show', ['id' => $artwork->id, 'slug' => $artwork->slug]),
|
||||
)->toArray()['json_ld'], JSON_UNESCAPED_SLASHES))
|
||||
->toContain('"@type":"ImageObject"')
|
||||
->toContain('"name":"Schema Ready Artwork"')
|
||||
->toContain('"keywords":["neon","city"]');
|
||||
});
|
||||
|
||||
it('builds artwork seo data with breadcrumb and image-license metadata', function () {
|
||||
$user = User::factory()->create(['name' => 'Schema Breadcrumb Author']);
|
||||
|
||||
$contentType = ContentType::create([
|
||||
'name' => 'Photography',
|
||||
'slug' => 'photography',
|
||||
'description' => 'Photography content',
|
||||
]);
|
||||
|
||||
$parentCategory = Category::create([
|
||||
'content_type_id' => $contentType->id,
|
||||
'parent_id' => null,
|
||||
'name' => 'Nature',
|
||||
'slug' => 'nature',
|
||||
'description' => 'Nature works',
|
||||
'is_active' => true,
|
||||
'sort_order' => 0,
|
||||
]);
|
||||
|
||||
$category = Category::create([
|
||||
'content_type_id' => $contentType->id,
|
||||
'parent_id' => $parentCategory->id,
|
||||
'name' => 'Forest',
|
||||
'slug' => 'forest',
|
||||
'description' => 'Forest works',
|
||||
'is_active' => true,
|
||||
'sort_order' => 1,
|
||||
]);
|
||||
|
||||
$artwork = Artwork::factory()->create([
|
||||
'user_id' => $user->id,
|
||||
'title' => 'Licensed Artwork',
|
||||
'slug' => 'licensed-artwork',
|
||||
'description' => 'Artwork description for breadcrumb schema test.',
|
||||
'published_at' => now()->subMinute(),
|
||||
'is_public' => true,
|
||||
'is_approved' => true,
|
||||
]);
|
||||
|
||||
$artwork->categories()->attach($category->id);
|
||||
$artwork->load(['user', 'tags', 'categories.contentType', 'categories.parent.contentType']);
|
||||
$artwork->setAttribute('license_url', 'https://skinbase.org/licenses/custom-license');
|
||||
|
||||
$seo = app(SeoFactory::class)->artwork(
|
||||
$artwork,
|
||||
[
|
||||
'md' => ['url' => 'https://files.skinbase.org/md/licensed.webp', 'width' => 600, 'height' => 400],
|
||||
'lg' => ['url' => 'https://files.skinbase.org/lg/licensed.webp', 'width' => 1200, 'height' => 800],
|
||||
'xl' => ['url' => 'https://files.skinbase.org/xl/licensed.webp', 'width' => 2400, 'height' => 1600],
|
||||
],
|
||||
route('art.show', ['id' => $artwork->id, 'slug' => $artwork->slug]),
|
||||
[
|
||||
['name' => 'Photography', 'url' => url('/photography')],
|
||||
['name' => 'Nature', 'url' => url('/photography/nature')],
|
||||
['name' => 'Forest', 'url' => url('/photography/nature/forest')],
|
||||
['name' => 'Licensed Artwork', 'url' => route('art.show', ['id' => $artwork->id, 'slug' => $artwork->slug])],
|
||||
],
|
||||
)->toArray();
|
||||
|
||||
expect(json_encode($seo['json_ld'], JSON_UNESCAPED_SLASHES))
|
||||
->toContain('"@type":"ImageObject"')
|
||||
->toContain('"creditText":"Schema Breadcrumb Author"')
|
||||
->toContain('"license":"https://skinbase.org/licenses/custom-license"')
|
||||
->toContain('"@type":"BreadcrumbList"')
|
||||
->toContain('"name":"Photography"')
|
||||
->toContain('"name":"Forest"');
|
||||
});
|
||||
|
||||
it('renders JSON-LD via routed artwork show endpoint', function () {
|
||||
$user = User::factory()->create(['name' => 'Schema Route Author']);
|
||||
|
||||
@@ -109,9 +186,16 @@ it('renders JSON-LD via routed artwork show endpoint', function () {
|
||||
|
||||
$response = $this->get($url);
|
||||
|
||||
$response->assertOk();
|
||||
$response->assertSee('application/ld+json', false);
|
||||
$response->assertSee('"@type":"ImageObject"', false);
|
||||
$response->assertSee('"name":"Schema Route Artwork"', false);
|
||||
$response->assertSee('"keywords":["route-tag"]', false);
|
||||
$response->assertOk()
|
||||
->assertInertia(fn (AssertableInertia $page) => $page
|
||||
->component('ArtworkPage')
|
||||
->where('seo.title', fn (string $title): bool => str_contains($title, 'Schema Route Artwork'))
|
||||
->where('seo.json_ld', function ($schemas): bool {
|
||||
$json = json_encode($schemas, JSON_UNESCAPED_SLASHES);
|
||||
|
||||
return str_contains($json, '"@type":"ImageObject"')
|
||||
&& str_contains($json, '"@type":"BreadcrumbList"')
|
||||
&& str_contains($json, '"name":"Schema Route Artwork"')
|
||||
&& str_contains($json, '"keywords":["route-tag"]');
|
||||
}));
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user