first commit

This commit is contained in:
2026-10-09 08:21:06 +02:00
parent db7456df87
commit d259c62304
3761 changed files with 896046 additions and 0 deletions
+109
View File
@@ -0,0 +1,109 @@
<?php
use Tests\UpdatesSettings;
uses(UpdatesSettings::class);
/*
* Pixel diffing, deliberately narrow.
*
* Chrome desktop only: Pest keys a snapshot on the test file, test name and
* dataset, with nothing for the browser or device, so a second engine would
* compare against the baseline Chrome wrote and always fail.
*
* Only pages whose content cannot move between runs are covered. Excluded on
* purpose: the dashboard, whose registration chart is a canvas with month
* derived labels; /users, /profile and the plugin pages, which render
* registration and log dates; and anything showing a faker generated user.
*
* The navbar avatar is hidden before every capture. It is a raster image scaled
* into a 44px box, and Chrome picks its scaling path depending on whether the
* decode finished before layout: the same 149 pixels flip between two renders
* from run to run, on whichever authenticated page happens to lose the race.
* networkidle and a settle delay both failed to pin it down. Hiding it costs
* nothing -- it is a static asset that never changes -- and keeps the rest of
* the layout, including the navbar itself, under test.
*
* Baselines live in tests/.pest/snapshots and are gitignored, because font
* rasterisation differs between operating systems and a baseline captured on
* one would fail on another. Regenerate with --update-snapshots, inspect a
* failure with --diff.
*/
beforeEach(function () {
$this->artisan('db:seed');
$this->setSettings([
'reg_enabled' => true,
// The widget calls out to Google, which a test must never depend on.
'registration.captcha.enabled' => false,
'tos' => true,
'forgot_password' => true,
]);
});
/**
* Hides the navbar avatar. Injected rather than applied through a helper that
* wraps visit(): Pest marks a test as a browser test by finding visit() in the
* test itself, so a test whose only visit() lives in a helper never connects
* the browser client and fails with "WebSocket client is not connected".
*/
const HIDE_AVATAR = "document.head.insertAdjacentHTML('beforeend', '<style>nav img{visibility:hidden}</style>')";
it('matches the login page', function () {
$page = visit('/login')->assertSee('Login');
$page->script(HIDE_AVATAR);
$page->assertScreenshotMatches();
});
it('matches the registration page', function () {
$page = visit('/register')->assertSee('Register');
$page->script(HIDE_AVATAR);
$page->assertScreenshotMatches();
});
it('matches the forgot password page', function () {
$page = visit('/password/reset')->assertSee('Forgot Your Password?');
$page->script(HIDE_AVATAR);
$page->assertScreenshotMatches();
});
it('matches the roles index', function () {
visualLogin();
$page = visit('/roles')->assertSee('Add Role');
$page->script(HIDE_AVATAR);
$page->assertScreenshotMatches();
});
it('matches the permission matrix', function () {
visualLogin();
$page = visit('/permissions')->assertSee('Save Permissions');
$page->script(HIDE_AVATAR);
$page->assertScreenshotMatches();
});
it('matches the general settings page', function () {
visualLogin();
$page = visit('/settings')->assertSee('General Settings');
$page->script(HIDE_AVATAR);
$page->assertScreenshotMatches();
});
it('matches the authentication settings page', function () {
visualLogin();
$page = visit('/settings/auth')->assertSee('Authentication Throttling');
$page->script(HIDE_AVATAR);
$page->assertScreenshotMatches();
});
it('matches the notification settings page', function () {
visualLogin();
$page = visit('/settings/notifications')->assertSee('Sign-Up Notification');
$page->script(HIDE_AVATAR);
$page->assertScreenshotMatches();
});