Changeset View
Changeset View
Standalone View
Standalone View
src/tests/Browser/UserProfileTest.php
Show All 15 Lines | class UserProfileTest extends TestCaseDusk | ||||
private $profile = [ | private $profile = [ | ||||
'first_name' => 'John', | 'first_name' => 'John', | ||||
'last_name' => 'Doe', | 'last_name' => 'Doe', | ||||
'currency' => 'USD', | 'currency' => 'USD', | ||||
'country' => 'US', | 'country' => 'US', | ||||
'billing_address' => "601 13th Street NW\nSuite 900 South\nWashington, DC 20005", | 'billing_address' => "601 13th Street NW\nSuite 900 South\nWashington, DC 20005", | ||||
'external_email' => 'john.doe.external@gmail.com', | 'external_email' => 'john.doe.external@gmail.com', | ||||
'phone' => '+1 509-248-1111', | 'phone' => '+1 509-248-1111', | ||||
'organization' => 'Kolab Developers', | |||||
]; | ]; | ||||
/** | /** | ||||
* {@inheritDoc} | * {@inheritDoc} | ||||
*/ | */ | ||||
public function setUp(): void | public function setUp(): void | ||||
{ | { | ||||
parent::setUp(); | parent::setUp(); | ||||
Show All 39 Lines | public function testProfile(): void | ||||
->assertSeeIn('#user-profile .button-delete', 'Delete account') | ->assertSeeIn('#user-profile .button-delete', 'Delete account') | ||||
->whenAvailable('@form', function (Browser $browser) { | ->whenAvailable('@form', function (Browser $browser) { | ||||
// Assert form content | // Assert form content | ||||
$browser->assertFocused('div.row:nth-child(1) input') | $browser->assertFocused('div.row:nth-child(1) input') | ||||
->assertSeeIn('div.row:nth-child(1) label', 'First name') | ->assertSeeIn('div.row:nth-child(1) label', 'First name') | ||||
->assertValue('div.row:nth-child(1) input[type=text]', $this->profile['first_name']) | ->assertValue('div.row:nth-child(1) input[type=text]', $this->profile['first_name']) | ||||
->assertSeeIn('div.row:nth-child(2) label', 'Last name') | ->assertSeeIn('div.row:nth-child(2) label', 'Last name') | ||||
->assertValue('div.row:nth-child(2) input[type=text]', $this->profile['last_name']) | ->assertValue('div.row:nth-child(2) input[type=text]', $this->profile['last_name']) | ||||
->assertSeeIn('div.row:nth-child(3) label', 'Phone') | ->assertSeeIn('div.row:nth-child(3) label', 'Organization') | ||||
->assertValue('div.row:nth-child(3) input[type=text]', $this->profile['phone']) | ->assertValue('div.row:nth-child(3) input[type=text]', $this->profile['organization']) | ||||
->assertSeeIn('div.row:nth-child(4) label', 'External email') | ->assertSeeIn('div.row:nth-child(4) label', 'Phone') | ||||
->assertValue('div.row:nth-child(4) input[type=text]', $this->profile['external_email']) | ->assertValue('div.row:nth-child(4) input[type=text]', $this->profile['phone']) | ||||
->assertSeeIn('div.row:nth-child(5) label', 'Address') | ->assertSeeIn('div.row:nth-child(5) label', 'External email') | ||||
->assertValue('div.row:nth-child(5) textarea', $this->profile['billing_address']) | ->assertValue('div.row:nth-child(5) input[type=text]', $this->profile['external_email']) | ||||
->assertSeeIn('div.row:nth-child(6) label', 'Country') | ->assertSeeIn('div.row:nth-child(6) label', 'Address') | ||||
->assertValue('div.row:nth-child(6) select', $this->profile['country']) | ->assertValue('div.row:nth-child(6) textarea', $this->profile['billing_address']) | ||||
->assertSeeIn('div.row:nth-child(7) label', 'Password') | ->assertSeeIn('div.row:nth-child(7) label', 'Country') | ||||
->assertValue('div.row:nth-child(7) input[type=password]', '') | ->assertValue('div.row:nth-child(7) select', $this->profile['country']) | ||||
->assertSeeIn('div.row:nth-child(8) label', 'Confirm password') | ->assertSeeIn('div.row:nth-child(8) label', 'Password') | ||||
->assertValue('div.row:nth-child(8) input[type=password]', '') | ->assertValue('div.row:nth-child(8) input[type=password]', '') | ||||
->assertSeeIn('div.row:nth-child(9) label', 'Confirm password') | |||||
->assertValue('div.row:nth-child(9) input[type=password]', '') | |||||
->assertSeeIn('button[type=submit]', 'Submit'); | ->assertSeeIn('button[type=submit]', 'Submit'); | ||||
// Clear all fields and submit | // Clear all fields and submit | ||||
// FIXME: Should any of these fields be required? | // FIXME: Should any of these fields be required? | ||||
$browser->type('#first_name', '') | $browser->type('#first_name', '') | ||||
->type('#last_name', '') | ->type('#last_name', '') | ||||
->type('#organization', '') | |||||
->type('#phone', '') | ->type('#phone', '') | ||||
->type('#external_email', '') | ->type('#external_email', '') | ||||
->type('#billing_address', '') | ->type('#billing_address', '') | ||||
->select('#country', '') | ->select('#country', '') | ||||
->click('button[type=submit]'); | ->click('button[type=submit]'); | ||||
}) | }) | ||||
->assertToast(Toast::TYPE_SUCCESS, 'User data updated successfully.'); | ->assertToast(Toast::TYPE_SUCCESS, 'User data updated successfully.'); | ||||
▲ Show 20 Lines • Show All 83 Lines • Show Last 20 Lines |