Save workspace changes
This commit is contained in:
@@ -0,0 +1,81 @@
|
||||
<?php
|
||||
|
||||
use App\Services\ArtworkService;
|
||||
use Illuminate\Pagination\LengthAwarePaginator;
|
||||
use Mockery;
|
||||
|
||||
/** Return an empty LengthAwarePaginator with the given path. */
|
||||
function emptyPaginator(string $path = '/'): LengthAwarePaginator
|
||||
{
|
||||
return (new LengthAwarePaginator(collect(), 0, 20, 1))->setPath($path);
|
||||
}
|
||||
|
||||
beforeEach(function () {
|
||||
// Swap ArtworkService so tests need no database
|
||||
$this->artworksMock = Mockery::mock(ArtworkService::class);
|
||||
$this->artworksMock->shouldReceive('getFeaturedArtworks')->andReturn(emptyPaginator('/'))->byDefault();
|
||||
$this->artworksMock->shouldReceive('getLatestArtworks')->andReturn(collect())->byDefault();
|
||||
$this->app->instance(ArtworkService::class, $this->artworksMock);
|
||||
});
|
||||
|
||||
it('renders the home page successfully', function () {
|
||||
$this->get('/')
|
||||
->assertStatus(200);
|
||||
});
|
||||
|
||||
it('renders the home page with grid=v2 without errors', function () {
|
||||
$this->get('/?grid=v2')
|
||||
->assertStatus(200);
|
||||
});
|
||||
|
||||
it('home page contains the gallery section', function () {
|
||||
$this->get('/')
|
||||
->assertStatus(200)
|
||||
->assertSee('id="homepage-root"', false)
|
||||
->assertSee('id="homepage-props"', false);
|
||||
});
|
||||
|
||||
it('home page includes a canonical link tag', function () {
|
||||
$this->get('/')
|
||||
->assertStatus(200)
|
||||
->assertSee('rel="canonical"', false);
|
||||
});
|
||||
|
||||
it('home page emits unified SEO tags and structured data', function () {
|
||||
$html = $this->get('/')
|
||||
->assertStatus(200)
|
||||
->getContent();
|
||||
|
||||
expect($html)
|
||||
->toContain('name="description"')
|
||||
->toContain('property="og:title"')
|
||||
->toContain('name="twitter:card"')
|
||||
->toContain('application/ld+json')
|
||||
->toContain('WebSite');
|
||||
});
|
||||
|
||||
it('home page exposes digital art in the explore navigation', function () {
|
||||
$html = $this->get('/')
|
||||
->assertStatus(200)
|
||||
->getContent();
|
||||
|
||||
expect($html)
|
||||
->toContain('href="/digital-art"')
|
||||
->toContain('Digital Art');
|
||||
});
|
||||
|
||||
it('home page with ?page=2 renders without errors', function () {
|
||||
// getLatestArtworks() returns a plain Collection (no pagination),
|
||||
// so seoNext/seoPrev for home are always null — but the page must still render cleanly.
|
||||
$this->get('/?page=2')
|
||||
->assertStatus(200)
|
||||
->assertSee('rel="canonical"', false);
|
||||
});
|
||||
|
||||
it('home page does not throw undefined variable errors', function () {
|
||||
// If any Blade variable is undefined an exception is thrown → non-200 status
|
||||
// This test explicitly guards against regressions on $gridV2 / $seoCanonical
|
||||
expect(
|
||||
fn () => $this->get('/')->assertStatus(200)
|
||||
)->not->toThrow(\ErrorException::class);
|
||||
});
|
||||
Reference in New Issue
Block a user