non working comments
This commit is contained in:
@@ -12,14 +12,16 @@
|
||||
|
||||
<div
|
||||
{{ $attributes->whereDoesntStartWith('wire:model')->merge(['class' => 'space-y-2']) }}
|
||||
@if($model) data-helpdesk-editor-model="{{ $model }}" @endif
|
||||
x-on:helpdesk-editor-reset.window="if ($event.detail.model === model) clear()"
|
||||
x-on:helpdesk-editor-sync.window="if ($event.detail.model === model) sync()"
|
||||
x-data="{
|
||||
model: @js($model),
|
||||
value: @js($initialValue),
|
||||
sync() {
|
||||
this.value = this.$refs.editor.innerHTML;
|
||||
if (this.model) {
|
||||
this.$wire.set(this.model, this.value, false);
|
||||
this.$wire.set(this.model, this.value);
|
||||
}
|
||||
},
|
||||
command(action, value = null) {
|
||||
@@ -31,7 +33,7 @@
|
||||
this.value = '';
|
||||
this.$refs.editor.innerHTML = '';
|
||||
if (this.model) {
|
||||
this.$wire.set(this.model, '', false);
|
||||
this.$wire.set(this.model, '');
|
||||
}
|
||||
},
|
||||
init() {
|
||||
@@ -60,7 +62,9 @@
|
||||
<div
|
||||
x-ref="editor"
|
||||
contenteditable="true"
|
||||
x-on:input.debounce.300ms="sync"
|
||||
x-on:input.debounce.150ms="sync"
|
||||
x-on:keyup="sync"
|
||||
x-on:paste="$nextTick(() => sync())"
|
||||
x-on:blur="sync"
|
||||
class="prose prose-sm min-h-[{{ (int) $rows * 28 }}px] max-w-none bg-white p-4 text-sm text-zinc-900 outline-none dark:prose-invert dark:bg-zinc-950 dark:text-zinc-100"
|
||||
data-placeholder="{{ $placeholder }}"
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -204,3 +204,11 @@ versions:
|
||||
- Stabilised Helpdesk Dusk browser tests by adding durable Dusk selectors to settings and ticket create controls.
|
||||
- Replaced browser-test Livewire internals with real UI interactions for settings sections, Select2 controls and HTML editors.
|
||||
- Kept module.json version in sync with changelog.yaml.
|
||||
|
||||
"1.3.12":
|
||||
changed:
|
||||
- Fixed ticket comment submission by forcing the Helpdesk HTML editor content into Livewire before directly invoking addComment from the form submit path.
|
||||
- Fixed nested reply submission by applying the same editor-to-Livewire synchronisation before addReply.
|
||||
- Updated the Helpdesk browser test so comment creation must persist a real helpdesk_comments database row instead of being masked by direct Livewire component mutation.
|
||||
- Kept module.json version in sync with changelog.yaml.
|
||||
|
||||
|
||||
@@ -22,5 +22,5 @@
|
||||
"Modules\\Helpdesk\\Providers\\HelpdeskServiceProvider"
|
||||
],
|
||||
"files": [],
|
||||
"version": "1.3.11"
|
||||
"version": "1.3.12"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user