File: D:/HostingSpaces/SBogers95/rentman.io/tests/Browser/UserSearchTest.php
<?php
namespace Tests\Browser;
use App\Komma\Users\Models\User;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Laravel\Dusk\Browser;
use Tests\Browser\Pages\UsersSectionTestPage;
use Tests\DuskTestCase;
class UserSearchTest extends DuskTestCase
{
use DatabaseTransactions; //Automatically rolls back database actions after tests
/**
* @group UserTest
* @test
*/
public function testSidebarUserSearchByEmail()
{
$randomUser = factory(User::class, 1)->make()->first();
$counter = 0;
$this->browse(function (Browser $browser) use ($randomUser, $counter) {
$browser->loginAs(User::find(1))
->visit(new UsersSectionTestPage)
->screenshot($this->getName().'_customers_screen_'.$counter++)
->assertSee(__('kms/users.section.subtitle'))
->click('@addButton')
->screenshot($this->getName().'_customers_screen_'.$counter++)
->type('@userNameField', $randomUser->username)
->type('@firstNameField', $randomUser->first_name)
->type('@lastNameField', $randomUser->last_name)
->type('@emailField', $randomUser->email)
->type('@passwordField', 'Admin123')
->type('@passwordConfirmationField', 'Admin123')
->screenshot($this->getName())
->click('@saveButton')
//Visit the users page again and save the user without making changes. This must not change the password and still enable the user to login
->visit(new UsersSectionTestPage())
->screenshot($this->getName())
->assertSee(__('kms/users.section.subtitle'))
->type('@searchInput', $randomUser->email)
->screenshot($this->getName(false).'-'.++$counter)
->assertSeeIn('#search-result-counter', '1')
->click('#users-searchlist > li.entities-list-item.active > a')
->screenshot($this->getName(false).'-'.++$counter)
->assertSeeIn('#entity > div.entity-header > div.entity-header-attributes > h2', $randomUser->first_name.' '.$randomUser->last_name)
->screenshot($this->getName(false).'-'.'reopened');
});
}
}