Changeset View
Changeset View
Standalone View
Standalone View
src/tests/Browser/UserProfileTest.php
Show First 20 Lines • Show All 94 Lines • ▼ Show 20 Lines | public function testProfile(): void | ||||
$browser->type('#first_name', '') | $browser->type('#first_name', '') | ||||
->type('#last_name', '') | ->type('#last_name', '') | ||||
->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]'); | ||||
}) | }) | ||||
->with(new Toast(Toast::TYPE_SUCCESS), function (Browser $browser) { | ->assertToast(Toast::TYPE_SUCCESS, 'User data updated successfully.'); | ||||
$browser->assertToastTitle('') | |||||
->assertToastMessage('User data updated successfully') | |||||
->closeToast(); | |||||
}); | |||||
// Test error handling | // Test error handling | ||||
$browser->with('@form', function (Browser $browser) { | $browser->with('@form', function (Browser $browser) { | ||||
$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.') | ||||
->assertSeeIn( | ->assertSeeIn( | ||||
'#external_email + .invalid-feedback', | '#external_email + .invalid-feedback', | ||||
'The external email must be a valid email address.' | 'The external email must be a valid email address.' | ||||
) | ) | ||||
->assertFocused('#phone'); | ->assertFocused('#phone') | ||||
}) | ->assertToast(Toast::TYPE_ERROR, 'Form validation error'); | ||||
->with(new Toast(Toast::TYPE_ERROR), function (Browser $browser) { | |||||
$browser->assertToastTitle('Error') | |||||
->assertToastMessage('Form validation error') | |||||
->closeToast(); | |||||
}); | }); | ||||
}); | }); | ||||
} | } | ||||
/** | /** | ||||
* Test profile of non-controller user | * Test profile of non-controller user | ||||
*/ | */ | ||||
public function testProfileNonController(): void | public function testProfileNonController(): void | ||||
▲ Show 20 Lines • Show All 45 Lines • ▼ Show 20 Lines | public function testProfileDelete(): void | ||||
->waitForLocation('/profile') | ->waitForLocation('/profile') | ||||
->on(new UserProfile()); | ->on(new UserProfile()); | ||||
// Test deleting the user | // Test deleting the user | ||||
$browser->click('#user-profile .button-delete') | $browser->click('#user-profile .button-delete') | ||||
->waitForLocation('/profile/delete') | ->waitForLocation('/profile/delete') | ||||
->click('#user-delete .button-delete') | ->click('#user-delete .button-delete') | ||||
->waitForLocation('/login') | ->waitForLocation('/login') | ||||
->with(new Toast(Toast::TYPE_SUCCESS), function (Browser $browser) { | ->assertToast(Toast::TYPE_SUCCESS, 'User deleted successfully.'); | ||||
$browser->assertToastTitle('') | |||||
->assertToastMessage('User deleted successfully.') | |||||
->closeToast(); | |||||
}); | |||||
$this->assertTrue($user->fresh()->trashed()); | $this->assertTrue($user->fresh()->trashed()); | ||||
}); | }); | ||||
} | } | ||||
// TODO: Test that Ned (John's "delegatee") can delete himself | // TODO: Test that Ned (John's "delegatee") can delete himself | ||||
// TODO: Test that Ned (John's "delegatee") can/can't delete John ? | // TODO: Test that Ned (John's "delegatee") can/can't delete John ? | ||||
} | } |