102 - QA Testing the Login Flow

This commit is contained in:
Adam Wathan
2017-05-02 16:02:45 -04:00
parent 41fbdcae1a
commit 54d054214f
3 changed files with 48 additions and 27 deletions

View File

@@ -11,10 +11,6 @@
|
*/
Route::get('/', function () {
return "Laravel";
});
Route::get('/concerts/{id}', 'ConcertsController@show');
Route::post('/concerts/{id}/orders', 'ConcertOrdersController@store');
Route::get('/orders/{confirmationNumber}', 'OrdersController@show');

View File

@@ -1,23 +0,0 @@
<?php
namespace Tests\Browser;
use Tests\DuskTestCase;
use Laravel\Dusk\Browser;
use Illuminate\Foundation\Testing\DatabaseMigrations;
class ExampleTest extends DuskTestCase
{
/**
* A basic browser test example.
*
* @return void
*/
public function testBasicExample()
{
$this->browse(function (Browser $browser) {
$browser->visit('/')
->assertSee('Laravel');
});
}
}

View File

@@ -0,0 +1,48 @@
<?php
namespace Tests\Browser;
use App\User;
use Tests\DuskTestCase;
use Laravel\Dusk\Browser;
use Illuminate\Foundation\Testing\DatabaseMigrations;
class PromoterLoginTest extends DuskTestCase
{
use DatabaseMigrations;
/** @test */
public function logging_in_successfully()
{
$user = factory(User::class)->create([
'email' => 'jane@example.com',
'password' => bcrypt('super-secret-password'),
]);
$this->browse(function (Browser $browser) {
$browser->visit('/login')
->type('email', 'jane@example.com')
->type('password', 'super-secret-password')
->press('Log in')
->assertPathIs('/backstage/concerts');
});
}
/** @test */
public function logging_in_with_invalid_credentials()
{
$user = factory(User::class)->create([
'email' => 'jane@example.com',
'password' => bcrypt('super-secret-password'),
]);
$this->browse(function (Browser $browser) {
$browser->visit('/login')
->type('email', 'jane@example.com')
->type('password', 'wrong-password')
->press('Log in')
->assertPathIs('/login')
->assertSee('credentials do not match');
});
}
}