/** @test */
public function user_can_place_an_order()
{
$this->browse(function (Browser $browser) {
$browser->loginAs( User::find(1) )
->visit( new ChangeAddress )
->fillInEditAddressForm(
'10 Example Street', 'New York City', 'New York',
'10 Example Street', 'New York City', 'New York')
->clickLink('Home')
->click('@restaurant-card')
->clickLink('Shop')
->click('@dish-card')
->click('button[type="submit"]')
->assertSee('1 item in cart')
->clickLink('Checkout')
->assertSee('Confirm Password')
->type('password', User::find(1));
// To be continued...
});
}
As you can see I login with the loginAs method. At some point, I reach a password confirmation screen and have to type the password. Of course I know the password, but don't want to type it in my code willy-nilly since my code is going onto Github. Best method to deal with passwords using Dusk?
I'm not 100% sure what's wrong with my setup. I've confirmed manually that my authentication works. It's just that Dusk keeps spouting "these credentials do not match our records" when I'm trying to login a user.
@aoletom1 Sounds like the user doesn't exist in the Dusk database. Are you using DatabaseMigrations and do you have a setUp method to run your database seed? And you're using a separate Dusk database in env.dusk.local? I'll post some of my code in case it helps.
namespace Tests\Browser;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use Laravel\Dusk\Browser;
use Tests\DuskTestCase;
use App\User;
class OrderTest extends DuskTestCase
{
use DatabaseMigrations;
public function setUp(): void
{
parent::setUp();
$this->artisan('db:seed');
}
// Tests...
}