non working comments
This commit is contained in:
@@ -21,17 +21,15 @@ final class HelpdeskSettingsBrowserTest extends DuskTestCase
|
||||
$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('Git repositories')
|
||||
->assertSourceHas('Workflow messages')
|
||||
->assertSourceHas('HTML email body');
|
||||
->assertSee('Support configuration');
|
||||
|
||||
$this->openSettingsSection($browser, 'statuses', 'Statuses');
|
||||
$this->openSettingsSection($browser, 'priorities', 'Priorities');
|
||||
$this->openSettingsSection($browser, 'categories', 'Categories');
|
||||
$this->openSettingsSection($browser, 'teams', 'Teams');
|
||||
$this->openSettingsSection($browser, 'projects', 'Projects');
|
||||
$this->openSettingsSection($browser, 'git', 'Remote URL');
|
||||
$this->openSettingsSection($browser, 'workflow', 'HTML email body');
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -64,11 +64,18 @@ final class HelpdeskTicketBrowserTest extends DuskTestCase
|
||||
|
||||
$this->setHelpdeskEditor($browser, 'ticket-comment-editor', '<p>First browser response</p>');
|
||||
|
||||
$browser->pause(750)
|
||||
->press('@post-comment')
|
||||
$browser->press('@post-comment')
|
||||
->waitForText('First browser response', 10)
|
||||
->assertSee('First browser response');
|
||||
});
|
||||
|
||||
$this->assertDatabaseHas('helpdesk_comments', [
|
||||
'ticket_id' => $ticket->id,
|
||||
'parent_id' => null,
|
||||
'user_id' => $user->id,
|
||||
'body' => '<p>First browser response</p>',
|
||||
'is_internal' => false,
|
||||
]);
|
||||
}
|
||||
|
||||
private function setHelpdeskEditor(Browser $browser, string $dusk, string $html): void
|
||||
@@ -78,17 +85,36 @@ final class HelpdeskTicketBrowserTest extends DuskTestCase
|
||||
|
||||
$browser->script(<<<JS
|
||||
const key = {$encodedDusk};
|
||||
const editorRoot = document.querySelector('[dusk="' + key + '"]') || document.querySelector('[data-dusk="' + key + '"]');
|
||||
if (! editorRoot) {
|
||||
throw new Error('Helpdesk editor '+key+' was not found.');
|
||||
const html = {$encodedHtml};
|
||||
const root = document.querySelector('[dusk="' + key + '"]') || document.querySelector('[data-dusk="' + key + '"]');
|
||||
|
||||
if (! root) {
|
||||
throw new Error('Helpdesk editor ' + key + ' was not found.');
|
||||
}
|
||||
const editor = editorRoot.querySelector('[contenteditable="true"]');
|
||||
|
||||
const editor = root.matches('[contenteditable="true"]')
|
||||
? root
|
||||
: root.querySelector('[contenteditable="true"]');
|
||||
|
||||
if (! editor) {
|
||||
throw new Error('Helpdesk editor content area '+key+' was not found.');
|
||||
throw new Error('Helpdesk editor content area ' + key + ' was not found.');
|
||||
}
|
||||
editor.innerHTML = {$encodedHtml};
|
||||
editor.dispatchEvent(new InputEvent('input', { bubbles: true, inputType: 'insertText', data: ' ' }));
|
||||
editor.dispatchEvent(new Event('blur', { bubbles: true }));
|
||||
|
||||
editor.focus();
|
||||
editor.innerHTML = html;
|
||||
|
||||
editor.dispatchEvent(new InputEvent('input', {
|
||||
bubbles: true,
|
||||
composed: true,
|
||||
inputType: 'insertText',
|
||||
data: editor.textContent || ' ',
|
||||
}));
|
||||
|
||||
editor.dispatchEvent(new Event('change', { bubbles: true, composed: true }));
|
||||
editor.dispatchEvent(new KeyboardEvent('keyup', { bubbles: true, composed: true }));
|
||||
editor.dispatchEvent(new Event('blur', { bubbles: true, composed: true }));
|
||||
|
||||
|
||||
JS);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user