Changeset View
Changeset View
Standalone View
Standalone View
src/tests/Browser/SignupTest.php
Show First 20 Lines • Show All 101 Lines • ▼ Show 20 Lines | public function testSignupStep0(): void | ||||
$browser->visit(new Signup()); | $browser->visit(new Signup()); | ||||
$browser->assertVisible('@step0') | $browser->assertVisible('@step0') | ||||
->assertMissing('@step1') | ->assertMissing('@step1') | ||||
->assertMissing('@step2') | ->assertMissing('@step2') | ||||
->assertMissing('@step3'); | ->assertMissing('@step3'); | ||||
$browser->within(new Menu(), function ($browser) { | $browser->within(new Menu(), function ($browser) { | ||||
$browser->assertMenuItems(['signup', 'explore', 'blog', 'support', 'login']); | $browser->assertMenuItems(['signup', 'explore', 'blog', 'support', 'login'], 'signup'); | ||||
$browser->assertActiveItem('signup'); | |||||
}); | }); | ||||
$browser->waitFor('@step0 .plan-selector > .plan-box'); | $browser->waitFor('@step0 .plan-selector > .plan-box'); | ||||
// Assert first plan box and press the button | // Assert first plan box and press the button | ||||
$browser->with('@step0 .plan-selector > .plan-individual', function ($step) { | $browser->with('@step0 .plan-selector > .plan-individual', function ($step) { | ||||
$step->assertVisible('button') | $step->assertVisible('button') | ||||
->assertSeeIn('button', 'Individual Account') | ->assertSeeIn('button', 'Individual Account') | ||||
Show All 30 Lines | class SignupTest extends TestCaseDusk | ||||
} | } | ||||
/** | /** | ||||
* Test 1st step of the signup process | * Test 1st step of the signup process | ||||
*/ | */ | ||||
public function testSignupStep1(): void | public function testSignupStep1(): void | ||||
{ | { | ||||
$this->browse(function (Browser $browser) { | $this->browse(function (Browser $browser) { | ||||
$browser->visit('/signup/individual')->onWithoutAssert(new Signup()); | $browser->visit('/signup/individual') | ||||
->onWithoutAssert(new Signup()); | |||||
$browser->assertVisible('@step1'); | |||||
$browser->within(new Menu(), function ($browser) { | |||||
$browser->assertMenuItems(['signup', 'explore', 'blog', 'support', 'login']); | |||||
$browser->assertActiveItem('signup'); | |||||
}); | |||||
// Here we expect two text inputs and Back and Continue buttons | // Here we expect two text inputs and Back and Continue buttons | ||||
$browser->with('@step1', function ($step) { | $browser->with('@step1', function ($step) { | ||||
$step->assertVisible('#signup_last_name') | $step->assertVisible('#signup_last_name') | ||||
->assertVisible('#signup_first_name') | ->assertVisible('#signup_first_name') | ||||
->assertFocused('#signup_first_name') | ->assertFocused('#signup_first_name') | ||||
->assertVisible('#signup_email') | ->assertVisible('#signup_email') | ||||
->assertVisible('[type=button]') | ->assertVisible('[type=button]') | ||||
->assertVisible('[type=submit]'); | ->assertVisible('[type=submit]'); | ||||
}); | }); | ||||
// Submit empty form | // Submit empty form | ||||
// Email is required, so after pressing Submit | // Email is required, so after pressing Submit | ||||
// we expect focus to be moved to the email input | // we expect focus to be moved to the email input | ||||
$browser->with('@step1', function ($step) { | $browser->with('@step1', function ($step) { | ||||
$step->click('[type=submit]'); | $step->click('[type=submit]'); | ||||
$step->assertFocused('#signup_email'); | $step->assertFocused('#signup_email'); | ||||
}); | }); | ||||
$browser->within(new Menu(), function ($browser) { | |||||
$browser->assertMenuItems(['signup', 'explore', 'blog', 'support', 'login'], 'signup'); | |||||
}); | |||||
// Submit invalid email, and first_name | // Submit invalid email, and first_name | ||||
// We expect both inputs to have is-invalid class added, with .invalid-feedback element | // We expect both inputs to have is-invalid class added, with .invalid-feedback element | ||||
$browser->with('@step1', function ($step) use ($browser) { | $browser->with('@step1', function ($step) use ($browser) { | ||||
$step->type('#signup_first_name', str_repeat('a', 250)) | $step->type('#signup_first_name', str_repeat('a', 250)) | ||||
->type('#signup_email', '@test') | ->type('#signup_email', '@test') | ||||
->click('[type=submit]') | ->click('[type=submit]') | ||||
->waitFor('#signup_email.is-invalid') | ->waitFor('#signup_email.is-invalid') | ||||
->assertVisible('#signup_first_name.is-invalid') | ->assertVisible('#signup_first_name.is-invalid') | ||||
▲ Show 20 Lines • Show All 177 Lines • ▼ Show 20 Lines | public function testSignupStep3(): void | ||||
// At this point we should be auto-logged-in to dashboard | // At this point we should be auto-logged-in to dashboard | ||||
$browser->waitUntilMissing('@step3') | $browser->waitUntilMissing('@step3') | ||||
->waitUntilMissing('.app-loader') | ->waitUntilMissing('.app-loader') | ||||
->on(new Dashboard()) | ->on(new Dashboard()) | ||||
->assertUser('signuptestdusk@' . \config('app.domain')); | ->assertUser('signuptestdusk@' . \config('app.domain')); | ||||
// Logout the user | // Logout the user | ||||
$browser->click('a.link-logout'); | $browser->within(new Menu(), function ($browser) { | ||||
$browser->clickMenuItem('logout'); | |||||
}); | |||||
}); | }); | ||||
} | } | ||||
/** | /** | ||||
* Test signup for a group account | * Test signup for a group account | ||||
*/ | */ | ||||
public function testSignupGroup(): void | public function testSignupGroup(): void | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 77 Lines • ▼ Show 20 Lines | public function testSignupGroup(): void | ||||
}); | }); | ||||
// At this point we should be auto-logged-in to dashboard | // At this point we should be auto-logged-in to dashboard | ||||
$browser->waitUntilMissing('@step3') | $browser->waitUntilMissing('@step3') | ||||
->waitUntilMissing('.app-loader') | ->waitUntilMissing('.app-loader') | ||||
->on(new Dashboard()) | ->on(new Dashboard()) | ||||
->assertUser('admin@user-domain-signup.com'); | ->assertUser('admin@user-domain-signup.com'); | ||||
$browser->click('a.link-logout'); | $browser->within(new Menu(), function ($browser) { | ||||
$browser->clickMenuItem('logout'); | |||||
}); | |||||
}); | }); | ||||
} | } | ||||
/** | /** | ||||
* Test signup with voucher | * Test signup with voucher | ||||
*/ | */ | ||||
public function testSignupVoucherLink(): void | public function testSignupVoucherLink(): void | ||||
{ | { | ||||
Show All 37 Lines | public function testSignupVoucherLink(): void | ||||
->type('#signup_voucher', 'TEST') | ->type('#signup_voucher', 'TEST') | ||||
->click('[type=submit]'); | ->click('[type=submit]'); | ||||
}) | }) | ||||
->waitUntilMissing('@step3') | ->waitUntilMissing('@step3') | ||||
->waitUntilMissing('.app-loader') | ->waitUntilMissing('.app-loader') | ||||
->on(new Dashboard()) | ->on(new Dashboard()) | ||||
->assertUser('signuptestdusk@' . \config('app.domain')) | ->assertUser('signuptestdusk@' . \config('app.domain')) | ||||
// Logout the user | // Logout the user | ||||
->click('a.link-logout'); | ->within(new Menu(), function ($browser) { | ||||
$browser->clickMenuItem('logout'); | |||||
}); | |||||
}); | }); | ||||
$user = $this->getTestUser('signuptestdusk@' . \config('app.domain')); | $user = $this->getTestUser('signuptestdusk@' . \config('app.domain')); | ||||
$discount = Discount::where('code', 'TEST')->first(); | $discount = Discount::where('code', 'TEST')->first(); | ||||
$this->assertSame($discount->id, $user->wallets()->first()->discount_id); | $this->assertSame($discount->id, $user->wallets()->first()->discount_id); | ||||
} | } | ||||
} | } |