first commit
This commit is contained in:
@@ -0,0 +1,77 @@
|
||||
<?php
|
||||
|
||||
use Facades\Tests\Setup\UserFactory;
|
||||
use Tests\UpdatesSettings;
|
||||
|
||||
uses(UpdatesSettings::class);
|
||||
|
||||
beforeEach(function () {
|
||||
$this->artisan('db:seed');
|
||||
});
|
||||
|
||||
it('renders the login form', function () {
|
||||
visit('/login')
|
||||
->assertNoJavaScriptErrors()
|
||||
->assertSee('Login')
|
||||
->assertPresent('#username')
|
||||
->assertPresent('#password');
|
||||
});
|
||||
|
||||
it('signs a user in and lands on the dashboard', function () {
|
||||
$user = UserFactory::admin()->create(['password' => 'password']);
|
||||
|
||||
visit('/login')
|
||||
->fill('#username', $user->email)
|
||||
->fill('#password', 'password')
|
||||
->click('Log In')
|
||||
->assertPathIs('/')
|
||||
->assertSee('Dashboard');
|
||||
|
||||
$this->assertAuthenticatedAs($user);
|
||||
});
|
||||
|
||||
it('keeps the user on the login page after wrong credentials', function () {
|
||||
$user = UserFactory::admin()->create(['password' => 'password']);
|
||||
|
||||
visit('/login')
|
||||
->fill('#username', $user->email)
|
||||
->fill('#password', 'wrong-password')
|
||||
->click('Log In')
|
||||
->assertPathIs('/login')
|
||||
->assertSee('These credentials do not match our records.');
|
||||
|
||||
$this->assertGuest();
|
||||
});
|
||||
|
||||
it('sends an unauthenticated visitor to the login page', function () {
|
||||
visit('/')->assertPathIs('/login')->assertSee('Login');
|
||||
|
||||
$this->assertGuest();
|
||||
});
|
||||
|
||||
it('logs the user back out', function () {
|
||||
browserLogin();
|
||||
|
||||
visit('/logout')->assertPathIs('/login')->assertSee('Login');
|
||||
|
||||
$this->assertGuest();
|
||||
});
|
||||
|
||||
it('reveals the password when the toggle is pressed', function () {
|
||||
visit('/login')
|
||||
->assertAttribute('#password', 'type', 'password')
|
||||
->click('[aria-label="Show password"]')
|
||||
->assertAttribute('#password', 'type', 'text');
|
||||
});
|
||||
|
||||
it('hides the password reset link when the setting is disabled', function () {
|
||||
$this->setSettings(['forgot_password' => false]);
|
||||
|
||||
visit('/login')->assertSee('Login')->assertDontSee('I forgot my password');
|
||||
});
|
||||
|
||||
it('shows the password reset link when the setting is enabled', function () {
|
||||
$this->setSettings(['forgot_password' => true]);
|
||||
|
||||
visit('/login')->assertSee('I forgot my password');
|
||||
});
|
||||
Reference in New Issue
Block a user