Changeset View
Changeset View
Standalone View
Standalone View
src/tests/Browser/SupportTest.php
<?php | <?php | ||||
namespace Tests\Browser; | namespace Tests\Browser; | ||||
use Tests\Browser; | use Tests\Browser; | ||||
use Tests\Browser\Components\Dialog; | |||||
use Tests\Browser\Components\Menu; | use Tests\Browser\Components\Menu; | ||||
use Tests\Browser\Components\Toast; | |||||
use Tests\TestCaseDusk; | use Tests\TestCaseDusk; | ||||
class SupportTest extends TestCaseDusk | class SupportTest extends TestCaseDusk | ||||
{ | { | ||||
/** | /** | ||||
* Test support contact form | * Test support view | ||||
*/ | */ | ||||
public function testSupportForm(): void | public function testSupportForm(): void | ||||
{ | { | ||||
$this->browse(function (Browser $browser) { | $this->browse(function (Browser $browser) { | ||||
$browser->visit('/') | $browser->visit('/') | ||||
->within(new Menu(), function ($browser) { | ->within(new Menu(), function ($browser) { | ||||
$browser->clickMenuItem('support'); | $browser->clickMenuItem('support'); | ||||
}) | }) | ||||
->waitFor('#support') | ->waitFor('#support') | ||||
->assertSeeIn('.card-title', 'Contact Support') | ->assertSeeIn('.card-title', 'Documentation') | ||||
->assertSeeIn('a.btn-primary', 'Contact Support') | ->assertSeeIn('a.btn-primary', 'Search Knowledgebase'); | ||||
->click('a.btn-primary') | |||||
->with(new Dialog('#support-dialog'), function (Browser $browser) { | |||||
$browser->assertSeeIn('@title', 'Contact Support') | |||||
->assertFocused('#support-user') | |||||
->assertSeeIn('@button-cancel', 'Cancel') | |||||
->assertSeeIn('@button-action', 'Submit') | |||||
->assertVisible('#support-name') | |||||
->assertVisible('#support-email') | |||||
->assertVisible('#support-summary') | |||||
->assertVisible('#support-body') | |||||
->type('#support-email', 'email@address.com') | |||||
->type('#support-summary', 'Summary') | |||||
->type('#support-body', 'Body') | |||||
->click('@button-cancel'); | |||||
}) | |||||
->assertMissing('#support-dialog') | |||||
->click('a.btn-primary') | |||||
->with(new Dialog('#support-dialog'), function (Browser $browser) { | |||||
$browser->assertSeeIn('@title', 'Contact Support') | |||||
->assertFocused('#support-user') | |||||
->assertValue('#support-email', 'email@address.com') | |||||
->assertValue('#support-summary', 'Summary') | |||||
->assertValue('#support-body', 'Body') | |||||
->click('@button-action'); | |||||
}) | |||||
// Note: This line assumes SUPPORT_EMAIL is not set in config | |||||
->assertToast(Toast::TYPE_ERROR, 'Failed to submit the support request') | |||||
->assertVisible('#support-dialog'); | |||||
}); | }); | ||||
} | } | ||||
} | } |