- {{ trans('simplecrm.sign_out') }} -
+{{ trans('simplecrm.sign_out') }}
diff --git a/tests/Browser/Auth/LoginTest.php b/tests/Browser/Auth/LoginTest.php new file mode 100644 index 0000000..6b776b7 --- /dev/null +++ b/tests/Browser/Auth/LoginTest.php @@ -0,0 +1,32 @@ +browse(function (Browser $browser) { + // Create new user + $user = User::factory()->create([ + 'email' => 'admin@admin.com' + ]); + + // Begin test + $browser->visit('/login') + ->type('email', $user->email) + ->type('password', 'password') + ->press(trans('simplecrm.sign_in')) + ->click('a[href="' . route('logout') . '"]') + ->visit('/admin') + ->assertPathIs('/login'); + }); + } +} diff --git a/tests/Browser/CompanyTest.php b/tests/Browser/CompanyTest.php new file mode 100644 index 0000000..3bf7b1b --- /dev/null +++ b/tests/Browser/CompanyTest.php @@ -0,0 +1,26 @@ +create([ + 'email' => 'admin@admin.com' + ]); + + $this->browse(function (Browser $browser) use ($user) { + $browser->loginAs($user) + ->visit(route('admin.company.index')) + ->assertRouteIs('admin.company.index'); + }); + } +} diff --git a/tests/Browser/EmployeeTest.php b/tests/Browser/EmployeeTest.php new file mode 100644 index 0000000..5432b9c --- /dev/null +++ b/tests/Browser/EmployeeTest.php @@ -0,0 +1,26 @@ +create([ + 'email' => 'admin@admin.com' + ]); + + $this->browse(function (Browser $browser) use ($user) { + $browser->loginAs($user) + ->visit(route('admin.employee.index')) + ->assertRouteIs('admin.employee.index'); + }); + } +} diff --git a/tests/Browser/ExampleTest.php b/tests/Browser/ExampleTest.php new file mode 100644 index 0000000..9d8968b --- /dev/null +++ b/tests/Browser/ExampleTest.php @@ -0,0 +1,23 @@ +browse(function (Browser $browser) { + $browser->visit('/') + ->assertSee('Laravel'); + }); + } +} diff --git a/tests/Browser/Pages/HomePage.php b/tests/Browser/Pages/HomePage.php new file mode 100644 index 0000000..26bf174 --- /dev/null +++ b/tests/Browser/Pages/HomePage.php @@ -0,0 +1,41 @@ + '#selector', + ]; + } +} diff --git a/tests/Browser/Pages/Page.php b/tests/Browser/Pages/Page.php new file mode 100644 index 0000000..f8d7622 --- /dev/null +++ b/tests/Browser/Pages/Page.php @@ -0,0 +1,20 @@ + '#selector', + ]; + } +} diff --git a/tests/DuskTestCase.php b/tests/DuskTestCase.php new file mode 100644 index 0000000..808af69 --- /dev/null +++ b/tests/DuskTestCase.php @@ -0,0 +1,61 @@ +addArguments(collect([ + '--window-size=1920,1080', + ])->unless($this->hasHeadlessDisabled(), function ($items) { + return $items->merge([ + '--disable-gpu', + '--headless', + ]); + })->all()); + + return RemoteWebDriver::create( + $_ENV['DUSK_DRIVER_URL'] ?? 'http://localhost:9515', + DesiredCapabilities::chrome()->setCapability( + ChromeOptions::CAPABILITY, $options + ) + ); + } + + /** + * Determine whether the Dusk command has disabled headless mode. + * + * @return bool + */ + protected function hasHeadlessDisabled() + { + return isset($_SERVER['DUSK_HEADLESS_DISABLED']) || + isset($_ENV['DUSK_HEADLESS_DISABLED']); + } +} diff --git a/tests/Feature/Auth/RegisterTest.php b/tests/Feature/Auth/RegisterTest.php new file mode 100644 index 0000000..c9d8c13 --- /dev/null +++ b/tests/Feature/Auth/RegisterTest.php @@ -0,0 +1,17 @@ +get('/register'); + + $response->assertStatus(404); + } +} diff --git a/tests/TestCase.php b/tests/TestCase.php index 2932d4a..5a8da7e 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -3,8 +3,16 @@ namespace Tests; use Illuminate\Foundation\Testing\TestCase as BaseTestCase; +use App\Models\User; abstract class TestCase extends BaseTestCase { use CreatesApplication; + + protected function signIn($user = null) + { + $user = $user ?? User::factory()->create(); + $this->actingAs($user); + return $this; + } }