part fix for tests

This commit is contained in:
Mark Gregory
2026-06-23 15:54:42 +01:00
parent 5299d2c059
commit 3b0393a1fe
6 changed files with 202 additions and 7 deletions
@@ -206,11 +206,11 @@ final class TicketConversationTest extends TestCase
Livewire::actingAs($agent)
->test(TicketShow::class, ['ticket' => $ticket])
->set('status_id', $fixtures['closed']->id)
->set('closureComment', 'Closing after agent review.')
->call('updateStatus')
->assertHasNoErrors()
->assertDispatched('helpdesk-status-updated')
->set('priority_id', $fixtures['high']->id)
->set('closureComment', 'Closing after agent review.')
->call('updatePriority')
->assertHasNoErrors()
->assertDispatched('helpdesk-priority-updated');
@@ -16,7 +16,7 @@ final class TicketCreateEditorSyncFilesTest extends TestCase
$this->assertIsString($view);
$this->assertStringContainsString('wire:model="body"', $view);
$this->assertStringContainsString(".set('body', value, false)", $view);
$this->assertStringContainsString('syncBody', $view);
$this->assertStringContainsString("form.addEventListener('submit', syncBody, { capture: true })", $view);
$this->assertStringNotContainsString('wire:model.live="body"', $view);
$this->assertStringContainsString("document.addEventListener('livewire:navigated', initialiseTicketCreateEditor)", $view);
@@ -4,15 +4,14 @@ declare(strict_types=1);
namespace Modules\Helpdesk\Tests\Feature;
use App\Models\Company;
use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Modules\Helpdesk\Models\Ticket;
use Tests\TestCase;
use Modules\Helpdesk\Tests\Concerns\BuildsHelpdeskFixtures;
final class TicketTimeLogTest extends TestCase
{
use BuildsHelpdeskFixtures;
use RefreshDatabase;
@@ -65,4 +64,35 @@ final class TicketTimeLogTest extends TestCase
->assertRedirect(route('helpdesk.tickets.show', $ticket))
->assertSessionHasErrors('minutes');
}
/**
* Create a company for ticket time-log feature tests.
*/
private function createCompany(): Company
{
return Company::factory()->create();
}
/**
* Create a company-scoped user for ticket time-log feature tests.
*/
private function createUserForCompany(Company $company): User
{
return User::factory()->create([
'company_id' => $company->getKey(),
]);
}
/**
* Create a company-scoped ticket for ticket time-log feature tests.
*
* @param array<string, mixed> $attributes
*/
private function createTicketForCompany(Company $company, array $attributes = []): Ticket
{
return Ticket::factory()->create(array_merge([
'company_id' => $company->getKey(),
], $attributes));
}
}