2025-12-28 20:18:27 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
use App\Models\Planner;
|
2025-12-29 23:36:15 +01:00
|
|
|
use Illuminate\Support\Facades\Hash;
|
2025-12-29 17:38:37 +01:00
|
|
|
|
2026-08-19 02:09:42 +02:00
|
|
|
it('logs in successfully', function () {
|
|
|
|
|
$planner = Planner::factory()->create([
|
|
|
|
|
'password' => Hash::make('password'),
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
visit('/login')
|
|
|
|
|
->type('input[id="email"]', $planner->email)
|
|
|
|
|
->type('input[id="password"]', 'password')
|
|
|
|
|
->press('Sign In')
|
|
|
|
|
->assertPathIs('/dashboard');
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('rejects wrong credentials', function () {
|
|
|
|
|
$planner = Planner::factory()->create([
|
|
|
|
|
'password' => Hash::make('password'),
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
visit('/login')
|
|
|
|
|
->type('input[id="email"]', $planner->email)
|
|
|
|
|
->type('input[id="password"]', 'wrong-password')
|
|
|
|
|
->press('Sign In')
|
|
|
|
|
->assertPathIs('/login')
|
|
|
|
|
->assertSee('These credentials do not match our records');
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('requires the email and password fields', function () {
|
|
|
|
|
visit('/login')
|
|
|
|
|
->assertScript("document.querySelector('input[id=\"email\"]').required")
|
|
|
|
|
->assertScript("document.querySelector('input[id=\"password\"]').required")
|
|
|
|
|
->assertAttribute('input[id="email"]', 'type', 'email')
|
|
|
|
|
->assertAttribute('input[id="password"]', 'type', 'password')
|
|
|
|
|
->press('Sign In')
|
|
|
|
|
->assertPathIs('/login');
|
|
|
|
|
});
|