Files
WMS/Modules/Helpdesk/Tests/Feature/TicketCreateEditorSyncFilesTest.php
T

46 lines
2.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 bind the details body through Livewire
* without eager live validation while the user is typing.
*/
public function test_ticket_create_editor_pushes_details_body_to_livewire_before_validation(): void
{
$view = file_get_contents(base_path('Modules/Helpdesk/Resources/views/livewire/ticket-create.blade.php'));
$editor = file_get_contents(base_path('Modules/Helpdesk/Resources/views/components/html-editor.blade.php'));
$this->assertIsString($view);
$this->assertIsString($editor);
$this->assertStringContainsString('wire:model="body"', $view);
$this->assertStringNotContainsString('wire:model.live="body"', $view);
$this->assertStringContainsString('form.addEventListener(\'submit\'', $editor);
$this->assertStringContainsString('this.$wire.set(this.model, this.value, false)', $editor);
}
/**
* The rich text editor must not fire a Livewire request for every keystroke,
* otherwise the submit button can remain disabled and typed content can race
* with stale Livewire responses.
*/
public function test_ticket_create_editor_does_not_live_sync_on_each_keypress(): void
{
$editor = file_get_contents(base_path('Modules/Helpdesk/Resources/views/components/html-editor.blade.php'));
$this->assertIsString($editor);
$this->assertStringNotContainsString('x-on:keyup="sync"', $editor);
$this->assertStringNotContainsString('this.$wire.set(this.model, this.value);', $editor);
$this->assertStringContainsString('x-on:input.debounce.250ms="sync(false)"', $editor);
$this->assertStringContainsString('autocorrect="off"', $editor);
$this->assertStringContainsString('autocomplete="off"', $editor);
$this->assertStringContainsString('spellcheck="true"', $editor);
}
}