Changeset View
Changeset View
Standalone View
Standalone View
src/tests/Browser/SignupTest.php
Show First 20 Lines • Show All 68 Lines • ▼ Show 20 Lines | public function testSignupCodeByLink(): void | ||||
->assertToast(Toast::TYPE_ERROR, 'Form validation error'); | ->assertToast(Toast::TYPE_ERROR, 'Form validation error'); | ||||
}); | }); | ||||
// Test valid code | // Test valid code | ||||
$this->browse(function (Browser $browser) { | $this->browse(function (Browser $browser) { | ||||
$code = SignupCode::create([ | $code = SignupCode::create([ | ||||
'data' => [ | 'data' => [ | ||||
'email' => 'User@example.org', | 'email' => 'User@example.org', | ||||
'name' => 'User Name', | 'first_name' => 'User', | ||||
'last_name' => 'Name', | |||||
'plan' => 'individual', | 'plan' => 'individual', | ||||
'voucher' => '', | 'voucher' => '', | ||||
] | ] | ||||
]); | ]); | ||||
$browser->visit('/signup/' . $code->short_code . '-' . $code->code) | $browser->visit('/signup/' . $code->short_code . '-' . $code->code) | ||||
->waitFor('@step3') | ->waitFor('@step3') | ||||
->assertMissing('@step1') | ->assertMissing('@step1') | ||||
Show All 34 Lines | public function testSignupStep0(): void | ||||
->click('button'); | ->click('button'); | ||||
}); | }); | ||||
$browser->waitForLocation('/signup/individual') | $browser->waitForLocation('/signup/individual') | ||||
->assertVisible('@step1') | ->assertVisible('@step1') | ||||
->assertMissing('@step0') | ->assertMissing('@step0') | ||||
->assertMissing('@step2') | ->assertMissing('@step2') | ||||
->assertMissing('@step3') | ->assertMissing('@step3') | ||||
->assertFocused('@step1 #signup_name'); | ->assertFocused('@step1 #signup_first_name'); | ||||
// Click Back button | // Click Back button | ||||
$browser->click('@step1 [type=button]') | $browser->click('@step1 [type=button]') | ||||
->waitForLocation('/signup') | ->waitForLocation('/signup') | ||||
->assertVisible('@step0') | ->assertVisible('@step0') | ||||
->assertMissing('@step1') | ->assertMissing('@step1') | ||||
->assertMissing('@step2') | ->assertMissing('@step2') | ||||
->assertMissing('@step3'); | ->assertMissing('@step3'); | ||||
// Choose the group account plan | // Choose the group account plan | ||||
$browser->click('@step0 .plan-selector > .plan-group button') | $browser->click('@step0 .plan-selector > .plan-group button') | ||||
->waitForLocation('/signup/group') | ->waitForLocation('/signup/group') | ||||
->assertVisible('@step1') | ->assertVisible('@step1') | ||||
->assertMissing('@step0') | ->assertMissing('@step0') | ||||
->assertMissing('@step2') | ->assertMissing('@step2') | ||||
->assertMissing('@step3') | ->assertMissing('@step3') | ||||
->assertFocused('@step1 #signup_name'); | ->assertFocused('@step1 #signup_first_name'); | ||||
// TODO: Test if 'plan' variable is set properly in vue component | // TODO: Test if 'plan' variable is set properly in vue component | ||||
}); | }); | ||||
} | } | ||||
/** | /** | ||||
* 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->assertVisible('@step1'); | ||||
$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']); | ||||
$browser->assertActiveItem('signup'); | $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_name') | $step->assertVisible('#signup_last_name') | ||||
->assertFocused('#signup_name') | ->assertVisible('#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 | ||||
// Both Step 1 inputs are required, so after pressing Submit | // Email is required, so after pressing Submit | ||||
// we expect focus to be moved to the first 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_name'); | $step->assertFocused('#signup_email'); | ||||
}); | }); | ||||
// Submit invalid email | // Submit invalid email, and first_name | ||||
// We expect email input 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_name', 'Test User') | $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_email + .invalid-feedback') | ->assertVisible('#signup_email + .invalid-feedback') | ||||
->assertVisible('#signup_last_name + .invalid-feedback') | |||||
->assertToast(Toast::TYPE_ERROR, 'Form validation error'); | ->assertToast(Toast::TYPE_ERROR, 'Form validation error'); | ||||
}); | }); | ||||
// Submit valid data | // Submit valid data | ||||
// We expect error state on email input to be removed, and Step 2 form visible | // We expect error state on email input to be removed, and Step 2 form visible | ||||
$browser->with('@step1', function ($step) { | $browser->with('@step1', function ($step) { | ||||
$step->type('#signup_name', 'Test User'); | $step->type('#signup_first_name', 'Test') | ||||
$step->type('#signup_email', 'BrowserSignupTestUser1@kolab.org'); | ->type('#signup_last_name', 'User') | ||||
$step->click('[type=submit]'); | ->type('#signup_email', 'BrowserSignupTestUser1@kolab.org') | ||||
->click('[type=submit]') | |||||
$step->assertMissing('#signup_email.is-invalid'); | ->assertMissing('#signup_email.is-invalid') | ||||
$step->assertMissing('#signup_email + .invalid-feedback'); | ->assertMissing('#signup_email + .invalid-feedback'); | ||||
}); | }); | ||||
$browser->waitUntilMissing('@step2 #signup_code[value=""]'); | $browser->waitUntilMissing('@step2 #signup_code[value=""]'); | ||||
$browser->waitFor('@step2'); | $browser->waitFor('@step2'); | ||||
$browser->assertMissing('@step1'); | $browser->assertMissing('@step1'); | ||||
}); | }); | ||||
} | } | ||||
Show All 16 Lines | public function testSignupStep2(): void | ||||
->assertFocused('#signup_short_code') | ->assertFocused('#signup_short_code') | ||||
->assertVisible('[type=button]') | ->assertVisible('[type=button]') | ||||
->assertVisible('[type=submit]'); | ->assertVisible('[type=submit]'); | ||||
}); | }); | ||||
// Test Back button functionality | // Test Back button functionality | ||||
$browser->click('@step2 [type=button]') | $browser->click('@step2 [type=button]') | ||||
->waitFor('@step1') | ->waitFor('@step1') | ||||
->assertFocused('@step1 #signup_name') | ->assertFocused('@step1 #signup_first_name') | ||||
->assertMissing('@step2'); | ->assertMissing('@step2'); | ||||
// Submit valid Step 1 data (again) | // Submit valid Step 1 data (again) | ||||
$browser->with('@step1', function ($step) { | $browser->with('@step1', function ($step) { | ||||
$step->type('#signup_name', 'Test User'); | $step->type('#signup_first_name', 'User') | ||||
$step->type('#signup_email', 'BrowserSignupTestUser1@kolab.org'); | ->type('#signup_last_name', 'User') | ||||
$step->click('[type=submit]'); | ->type('#signup_email', 'BrowserSignupTestUser1@kolab.org') | ||||
->click('[type=submit]'); | |||||
}); | }); | ||||
$browser->waitFor('@step2'); | $browser->waitFor('@step2'); | ||||
$browser->assertMissing('@step1'); | $browser->assertMissing('@step1'); | ||||
// Submit invalid code | // Submit invalid code | ||||
// We expect code input to have is-invalid class added, with .invalid-feedback element | // We expect code input to have is-invalid class added, with .invalid-feedback element | ||||
$browser->with('@step2', function ($step) use ($browser) { | $browser->with('@step2', function ($step) use ($browser) { | ||||
▲ Show 20 Lines • Show All 133 Lines • ▼ Show 20 Lines | public function testSignupGroup(): void | ||||
// Choose the group account plan | // Choose the group account plan | ||||
$browser->waitFor('@step0 .plan-group button') | $browser->waitFor('@step0 .plan-group button') | ||||
->click('@step0 .plan-group button'); | ->click('@step0 .plan-group button'); | ||||
// Submit valid data | // Submit valid data | ||||
// We expect error state on email input to be removed, and Step 2 form visible | // We expect error state on email input to be removed, and Step 2 form visible | ||||
$browser->whenAvailable('@step1', function ($step) { | $browser->whenAvailable('@step1', function ($step) { | ||||
$step->type('#signup_name', 'Test User') | $step->type('#signup_first_name', 'Test') | ||||
->type('#signup_last_name', 'User') | |||||
->type('#signup_email', 'BrowserSignupTestUser1@kolab.org') | ->type('#signup_email', 'BrowserSignupTestUser1@kolab.org') | ||||
->click('[type=submit]'); | ->click('[type=submit]'); | ||||
}); | }); | ||||
// Submit valid code | // Submit valid code | ||||
$browser->whenAvailable('@step2', function ($step) { | $browser->whenAvailable('@step2', function ($step) { | ||||
// Get the code and short_code from database | // Get the code and short_code from database | ||||
// FIXME: Find a nice way to read javascript data without using hidden inputs | // FIXME: Find a nice way to read javascript data without using hidden inputs | ||||
▲ Show 20 Lines • Show All 72 Lines • ▼ Show 20 Lines | class SignupTest extends TestCaseDusk | ||||
public function testSignupVoucherLink(): void | public function testSignupVoucherLink(): void | ||||
{ | { | ||||
$this->browse(function (Browser $browser) { | $this->browse(function (Browser $browser) { | ||||
$browser->visit('/signup/voucher/TEST') | $browser->visit('/signup/voucher/TEST') | ||||
->onWithoutAssert(new Signup()) | ->onWithoutAssert(new Signup()) | ||||
->waitFor('@step0') | ->waitFor('@step0') | ||||
->click('.plan-individual button') | ->click('.plan-individual button') | ||||
->whenAvailable('@step1', function (Browser $browser) { | ->whenAvailable('@step1', function (Browser $browser) { | ||||
$browser->type('#signup_name', 'Test User') | $browser->type('#signup_first_name', 'Test') | ||||
->type('#signup_last_name', 'User') | |||||
->type('#signup_email', 'BrowserSignupTestUser1@kolab.org') | ->type('#signup_email', 'BrowserSignupTestUser1@kolab.org') | ||||
->click('[type=submit]'); | ->click('[type=submit]'); | ||||
}) | }) | ||||
->whenAvailable('@step2', function (Browser $browser) { | ->whenAvailable('@step2', function (Browser $browser) { | ||||
// Get the code and short_code from database | // Get the code and short_code from database | ||||
// FIXME: Find a nice way to read javascript data without using hidden inputs | // FIXME: Find a nice way to read javascript data without using hidden inputs | ||||
$code = $browser->value('#signup_code'); | $code = $browser->value('#signup_code'); | ||||
Show All 37 Lines |