interim dusk fixes

This commit is contained in:
Mark Gregory
2026-06-25 12:12:06 +01:00
parent 85e8d96655
commit db32d7b823
3 changed files with 18 additions and 52 deletions
@@ -47,8 +47,8 @@
this.syncToLivewire(false); this.syncToLivewire(false);
}, },
}" }"
x-on:helpdesk-editor-sync.window="if (($event.detail?.model || model) === model) syncToLivewire(false)" x-on:helpdesk-editor-sync.window="if (! $event.detail?.model || $event.detail.model === @js($model)) syncToLivewire(false)"
x-on:helpdesk-editor-reset.window="if (($event.detail?.model || model) === model) resetEditor()" x-on:helpdesk-editor-reset.window="if (! $event.detail?.model || $event.detail.model === @js($model)) resetEditor()"
> >
<label for="{{ $model }}-editor" class="block text-sm font-semibold text-zinc-200"> <label for="{{ $model }}-editor" class="block text-sm font-semibold text-zinc-200">
{{ $label }} {{ $label }}
@@ -105,6 +105,8 @@
aria-multiline="true" aria-multiline="true"
data-placeholder="{{ $placeholder }}" data-placeholder="{{ $placeholder }}"
data-wire-model="{{ $model }}" data-wire-model="{{ $model }}"
data-helpdesk-sync-target="{{ $model }}"
data-helpdesk-editor-model="{{ $model }}"
@if ($editorDusk) data-dusk="{{ $editorDusk }}" dusk="{{ $editorDusk }}" @endif @if ($editorDusk) data-dusk="{{ $editorDusk }}" dusk="{{ $editorDusk }}" @endif
x-on:blur="syncToLivewire(false)" x-on:blur="syncToLivewire(false)"
class="helpdesk-rich-editor block min-h-[14rem] w-full overflow-y-auto whitespace-pre-wrap break-words border-0 bg-zinc-950 px-5 py-4 text-base leading-7 text-zinc-100 outline-none transition placeholder:text-zinc-500 empty:before:pointer-events-none empty:before:text-zinc-500 empty:before:content-[attr(data-placeholder)] focus:ring-2 focus:ring-blue-500" class="helpdesk-rich-editor block min-h-[14rem] w-full overflow-y-auto whitespace-pre-wrap break-words border-0 bg-zinc-950 px-5 py-4 text-base leading-7 text-zinc-100 outline-none transition placeholder:text-zinc-500 empty:before:pointer-events-none empty:before:text-zinc-500 empty:before:content-[attr(data-placeholder)] focus:ring-2 focus:ring-blue-500"
@@ -34,11 +34,13 @@ final class HelpdeskTicketBrowserTest extends DuskTestCase
$this->setHelpdeskSelect($browser, 'team_id', $fixtures['team']->id); $this->setHelpdeskSelect($browser, 'team_id', $fixtures['team']->id);
$this->setHelpdeskSelect($browser, 'project_id', $fixtures['project']->id); $this->setHelpdeskSelect($browser, 'project_id', $fixtures['project']->id);
$browser->press('@ticket-create-submit') $browser->pause(500)
->waitUntilMissing('@helpdesk-ticket-create', 15) ->press('@ticket-create-submit')
->assertPathBeginsWith('/helpdesk/tickets/') ->waitForLocation('/helpdesk/tickets', 15)
->waitForText($subject, 15) ->waitFor('@helpdesk-ticket-index', 15)
->assertSee($subject); ->assertSee($subject)
->assertSee('High')
->assertSee('Support');
}); });
} }
@@ -98,45 +100,6 @@ final class HelpdeskTicketBrowserTest extends DuskTestCase
]); ]);
} }
private function submitNestedCommentThroughBrowser(Browser $browser, int|string $ticketId, int|string $parentId): void
{
$action = route('helpdesk.tickets.comments.store', ['ticket' => $ticketId]);
$encodedAction = json_encode($action, JSON_THROW_ON_ERROR);
$encodedParentId = json_encode((string) $parentId, JSON_THROW_ON_ERROR);
$browser->script(<<<JS
const action = {$encodedAction};
const parentId = {$encodedParentId};
const token = document.querySelector('meta[name="csrf-token"]')?.getAttribute('content')
|| document.querySelector('input[name="_token"]')?.value;
const form = document.createElement('form');
form.method = 'POST';
form.action = action;
form.style.display = 'none';
const fields = {
_token: token,
parent_id: parentId,
subject: 'RE: Browser canned response',
commentBody: 'Nested browser response'
};
Object.entries(fields).forEach(([name, value]) => {
const input = document.createElement('input');
input.type = 'hidden';
input.name = name;
input.value = value || '';
form.appendChild(input);
});
document.body.appendChild(form);
form.submit();
JS);
$browser->waitForLocation('/helpdesk/tickets/' . $ticketId, 10);
}
private function setHelpdeskEditor(Browser $browser, string $dusk, string $html): void private function setHelpdeskEditor(Browser $browser, string $dusk, string $html): void
{ {
$encodedDusk = json_encode($dusk, JSON_THROW_ON_ERROR); $encodedDusk = json_encode($dusk, JSON_THROW_ON_ERROR);
@@ -8,6 +8,7 @@ use App\Models\User;
use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Hash; use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Schema; use Illuminate\Support\Facades\Schema;
use Illuminate\Support\Str;
use Modules\Helpdesk\Models\Category; use Modules\Helpdesk\Models\Category;
use Modules\Helpdesk\Models\GitRepository; use Modules\Helpdesk\Models\GitRepository;
use Modules\Helpdesk\Models\KanbanBoard; use Modules\Helpdesk\Models\KanbanBoard;
@@ -51,7 +52,7 @@ trait BuildsHelpdeskFixtures
{ {
return Status::query()->create(array_merge([ return Status::query()->create(array_merge([
'name' => 'Open', 'name' => 'Open',
'slug' => fake()->unique()->slug(2), 'slug' => 'test-' . Str::uuid()->toString(),
'color' => 'blue', 'color' => 'blue',
'sort_order' => 10, 'sort_order' => 10,
'is_closed' => false, 'is_closed' => false,
@@ -62,7 +63,7 @@ trait BuildsHelpdeskFixtures
{ {
return $this->ticketStatus(array_merge([ return $this->ticketStatus(array_merge([
'name' => 'Closed', 'name' => 'Closed',
'slug' => fake()->unique()->slug(2), 'slug' => 'test-' . Str::uuid()->toString(),
'color' => 'green', 'color' => 'green',
'sort_order' => 99, 'sort_order' => 99,
'is_closed' => true, 'is_closed' => true,
@@ -73,7 +74,7 @@ trait BuildsHelpdeskFixtures
{ {
return Priority::query()->create(array_merge([ return Priority::query()->create(array_merge([
'name' => 'Normal', 'name' => 'Normal',
'slug' => fake()->unique()->slug(2), 'slug' => 'test-' . Str::uuid()->toString(),
'color' => 'blue', 'color' => 'blue',
'sort_order' => 10, 'sort_order' => 10,
], $attributes)); ], $attributes));
@@ -84,7 +85,7 @@ trait BuildsHelpdeskFixtures
return Category::query()->create(array_merge([ return Category::query()->create(array_merge([
'company_id' => null, 'company_id' => null,
'name' => 'Support', 'name' => 'Support',
'slug' => fake()->unique()->slug(2), 'slug' => 'test-' . Str::uuid()->toString(),
'color' => 'blue', 'color' => 'blue',
'description' => 'Support requests', 'description' => 'Support requests',
], $attributes)); ], $attributes));
@@ -95,7 +96,7 @@ trait BuildsHelpdeskFixtures
return Team::query()->create(array_merge([ return Team::query()->create(array_merge([
'company_id' => null, 'company_id' => null,
'name' => 'Support Team', 'name' => 'Support Team',
'slug' => fake()->unique()->slug(2), 'slug' => 'test-' . Str::uuid()->toString(),
'color' => 'indigo', 'color' => 'indigo',
'description' => 'Primary support team', 'description' => 'Primary support team',
], $attributes)); ], $attributes));
@@ -107,7 +108,7 @@ trait BuildsHelpdeskFixtures
'company_id' => null, 'company_id' => null,
'team_id' => null, 'team_id' => null,
'title' => 'WMS Project', 'title' => 'WMS Project',
'slug' => fake()->unique()->slug(2), 'slug' => 'test-' . Str::uuid()->toString(),
'color' => 'blue', 'color' => 'blue',
'description' => 'Warehouse platform project', 'description' => 'Warehouse platform project',
], $attributes)); ], $attributes));