This repository has been archived on 2024-05-20. You can view files and clone it, but cannot push or open issues or pull requests.
PriceyBotPanel/tests/Feature/Auth/AuthenticationTest.php

74 lines
1.6 KiB
PHP

<?php
use App\Models\User;
use App\Providers\RouteServiceProvider;
use Livewire\Volt\Volt;
test('login screen can be rendered', function () {
$response = $this->get('/login');
$response
->assertSeeVolt('pages.auth.login')
->assertOk();
});
test('users can authenticate using the login screen', function () {
$user = User::factory()->create();
$component = Volt::test('pages.auth.login')
->set('email', $user->email)
->set('password', 'password');
$component->call('login');
$component
->assertHasNoErrors()
->assertRedirect(RouteServiceProvider::HOME);
$this->assertAuthenticated();
});
test('users can not authenticate with invalid password', function () {
$user = User::factory()->create();
$component = Volt::test('pages.auth.login')
->set('email', $user->email)
->set('password', 'wrong-password');
$component->call('login');
$component
->assertHasErrors()
->assertNoRedirect();
$this->assertGuest();
});
test('navigation menu can be rendered', function () {
$user = User::factory()->create();
$this->actingAs($user);
$response = $this->get('/dashboard');
$response
->assertSeeVolt('layout.navigation')
->assertOk();
});
test('users can logout', function () {
$user = User::factory()->create();
$this->actingAs($user);
$component = Volt::test('layout.navigation');
$component->call('logout');
$component
->assertHasNoErrors()
->assertRedirect('/');
$this->assertGuest();
});