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

63 lines
1.8 KiB
PHP

<?php
use App\Models\User;
use Tests\UpdatesSettings;
uses(UpdatesSettings::class);
/*
* reCAPTCHA is disabled the way the server suite disables it: the widget calls
* out to Google, which a test must never depend on.
*/
beforeEach(function () {
$this->artisan('db:seed');
$this->setSettings([
'reg_enabled' => true,
'registration.captcha.enabled' => false,
'tos' => false,
'approval.enabled' => false,
'reg_email_confirmation' => false,
]);
});
it('renders the registration form', function () {
visit('/register')
->assertNoJavaScriptErrors()
->assertSee('Register')
->assertPresent('#email')
->assertPresent('#username')
->assertPresent('#password');
});
it('registers a new user', function () {
visit('/register')
->fill('#email', 'newcomer@vanguard.test')
->fill('#username', 'newcomer')
->fill('#password', 'sup3r-secret')
->fill('#password_confirmation', 'sup3r-secret')
// The page heading is also "Register", and a text locator would match it
// instead of the button.
->click('button[type="submit"]')
// assertSee waits for the page to settle; assertPathIs does not, so a
// content assertion has to come first after any navigation.
->assertSee('Dashboard')
->assertPathIs('/');
expect(User::where('email', 'newcomer@vanguard.test')->exists())->toBeTrue();
});
it('opens the terms of service dialog', function () {
$this->setSettings(['tos' => true]);
visit('/register')
->assertSee('I accept')
->click('Terms of Service')
->assertSee('Close');
});
it('returns a 404 when registration is disabled', function () {
$this->setSettings(['reg_enabled' => false]);
visit('/register')->assertSee('404');
});