93 lines
3.3 KiB
PHP
93 lines
3.3 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Modules\Helpdesk\Tests\Browser;
|
|
|
|
use Laravel\Dusk\Browser;
|
|
use Modules\Helpdesk\Tests\Concerns\BuildsHelpdeskFixtures;
|
|
use Tests\DuskTestCase;
|
|
|
|
final class HelpdeskSettingsBrowserTest extends DuskTestCase
|
|
{
|
|
use BuildsHelpdeskFixtures;
|
|
|
|
public function test_settings_tabs_expose_lookup_git_and_workflow_setup_areas(): void
|
|
{
|
|
$this->seedLookupData();
|
|
$admin = $this->admin(['name' => 'Settings Admin']);
|
|
|
|
$this->browse(function (Browser $browser) use ($admin): void {
|
|
$browser->loginAs($admin)
|
|
->visitRoute('helpdesk.settings')
|
|
->waitFor('@helpdesk-settings-manager')
|
|
->assertSee('Support configuration')
|
|
->assertSourceHas('Statuses')
|
|
->assertSourceHas('Priorities')
|
|
->assertSourceHas('Categories')
|
|
->assertSourceHas('Teams')
|
|
->assertSourceHas('Projects')
|
|
->assertSourceHas('Git')
|
|
->assertSourceHas('Workflow')
|
|
->assertSourceHas('Canned')
|
|
->assertSourceHas('SLA')
|
|
->assertSourceHas('Rules')
|
|
->assertSourceHas('Checks')
|
|
->assertSourceHas('Tags')
|
|
->assertSourceHas('Products');
|
|
|
|
$this->setHelpdeskSettingsSection($browser, 'git');
|
|
$browser->waitForText('Git repositories', 10)
|
|
->assertSee('Remote URL');
|
|
|
|
$this->setHelpdeskSettingsSection($browser, 'workflow');
|
|
$browser->waitForText('Workflow messages', 10)
|
|
->assertSee('HTML email body');
|
|
|
|
$this->setHelpdeskSettingsSection($browser, 'canned');
|
|
$browser->waitForText('Canned responses', 10)
|
|
->assertSee('Reply body');
|
|
|
|
$this->setHelpdeskSettingsSection($browser, 'sla');
|
|
$browser->waitForText('SLA policies', 10)
|
|
->assertSee('First response minutes');
|
|
|
|
$this->setHelpdeskSettingsSection($browser, 'automation');
|
|
$browser->waitForText('Email automation rules', 10)
|
|
->assertSee('Subject contains');
|
|
|
|
$this->setHelpdeskSettingsSection($browser, 'checklists');
|
|
$browser->waitForText('Checklist templates', 10)
|
|
->assertSee('Checklist items');
|
|
|
|
$this->setHelpdeskSettingsSection($browser, 'tags');
|
|
$browser->waitForText('Ticket tags', 10)
|
|
->assertSee('Colour');
|
|
|
|
$this->setHelpdeskSettingsSection($browser, 'products');
|
|
$browser->waitForText('Products and services', 10)
|
|
->assertSee('Release/build');
|
|
});
|
|
}
|
|
|
|
private function setHelpdeskSettingsSection(Browser $browser, string $section): void
|
|
{
|
|
$encodedSection = json_encode($section, JSON_THROW_ON_ERROR);
|
|
|
|
$browser->script(<<<JS
|
|
const settings = document.querySelector('[dusk="helpdesk-settings-manager"]');
|
|
|
|
let component = settings;
|
|
while (component && ! component.hasAttribute('wire:id')) {
|
|
component = component.parentElement;
|
|
}
|
|
|
|
if (! component) {
|
|
throw new Error('Helpdesk settings Livewire component was not found.');
|
|
}
|
|
|
|
window.Livewire.find(component.getAttribute('wire:id')).set('section', {$encodedSection});
|
|
JS);
|
|
}
|
|
}
|