44 lines
2.1 KiB
PHP
44 lines
2.1 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Modules\Helpdesk\Tests\Feature;
|
|
|
|
use Tests\TestCase;
|
|
|
|
final class TicketCreateAttachmentPersistenceTest extends TestCase
|
|
{
|
|
/**
|
|
* The create form must not submit while Livewire is still uploading files,
|
|
* otherwise the ticket can be created before attachments reach the component.
|
|
*/
|
|
public function test_ticket_create_submit_is_blocked_while_attachments_are_uploading(): void
|
|
{
|
|
$view = file_get_contents(base_path('Modules/Helpdesk/Resources/views/livewire/ticket-create.blade.php'));
|
|
|
|
$this->assertIsString($view);
|
|
$this->assertStringContainsString('x-on:livewire-upload-start="helpdeskAttachmentsUploading = true"', $view);
|
|
$this->assertStringContainsString('x-on:livewire-upload-finish="helpdeskAttachmentsUploading = false"', $view);
|
|
$this->assertStringContainsString('x-on:livewire-upload-error="helpdeskAttachmentsUploading = false"', $view);
|
|
$this->assertStringContainsString('x-on:livewire-upload-cancel="helpdeskAttachmentsUploading = false"', $view);
|
|
$this->assertStringContainsString('wire:target="save,attachments"', $view);
|
|
$this->assertStringContainsString('x-bind:disabled="helpdeskAttachmentsUploading"', $view);
|
|
$this->assertStringContainsString('$event.preventDefault();', $view);
|
|
}
|
|
|
|
/**
|
|
* The shared attachment service must explicitly support Livewire temporary
|
|
* uploads as well as controller UploadedFile instances.
|
|
*/
|
|
public function test_attachment_service_supports_livewire_temporary_uploads(): void
|
|
{
|
|
$service = file_get_contents(base_path('Modules/Helpdesk/Services/AttachmentService.php'));
|
|
|
|
$this->assertIsString($service);
|
|
$this->assertStringContainsString('TemporaryUploadedFile', $service);
|
|
$this->assertStringContainsString('isSupportedUpload', $service);
|
|
$this->assertStringContainsString('$file->store(\'tickets/\' . $ticket->id, $disk)', $service);
|
|
$this->assertStringNotContainsString('! $file instanceof UploadedFile || ! $file->isValid()', $service);
|
|
}
|
|
}
|