Changeset View
Changeset View
Standalone View
Standalone View
src/tests/Browser/UserProfileTest.php
Show First 20 Lines • Show All 65 Lines • ▼ Show 20 Lines | public function testProfile(): void | ||||
$browser->visit(new Home()) | $browser->visit(new Home()) | ||||
->submitLogon('john@kolab.org', 'simple123', true) | ->submitLogon('john@kolab.org', 'simple123', true) | ||||
->on(new Dashboard()) | ->on(new Dashboard()) | ||||
->assertSeeIn('@links .link-profile', 'Your profile') | ->assertSeeIn('@links .link-profile', 'Your profile') | ||||
->click('@links .link-profile') | ->click('@links .link-profile') | ||||
->on(new UserProfile()) | ->on(new UserProfile()) | ||||
->assertSeeIn('#user-profile .button-delete', 'Delete account') | ->assertSeeIn('#user-profile .button-delete', 'Delete account') | ||||
->whenAvailable('@form', function (Browser $browser) { | ->whenAvailable('@form', function (Browser $browser) { | ||||
$user = User::where('email', 'john@kolab.org')->first(); | |||||
// Assert form content | // Assert form content | ||||
$browser->assertFocused('div.row:nth-child(1) input') | $browser->assertFocused('div.row:nth-child(2) input') | ||||
->assertSeeIn('div.row:nth-child(1) label', 'First name') | ->assertSeeIn('div.row:nth-child(1) label', 'Customer No.') | ||||
->assertValue('div.row:nth-child(1) input[type=text]', $this->profile['first_name']) | ->assertSeeIn('div.row:nth-child(1) .form-control-plaintext', $user->id) | ||||
->assertSeeIn('div.row:nth-child(2) label', 'Last name') | ->assertSeeIn('div.row:nth-child(2) label', 'First 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['first_name']) | ||||
->assertSeeIn('div.row:nth-child(3) label', 'Organization') | ->assertSeeIn('div.row:nth-child(3) label', 'Last name') | ||||
->assertValue('div.row:nth-child(3) input[type=text]', $this->profile['organization']) | ->assertValue('div.row:nth-child(3) input[type=text]', $this->profile['last_name']) | ||||
->assertSeeIn('div.row:nth-child(4) label', 'Phone') | ->assertSeeIn('div.row:nth-child(4) label', 'Organization') | ||||
->assertValue('div.row:nth-child(4) input[type=text]', $this->profile['phone']) | ->assertValue('div.row:nth-child(4) input[type=text]', $this->profile['organization']) | ||||
->assertSeeIn('div.row:nth-child(5) label', 'External email') | ->assertSeeIn('div.row:nth-child(5) label', 'Phone') | ||||
->assertValue('div.row:nth-child(5) input[type=text]', $this->profile['external_email']) | ->assertValue('div.row:nth-child(5) input[type=text]', $this->profile['phone']) | ||||
->assertSeeIn('div.row:nth-child(6) label', 'Address') | ->assertSeeIn('div.row:nth-child(6) label', 'External email') | ||||
->assertValue('div.row:nth-child(6) textarea', $this->profile['billing_address']) | ->assertValue('div.row:nth-child(6) input[type=text]', $this->profile['external_email']) | ||||
->assertSeeIn('div.row:nth-child(7) label', 'Country') | ->assertSeeIn('div.row:nth-child(7) label', 'Address') | ||||
->assertValue('div.row:nth-child(7) select', $this->profile['country']) | ->assertValue('div.row:nth-child(7) textarea', $this->profile['billing_address']) | ||||
->assertSeeIn('div.row:nth-child(8) label', 'Password') | ->assertSeeIn('div.row:nth-child(8) label', 'Country') | ||||
->assertValue('div.row:nth-child(8) input[type=password]', '') | ->assertValue('div.row:nth-child(8) select', $this->profile['country']) | ||||
->assertSeeIn('div.row:nth-child(9) label', 'Confirm password') | ->assertSeeIn('div.row:nth-child(9) label', 'Password') | ||||
->assertValue('div.row:nth-child(9) input[type=password]', '') | ->assertValue('div.row:nth-child(9) input[type=password]', '') | ||||
->assertSeeIn('div.row:nth-child(10) label', 'Confirm password') | |||||
->assertValue('div.row:nth-child(10) input[type=password]', '') | |||||
->assertSeeIn('button[type=submit]', 'Submit'); | ->assertSeeIn('button[type=submit]', 'Submit'); | ||||
// Test form error handling | // Test form error handling | ||||
$browser->type('#phone', 'aaaaaa') | $browser->type('#phone', 'aaaaaa') | ||||
->type('#external_email', 'bbbbb') | ->type('#external_email', 'bbbbb') | ||||
->click('button[type=submit]') | ->click('button[type=submit]') | ||||
->waitFor('#phone + .invalid-feedback') | ->waitFor('#phone + .invalid-feedback') | ||||
->assertSeeIn('#phone + .invalid-feedback', 'The phone format is invalid.') | ->assertSeeIn('#phone + .invalid-feedback', 'The phone format is invalid.') | ||||
▲ Show 20 Lines • Show All 90 Lines • Show Last 20 Lines |