Take the website's screenshots with one command
composer screenshots runs Pest browser tests in tests/Screenshots, outside every test suite: fixed demo data under a frozen clock, desktop (MacBook 14, 2x) and phone (iPhone 15 Pro, 3x) in light and dark, each capture published at once as WebP at two widths into website/img/screenshots. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01V9NnLxnPp8vaaurb3Z1MFy
This commit is contained in:
co-authored by
Claude Opus 5
parent
4470c2ed87
commit
e49bdf3eb3
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
use Tests\Screenshots\Publisher;
|
||||
|
||||
beforeEach(function () {
|
||||
$this->root = sys_get_temp_dir().'/sealshare-publisher-'.uniqid();
|
||||
mkdir($this->root.'/captures', 0755, true);
|
||||
});
|
||||
|
||||
afterEach(function () {
|
||||
exec('rm -rf '.escapeshellarg($this->root));
|
||||
});
|
||||
|
||||
test('a capture is published as WebP at each width, keeping its aspect ratio', function () {
|
||||
$capture = imagecreatetruecolor(3024, 1964);
|
||||
imagepng($capture, $this->root.'/captures/desktop-light-01-upload.png');
|
||||
|
||||
(new Publisher($this->root.'/captures', $this->root.'/site'))
|
||||
->publish('desktop-light-01-upload', 'desktop', 'light', '01-upload', [1600, 800]);
|
||||
|
||||
foreach ([1600 => 1039, 800 => 520] as $width => $height) {
|
||||
$path = $this->root."/site/desktop/light/01-upload-{$width}.webp";
|
||||
|
||||
expect($path)->toBeFile()
|
||||
->and(getimagesize($path))->toMatchArray([0 => $width, 1 => $height, 'mime' => 'image/webp']);
|
||||
}
|
||||
});
|
||||
|
||||
test('a capture that was not written fails the run', function () {
|
||||
(new Publisher($this->root.'/captures', $this->root.'/site'))
|
||||
->publish('phone-dark-02-password', 'phone', 'dark', '02-password', [1080]);
|
||||
})->throws(RuntimeException::class, 'The capture [phone-dark-02-password] was not written');
|
||||
Reference in New Issue
Block a user