Changeset View
Changeset View
Standalone View
Standalone View
src/tests/Browser/SupportTest.php
Show All 10 Lines | |||||
class SupportTest extends TestCaseDusk | class SupportTest extends TestCaseDusk | ||||
{ | { | ||||
/** | /** | ||||
* Test support contact form | * Test support contact form | ||||
*/ | */ | ||||
public function testSupportForm(): void | public function testSupportForm(): void | ||||
{ | { | ||||
$this->browse(function (Browser $browser) { | $this->browse(function (Browser $browser) { | ||||
$browser->visit('/') | $browser->withConfig(['app.support_email' => ""]) | ||||
->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') | ->assertElementsCount('.card-title', 2) | ||||
->assertSeeIn('a.btn-primary', 'Contact Support') | ->with('.row .col:last-child', function ($card) { | ||||
->click('a.btn-primary') | $card->assertSeeIn('.card-title', 'Contact Support') | ||||
->assertSeeIn('.btn-primary', 'Contact Support') | |||||
->click('.btn-primary'); | |||||
}) | |||||
->with(new Dialog('#support-dialog'), function (Browser $browser) { | ->with(new Dialog('#support-dialog'), function (Browser $browser) { | ||||
$browser->assertSeeIn('@title', 'Contact Support') | $browser->assertSeeIn('@title', 'Contact Support') | ||||
->assertFocused('#support-user') | ->assertFocused('#support-user') | ||||
->assertSeeIn('@button-cancel', 'Cancel') | ->assertSeeIn('@button-cancel', 'Cancel') | ||||
->assertSeeIn('@button-action', 'Submit') | ->assertSeeIn('@button-action', 'Submit') | ||||
->assertVisible('#support-name') | ->assertVisible('#support-name') | ||||
->assertVisible('#support-email') | ->assertVisible('#support-email') | ||||
->assertVisible('#support-summary') | ->assertVisible('#support-summary') | ||||
->assertVisible('#support-body') | ->assertVisible('#support-body') | ||||
->type('#support-email', 'email@address.com') | ->type('#support-email', 'email@address.com') | ||||
->type('#support-summary', 'Summary') | ->type('#support-summary', 'Summary') | ||||
->type('#support-body', 'Body') | ->type('#support-body', 'Body') | ||||
->click('@button-cancel'); | ->click('@button-cancel'); | ||||
}) | }) | ||||
->assertMissing('#support-dialog') | ->assertMissing('#support-dialog') | ||||
->click('a.btn-primary') | ->with('.row .col:last-child', function ($card) { | ||||
$card->click('.btn-primary'); | |||||
}) | |||||
->with(new Dialog('#support-dialog'), function (Browser $browser) { | ->with(new Dialog('#support-dialog'), function (Browser $browser) { | ||||
$browser->assertSeeIn('@title', 'Contact Support') | $browser->assertSeeIn('@title', 'Contact Support') | ||||
->assertFocused('#support-user') | ->assertFocused('#support-user') | ||||
->assertValue('#support-email', 'email@address.com') | ->assertValue('#support-email', 'email@address.com') | ||||
->assertValue('#support-summary', 'Summary') | ->assertValue('#support-summary', 'Summary') | ||||
->assertValue('#support-body', 'Body') | ->assertValue('#support-body', 'Body') | ||||
->click('@button-action'); | ->click('@button-action'); | ||||
}) | }) | ||||
// Note: This line assumes SUPPORT_EMAIL is not set in config | |||||
->assertToast(Toast::TYPE_ERROR, 'Failed to submit the support request') | ->assertToast(Toast::TYPE_ERROR, 'Failed to submit the support request') | ||||
->assertVisible('#support-dialog'); | ->assertVisible('#support-dialog'); | ||||
}); | }); | ||||
} | } | ||||
/** | |||||
* Test disabled support contact form | |||||
*/ | |||||
public function testNoSupportForm(): void | |||||
{ | |||||
$this->browse(function (Browser $browser) { | |||||
$browser->withConfig(['app.support_email' => null]) | |||||
->visit('/') | |||||
->within(new Menu(), function ($browser) { | |||||
$browser->clickMenuItem('support'); | |||||
}) | |||||
->waitFor('#support') | |||||
->assertElementsCount('.card-title', 1) | |||||
->assertSeeIn('.card-title', 'Documentation') | |||||
->assertSeeIn('.btn-primary', 'Search Knowledgebase'); | |||||
}); | |||||
} | |||||
} | } |