first commit
This commit is contained in:
68
tests/Browser/AuthTest.php
Normal file
68
tests/Browser/AuthTest.php
Normal file
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Browser;
|
||||
|
||||
use App\Models\User;
|
||||
use Tests\DuskTestCase;
|
||||
use Laravel\Dusk\Browser;
|
||||
|
||||
class AuthTest extends DuskTestCase
|
||||
{
|
||||
//use DatabaseMigrations;
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
// $this->artisan('db:seed');
|
||||
}
|
||||
/**
|
||||
* A Dusk test example.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testSignup()
|
||||
{
|
||||
$this->browse(function (Browser $browser) {
|
||||
|
||||
User::where('email', '=', 'scoobydoo@gmail.com')->first()->delete();
|
||||
|
||||
$browser->visit('/')
|
||||
->clickLink('Sign Up')
|
||||
->assertPathIs('/register')
|
||||
->type('name', 'Scooby Doo')
|
||||
->type('username', 'scoobydoo')
|
||||
->type('email', 'scoobydoo@gmail.com')
|
||||
->type('password', 'password123')
|
||||
->type('password_confirmation', 'password123')
|
||||
->click('button[type="submit"]')
|
||||
->waitForText('Thanks for signing up!')
|
||||
->assertSee('Thanks for signing up!');
|
||||
});
|
||||
}
|
||||
|
||||
public function testLogout()
|
||||
{
|
||||
$this->browse(function (Browser $browser) {
|
||||
$browser->loginAs(User::where('email', '=', 'scoobydoo@gmail.com')->first())
|
||||
->visit('/dashboard')
|
||||
->mouseover('.user-icon')
|
||||
->waitForText('Logout')
|
||||
->clickLink('Logout')
|
||||
->assertPathIs('/');
|
||||
});
|
||||
}
|
||||
|
||||
public function testLogin()
|
||||
{
|
||||
$this->browse(function (Browser $browser) {
|
||||
$browser->visit('/')
|
||||
->clickLink('Login')
|
||||
->assertPathIs('/login')
|
||||
->type('email', 'scoobydoo@gmail.com')
|
||||
->type('password', 'password123')
|
||||
->click('button[type="submit"]')
|
||||
->waitForText('Successfully logged in.')
|
||||
->assertSee('Successfully logged in.');
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
32
tests/Browser/HomePageTest.php
Normal file
32
tests/Browser/HomePageTest.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Browser;
|
||||
|
||||
use Tests\DuskTestCase;
|
||||
use Laravel\Dusk\Browser;
|
||||
use Illuminate\Foundation\Testing\DatabaseMigrations;
|
||||
|
||||
class HomePageTest extends DuskTestCase
|
||||
{
|
||||
//use DatabaseMigrations;
|
||||
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
//$this->artisan('db:seed');
|
||||
}
|
||||
|
||||
/**
|
||||
* A Dusk test example.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testText()
|
||||
{
|
||||
$this->browse(function (Browser $browser) {
|
||||
$browser->visit('/') //->dump()
|
||||
->waitForText('Wave is the perfect starter kit')
|
||||
->assertSeeIn('h2', 'Wave is the perfect starter kit');
|
||||
});
|
||||
}
|
||||
}
|
||||
41
tests/Browser/Pages/HomePage.php
Normal file
41
tests/Browser/Pages/HomePage.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Browser\Pages;
|
||||
|
||||
use Laravel\Dusk\Browser;
|
||||
|
||||
class HomePage extends Page
|
||||
{
|
||||
/**
|
||||
* Get the URL for the page.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function url()
|
||||
{
|
||||
return '/';
|
||||
}
|
||||
|
||||
/**
|
||||
* Assert that the browser is on the page.
|
||||
*
|
||||
* @param \Laravel\Dusk\Browser $browser
|
||||
* @return void
|
||||
*/
|
||||
public function assert(Browser $browser)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the element shortcuts for the page.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function elements()
|
||||
{
|
||||
return [
|
||||
'@element' => '#selector',
|
||||
];
|
||||
}
|
||||
}
|
||||
20
tests/Browser/Pages/Page.php
Normal file
20
tests/Browser/Pages/Page.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Browser\Pages;
|
||||
|
||||
use Laravel\Dusk\Page as BasePage;
|
||||
|
||||
abstract class Page extends BasePage
|
||||
{
|
||||
/**
|
||||
* Get the global element shortcuts for the site.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function siteElements()
|
||||
{
|
||||
return [
|
||||
'@element' => '#selector',
|
||||
];
|
||||
}
|
||||
}
|
||||
26
tests/Browser/UserProfileTest.php
Normal file
26
tests/Browser/UserProfileTest.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Browser;
|
||||
|
||||
use App\Models\User;
|
||||
use Tests\DuskTestCase;
|
||||
use Laravel\Dusk\Browser;
|
||||
use Illuminate\Foundation\Testing\DatabaseMigrations;
|
||||
|
||||
class UserProfileTest extends DuskTestCase
|
||||
{
|
||||
/**
|
||||
* A Dusk test example.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testProfilePage()
|
||||
{
|
||||
$this->browse(function (Browser $browser) {
|
||||
$browser->loginAs(User::where('email', '=', 'scoobydoo@gmail.com')->first())
|
||||
->visit('/@scoobydoo')
|
||||
->assertSee('Scooby Doo');
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
25
tests/Browser/UserProfileUpdateTest.php
Normal file
25
tests/Browser/UserProfileUpdateTest.php
Normal file
File diff suppressed because one or more lines are too long
2
tests/Browser/console/.gitignore
vendored
Normal file
2
tests/Browser/console/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
*
|
||||
!.gitignore
|
||||
2
tests/Browser/screenshots/.gitignore
vendored
Normal file
2
tests/Browser/screenshots/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
*
|
||||
!.gitignore
|
||||
Reference in New Issue
Block a user