first commit

This commit is contained in:
benjibennn
2023-12-22 12:35:55 +08:00
commit 9f89a732d6
872 changed files with 156291 additions and 0 deletions

View 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.');
});
}
}

View 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');
});
}
}

View 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',
];
}
}

View 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',
];
}
}

View 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');
});
}
}

File diff suppressed because one or more lines are too long

2
tests/Browser/console/.gitignore vendored Normal file
View File

@@ -0,0 +1,2 @@
*
!.gitignore

2
tests/Browser/screenshots/.gitignore vendored Normal file
View File

@@ -0,0 +1,2 @@
*
!.gitignore