* fix: stabilize and diagnose browser CI gate - Replace networkidle screenshot wait (5s client timeout, flaky with long-lived connections) with readyState + fonts-loaded wait and fixed settle in a StableScreenshot helper. - Export standalone diff/expected/actual PNGs on visual mismatch so CI artifacts are directly viewable (vendor only writes an HTML diff view). - Create .env in CI test jobs; without it Laravel's env bootstrap emits a file_get_contents warning on every test. - Bump checkout/cache actions to v5 (Node 20 deprecation). - Gitignore tests/Browser/Screenshots. * docs: track browser CI gate task status in tasks.md
55 lines
1.5 KiB
PHP
55 lines
1.5 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
use App\Models\SiteSetting;
|
|
use Database\Seeders\VisualContentSeeder;
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
use Illuminate\Support\Facades\Artisan;
|
|
|
|
uses(RefreshDatabase::class);
|
|
|
|
beforeEach(function (): void {
|
|
putenv('APP_FROZEN_NOW='.VisualContentSeeder::FROZEN_NOW);
|
|
$_ENV['APP_FROZEN_NOW'] = VisualContentSeeder::FROZEN_NOW;
|
|
$_SERVER['APP_FROZEN_NOW'] = VisualContentSeeder::FROZEN_NOW;
|
|
|
|
$this->refreshApplication();
|
|
|
|
Artisan::call('db:seed', ['--class' => VisualContentSeeder::class, '--force' => true]);
|
|
|
|
SiteSetting::instance();
|
|
});
|
|
|
|
afterEach(function (): void {
|
|
putenv('APP_FROZEN_NOW');
|
|
unset($_ENV['APP_FROZEN_NOW'], $_SERVER['APP_FROZEN_NOW']);
|
|
});
|
|
|
|
$screens = [
|
|
'home' => '/',
|
|
'services' => '/servicos',
|
|
'portfolio' => '/portfolio',
|
|
'portfolio-detail' => '/portfolio/casamento-ana-lucas',
|
|
];
|
|
|
|
$viewports = [
|
|
'desktop' => [1440, 1000],
|
|
'mobile' => [390, 844],
|
|
];
|
|
|
|
foreach ($screens as $screen => $path) {
|
|
foreach ($viewports as $viewport => [$width, $height]) {
|
|
it("matches {$screen} {$viewport} visual baseline", function () use ($path, $width, $height): void {
|
|
$this->assertStableScreenshotMatches(
|
|
$this->visit($path, [
|
|
'reducedMotion' => 'reduce',
|
|
])
|
|
->withLocale('pt-BR')
|
|
->withTimezone('America/Fortaleza')
|
|
->resize($width, $height)
|
|
);
|
|
});
|
|
}
|
|
}
|