Changeset View
Changeset View
Standalone View
Standalone View
src/tests/Browser/UserProfileTest.php
Show First 20 Lines • Show All 87 Lines • ▼ Show 20 Lines | public function testProfile(): void | ||||
->assertSeeIn('div.row:nth-child(7) label', 'Country') | ->assertSeeIn('div.row:nth-child(7) label', 'Country') | ||||
->assertValue('div.row:nth-child(7) select', $this->profile['country']) | ->assertValue('div.row:nth-child(7) select', $this->profile['country']) | ||||
->assertSeeIn('div.row:nth-child(8) label', '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') | ->assertSeeIn('div.row:nth-child(9) label', 'Confirm password') | ||||
->assertValue('div.row:nth-child(9) input[type=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 | // Test form error handling | ||||
// FIXME: Should any of these fields be required? | |||||
$browser->type('#first_name', '') | |||||
->type('#last_name', '') | |||||
->type('#organization', '') | |||||
->type('#phone', '') | |||||
->type('#external_email', '') | |||||
->type('#billing_address', '') | |||||
->select('#country', '') | |||||
->click('button[type=submit]'); | |||||
}) | |||||
->assertToast(Toast::TYPE_SUCCESS, 'User data updated successfully.'); | |||||
// Test error handling | |||||
$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'); | ->assertToast(Toast::TYPE_ERROR, 'Form validation error') | ||||
}); | ->clearToasts(); | ||||
// Clear all fields and submit | |||||
// FIXME: Should any of these fields be required? | |||||
$browser->vueClear('#first_name') | |||||
->vueClear('#last_name') | |||||
->vueClear('#organization') | |||||
->vueClear('#phone') | |||||
->vueClear('#external_email') | |||||
->vueClear('#billing_address') | |||||
->click('button[type=submit]') | |||||
->assertToast(Toast::TYPE_SUCCESS, 'User data updated successfully.'); | |||||
}) | |||||
// On success we're redirected to Dashboard | |||||
->on(new Dashboard()); | |||||
}); | }); | ||||
} | } | ||||
/** | /** | ||||
* 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 61 Lines • Show Last 20 Lines |