Files
ppeasy_vg12/tests/Browser/SettingsTest.php
T
2026-10-09 08:21:06 +02:00

95 lines
2.9 KiB
PHP

<?php
use Tests\UpdatesSettings;
uses(UpdatesSettings::class);
beforeEach(function () {
$this->artisan('db:seed');
});
it('updates the application name', function () {
browserLogin();
visit('/settings')
->assertNoJavaScriptErrors()
->assertSee('General Settings')
->fill('#app_name', 'Vanguard Renamed')
->click('Update')
->assertSee('Settings updated successfully.');
expect(setting('app_name'))->toBe('Vanguard Renamed');
});
it('renders both authentication settings tabs', function () {
browserLogin();
visit('/settings/auth')
->assertNoJavaScriptErrors()
->assertSee('Authentication')
->assertSee('Authentication Throttling')
->assertSee('Two-Factor Authentication')
->assertSee('Force Password Change On Next Login')
->click('Registration')
->assertSee('Allow Registration')
->assertSee('Google reCAPTCHA');
});
it('saves the general authentication settings', function () {
browserLogin();
// Two cards on this tab each end in an Update button, so the submit is
// scoped to the form that owns the field being changed.
visit('/settings/auth')
->fill('#login_reset_token_lifetime', '45')
->fill('#max_active_sessions', '3')
->click('form:has(#login_reset_token_lifetime) button[type="submit"]')
->assertSee('Settings updated successfully.');
expect(setting('login_reset_token_lifetime'))->toBe('45');
expect(setting('max_active_sessions'))->toBe('3');
});
it('toggles a switch and saves the throttling settings', function () {
$this->setSettings(['throttle_enabled' => 0]);
browserLogin();
visit('/settings/auth')
->assertAttribute('#switch-throttle', 'aria-checked', 'false')
->click('#switch-throttle')
->click('form:has(#throttle_attempts) button[type="submit"]')
->assertSee('Settings updated successfully.');
expect((bool) setting('throttle_enabled'))->toBeTrue();
});
it('turns a feature toggle card on', function () {
$this->setSettings(['2fa.enabled' => 0]);
browserLogin();
visit('/settings/auth')
->assertSee('Two-Factor Authentication')
->click('div:has(> h5:text-is("Two-Factor Authentication")) button')
->assertSee('Two-Factor Authentication enabled successfully.');
expect((bool) setting('2fa.enabled'))->toBeTrue();
});
it('updates the notification settings', function () {
$this->setSettings(['notifications_signup_email' => 0]);
browserLogin();
visit('/settings/notifications')
->assertNoJavaScriptErrors()
->assertSee('Notification Settings')
->assertSee('Sign-Up Notification')
->click('#switch-signup-email')
->click('Update')
->assertSee('Settings updated successfully.');
expect((bool) setting('notifications_signup_email'))->toBeTrue();
});