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

52 lines
2.2 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'));
$this->assertIsString($view);
$this->assertStringContainsString('wire:model="body"', $view);
$this->assertStringNotContainsString('wire:model.live="body"', $view);
$this->assertStringContainsString('submit', $view);
$this->assertTrue(
str_contains($view, 'Livewire')
|| str_contains($view, '$wire')
|| str_contains($view, '@this')
|| str_contains($view, 'wire:model="body"'),
'Ticket create editor must keep the body field synchronised with Livewire before validation.'
);
}
/**
* 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);
}
}