Files
WMS/Modules/Helpdesk/Tests/Feature/TicketCreateEditorSyncFilesTest.php
T
Mark Gregory 5f7c54e0ff Merge branch 'stage'
# Conflicts:
#	Modules/Helpdesk/Resources/views/components/html-editor.blade.php
#	Modules/Helpdesk/Resources/views/livewire/ticket-create.blade.php
#	Modules/Helpdesk/changelog.yaml
#	Modules/Helpdesk/module.json
2026-06-25 16:53:58 +01:00

81 lines
4.0 KiB
PHP

<?php
declare(strict_types=1);
namespace Modules\Helpdesk\Tests\Feature;
use Tests\TestCase;
final class TicketCreateEditorSyncFilesTest extends TestCase
{
/**
* The ticket create editor must not send Livewire requests while typing.
* Eager key/input sync causes disabled submit states, random content
* replacement, and prevents native spellcheck from settling.
*/
public function test_ticket_create_editor_does_not_sync_livewire_on_keypress_or_input(): void
{
$editor = file_get_contents(base_path('Modules/Helpdesk/Resources/views/components/html-editor.blade.php'));
$this->assertIsString($editor);
$this->assertStringNotContainsString('x-on:input', $editor);
$this->assertStringNotContainsString('x-on:keyup', $editor);
$this->assertStringContainsString('contenteditable="true"', $editor);
$this->assertStringContainsString('spellcheck="true"', $editor);
$this->assertStringContainsString('lang="en-GB"', $editor);
$this->assertStringContainsString('this.$wire.set(this.model, this.value, live)', $editor);
$this->assertStringContainsString('syncToLivewire(false)', $editor);
}
/**
* The create form must push the rich editor body to the Livewire property
* during submit capture, before the save action validates the body field.
*/
public function test_ticket_create_form_syncs_body_before_submit_validation(): void
{
$view = file_get_contents(base_path('Modules/Helpdesk/Resources/views/livewire/ticket-create.blade.php'));
$this->assertIsString($view);
$this->assertStringContainsString('model="body"', $view);
$this->assertStringContainsString('x-on:submit.capture', $view);
$this->assertStringContainsString('helpdesk-editor-sync', $view);
$this->assertStringNotContainsString('wire:model.live="body"', $view);
}
/**
* The create-ticket footer buttons should match the compact professional
* pattern already used by Ticket controls.
*/
public function test_ticket_create_footer_buttons_match_ticket_controls_style(): void
{
$view = file_get_contents(base_path('Modules/Helpdesk/Resources/views/livewire/ticket-create.blade.php'));
$this->assertIsString($view);
$this->assertStringContainsString('inline-flex min-h-10 items-center justify-center rounded-lg bg-red-600 px-4 py-2 text-xs font-black', $view);
$this->assertStringContainsString('inline-flex min-h-10 items-center justify-center rounded-lg bg-blue-600 px-4 py-2 text-xs font-black', $view);
$this->assertStringContainsString('inline-flex min-h-10 items-center justify-center rounded-lg bg-emerald-600 px-4 py-2 text-xs font-black', $view);
$this->assertStringContainsString('Create ticket', $view);
$this->assertStringNotContainsString('rounded-xl bg-green-600 px-5 py-2 text-sm font-semibold', $view);
}
/**
* Browser-native spellcheck must remain enabled without forcing Livewire
* updates on every keystroke because that breaks typing and spellcheck.
*/
public function test_ticket_create_editor_keeps_spellcheck_without_live_keypress_sync(): void
{
$component = file_get_contents(base_path('Modules/Helpdesk/Resources/views/components/html-editor.blade.php'));
$view = file_get_contents(base_path('Modules/Helpdesk/Resources/views/livewire/ticket-create.blade.php'));
$this->assertIsString($component);
$this->assertIsString($view);
$this->assertStringContainsString('spellcheck="true"', $component);
$this->assertStringContainsString('autocorrect="on"', $component);
$this->assertStringContainsString('lang="en-GB"', $component);
$this->assertStringNotContainsString('x-on:input', $component);
$this->assertStringNotContainsString('x-on:keyup', $component);
$this->assertStringContainsString('x-on:submit.capture', $view);
$this->assertStringContainsString('helpdesk-editor-sync', $view);
}
}