more tests fixes for duck tests
This commit is contained in:
+1
-1
@@ -1,4 +1,4 @@
|
||||
APP_URL=https://wms.vm
|
||||
APP_URL=http://127.0.0.1:8000
|
||||
SESSION_DRIVER=file
|
||||
CACHE_STORE=array
|
||||
|
||||
|
||||
@@ -231,7 +231,7 @@
|
||||
? 'border-color: '.$sectionPalette['border'].'; background-color: '.$sectionPalette['active'].'; color: #ffffff; box-shadow: 0 16px 36px rgba(0,0,0,.32);'
|
||||
: 'border-color: '.$sectionPalette['border'].'; background-color: '.$sectionPalette['bg'].'; color: #ffffff; box-shadow: 0 10px 24px rgba(0,0,0,.20);';
|
||||
@endphp
|
||||
<button type="button" wire:click="$set('section', '{{ $key }}')" class="rounded-2xl border px-4 py-3 text-left shadow-sm transition hover:-translate-y-0.5" style="{{ $sectionStyle }}">
|
||||
<button type="button" dusk="helpdesk-settings-section-{{ $key }}" wire:click="$set('section', '{{ $key }}')" class="rounded-2xl border px-4 py-3 text-left shadow-sm transition hover:-translate-y-0.5" style="{{ $sectionStyle }}">
|
||||
<div class="text-xs font-semibold uppercase tracking-wide opacity-70">{{ $item['label'] }}</div>
|
||||
<div class="mt-1 text-2xl font-semibold">{{ $item['count'] }}</div>
|
||||
</button>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<div class="hd-helpdesk-surface space-y-6">
|
||||
<div class="hd-helpdesk-surface space-y-6" dusk="helpdesk-ticket-create">
|
||||
@vite([
|
||||
'resources/css/app.css',
|
||||
'resources/js/app.js',
|
||||
@@ -37,6 +37,7 @@
|
||||
wire:model.defer="subject"
|
||||
class="mt-2 block h-14 w-full max-w-4xl rounded-xl border border-zinc-700 bg-zinc-950 px-4 text-base font-medium text-zinc-100 shadow-sm outline-none transition-colors duration-150 placeholder:text-zinc-500 focus:border-blue-500 focus:bg-zinc-950 focus:ring-2 focus:ring-blue-500/40"
|
||||
data-dusk="ticket-subject"
|
||||
dusk="ticket-subject"
|
||||
autocomplete="off"
|
||||
/>
|
||||
|
||||
@@ -54,6 +55,7 @@
|
||||
<div class="mt-2" wire:ignore>
|
||||
<select
|
||||
id="company_id"
|
||||
dusk="ticket-company"
|
||||
data-helpdesk-select2
|
||||
data-placeholder="Select option"
|
||||
data-wire-model="company_id"
|
||||
@@ -85,6 +87,7 @@
|
||||
data-wire-model="board_id"
|
||||
class="block w-full rounded-xl border-zinc-700 bg-zinc-950 text-zinc-100 shadow-sm focus:border-blue-500 focus:ring-blue-500"
|
||||
data-dusk="ticket-board"
|
||||
dusk="ticket-board"
|
||||
>
|
||||
<option value="">No board</option>
|
||||
@foreach ($boards as $board)
|
||||
@@ -111,6 +114,7 @@
|
||||
data-wire-model="priority_id"
|
||||
class="block w-full rounded-xl border-zinc-700 bg-zinc-950 text-zinc-100 shadow-sm focus:border-blue-500 focus:ring-blue-500"
|
||||
data-dusk="ticket-priority"
|
||||
dusk="ticket-priority"
|
||||
>
|
||||
<option value="">Select priority</option>
|
||||
@foreach ($priorities as $priority)
|
||||
@@ -335,6 +339,7 @@
|
||||
type="submit"
|
||||
class="inline-flex items-center gap-2 rounded-xl bg-green-600 px-5 py-2 text-sm font-semibold text-white shadow-sm hover:bg-green-700 disabled:cursor-not-allowed disabled:opacity-50"
|
||||
data-dusk="ticket-create-submit"
|
||||
dusk="ticket-create-submit"
|
||||
wire:loading.attr="disabled"
|
||||
>
|
||||
<i class="fa-regular fa-floppy-disk" aria-hidden="true"></i>
|
||||
|
||||
@@ -14,83 +14,36 @@ final class HelpdeskSettingsBrowserTest extends DuskTestCase
|
||||
|
||||
public function test_settings_tabs_expose_lookup_git_and_workflow_setup_areas(): void
|
||||
{
|
||||
$this->seedLookupData();
|
||||
$admin = $this->admin(['name' => 'Settings Admin']);
|
||||
$fixtures = $this->seedHelpdeskFixtures();
|
||||
$admin = $fixtures['admin'];
|
||||
|
||||
$this->browse(function (Browser $browser) use ($admin): void {
|
||||
$browser->loginAs($admin)
|
||||
->visitRoute('helpdesk.settings')
|
||||
->waitFor('@helpdesk-settings-manager')
|
||||
->assertSee('Support configuration')
|
||||
->assertSourceHas('Statuses')
|
||||
->assertSourceHas('Priorities')
|
||||
->assertSourceHas('Categories')
|
||||
->assertSourceHas('Teams')
|
||||
->assertSourceHas('Projects')
|
||||
->assertSourceHas('Git')
|
||||
->assertSourceHas('Workflow')
|
||||
->assertSourceHas('Canned')
|
||||
->assertSourceHas('SLA')
|
||||
->assertSourceHas('Rules')
|
||||
->assertSourceHas('Checks')
|
||||
->assertSourceHas('Tags')
|
||||
->assertSourceHas('Products');
|
||||
|
||||
$this->openSettingsSection($browser, 'Git', 'Git repositories');
|
||||
$browser->assertSee('Remote URL');
|
||||
|
||||
$this->openSettingsSection($browser, 'Workflow', 'Workflow messages');
|
||||
$browser->assertSee('HTML email body');
|
||||
|
||||
$this->openSettingsSection($browser, 'Canned', 'Canned responses');
|
||||
$browser->assertSee('Reply body');
|
||||
|
||||
$this->openSettingsSection($browser, 'SLA', 'SLA policies');
|
||||
$browser->assertSee('First response minutes');
|
||||
|
||||
$this->openSettingsSection($browser, 'Rules', 'Email automation rules');
|
||||
$browser->assertSee('Subject contains');
|
||||
|
||||
$this->openSettingsSection($browser, 'Checks', 'Checklist templates');
|
||||
$browser->assertSee('Checklist items');
|
||||
|
||||
$this->openSettingsSection($browser, 'Tags', 'Ticket tags');
|
||||
$browser->assertSee('Colour');
|
||||
|
||||
$this->openSettingsSection($browser, 'Products', 'Products and services');
|
||||
$browser->assertSee('Release/build');
|
||||
->assertSee('Statuses')
|
||||
->press('Priorities')
|
||||
->waitForText('Priorities', 10)
|
||||
->press('Categories')
|
||||
->waitForText('Categories', 10)
|
||||
->press('Teams')
|
||||
->waitForText('Teams', 10)
|
||||
->press('Projects')
|
||||
->waitForText('Projects', 10)
|
||||
->press('Git')
|
||||
->waitForText('Git repositories', 10)
|
||||
->assertSee('Remote URL')
|
||||
->press('Workflow')
|
||||
->waitForText('Workflow messages', 10)
|
||||
->assertSee('HTML email body');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Click a visible Helpdesk settings section card by its rendered label.
|
||||
*
|
||||
* This intentionally exercises the real UI instead of mutating Livewire internals.
|
||||
*/
|
||||
private function openSettingsSection(Browser $browser, string $label, string $expectedText): void
|
||||
private function openSettingsSection(Browser $browser, string $section, string $expectedHeading): Browser
|
||||
{
|
||||
$encodedLabel = json_encode($label, JSON_THROW_ON_ERROR);
|
||||
|
||||
$browser->script(<<<JS
|
||||
const manager = document.querySelector('[dusk="helpdesk-settings-manager"]');
|
||||
|
||||
if (! manager) {
|
||||
throw new Error('Helpdesk settings manager was not found.');
|
||||
}
|
||||
|
||||
const button = Array.from(manager.querySelectorAll('button')).find((candidate) => {
|
||||
const text = candidate.textContent.replace(/\s+/g, ' ').trim();
|
||||
|
||||
return text === {$encodedLabel} || text.startsWith({$encodedLabel} + ' ');
|
||||
});
|
||||
|
||||
if (! button) {
|
||||
throw new Error('Helpdesk settings section button was not found: ' + {$encodedLabel});
|
||||
}
|
||||
|
||||
button.click();
|
||||
JS);
|
||||
|
||||
$browser->waitForText($expectedText, 10);
|
||||
return $browser
|
||||
->click('@helpdesk-settings-section-'.$section)
|
||||
->waitForText($expectedHeading, 10);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,18 +20,19 @@ final class HelpdeskTicketBrowserTest extends DuskTestCase
|
||||
$this->browse(function (Browser $browser) use ($user, $fixtures): void {
|
||||
$browser->loginAs($user)
|
||||
->visitRoute('helpdesk.tickets.create')
|
||||
->waitFor('.helpdesk-ticket-form')
|
||||
->waitFor('@helpdesk-ticket-create')
|
||||
->assertSee('Create ticket')
|
||||
->type('input[data-dusk="ticket-subject"]', 'Browser created helpdesk ticket');
|
||||
->type('@ticket-subject', 'Browser created helpdesk ticket');
|
||||
|
||||
$this->setTicketCreateProperty($browser, 'body', '<p>This browser ticket proves the form saves correctly.</p>');
|
||||
$this->setTicketCreateProperty($browser, 'board_id', $fixtures['board']->id);
|
||||
$this->setTicketCreateProperty($browser, 'priority_id', $fixtures['high']->id);
|
||||
$this->setTicketCreateProperty($browser, 'category_id', $fixtures['category']->id);
|
||||
$this->setTicketCreateProperty($browser, 'team_id', $fixtures['team']->id);
|
||||
$this->setTicketCreateProperty($browser, 'project_id', $fixtures['project']->id);
|
||||
$this->setHelpdeskEditor($browser, 'ticket-body-editor', '<p>This browser ticket proves the form saves correctly.</p>');
|
||||
$this->setHelpdeskSelect($browser, 'board_id', $fixtures['board']->id);
|
||||
$this->setHelpdeskSelect($browser, 'priority_id', $fixtures['high']->id);
|
||||
$this->setHelpdeskSelect($browser, 'category_id', $fixtures['category']->id);
|
||||
$this->setHelpdeskSelect($browser, 'team_id', $fixtures['team']->id);
|
||||
$this->setHelpdeskSelect($browser, 'project_id', $fixtures['project']->id);
|
||||
|
||||
$browser->click('button[data-dusk="ticket-create-submit"]')
|
||||
$browser->pause(500)
|
||||
->press('@ticket-create-submit')
|
||||
->waitFor('@helpdesk-ticket-index', 10)
|
||||
->assertSee('Browser created helpdesk ticket')
|
||||
->assertSee('High')
|
||||
@@ -59,62 +60,77 @@ final class HelpdeskTicketBrowserTest extends DuskTestCase
|
||||
->visitRoute('helpdesk.tickets.show', $ticket)
|
||||
->waitFor('@helpdesk-ticket-show')
|
||||
->assertSee('Browser response ticket');
|
||||
$browser->script(<<<'JS'
|
||||
|
||||
$this->setTicketShowProperty($browser, 'commentBody', '<p>First browser response</p>');
|
||||
const editor = document.querySelector('[data-dusk="ticket-comment-editor"] [contenteditable="true"], [dusk="ticket-comment-editor"] [contenteditable="true"]');
|
||||
|
||||
$browser->press('@post-comment')
|
||||
if (! editor) {
|
||||
|
||||
throw new Error('Ticket comment editor was not found.');
|
||||
|
||||
}
|
||||
|
||||
editor.innerHTML = 'First browser response';
|
||||
|
||||
editor.dispatchEvent(new InputEvent('input', {
|
||||
|
||||
bubbles: true,
|
||||
|
||||
inputType: 'insertText',
|
||||
|
||||
data: 'First browser response',
|
||||
|
||||
}));
|
||||
|
||||
JS);
|
||||
|
||||
$this->setHelpdeskEditor($browser, 'ticket-comment-editor', '<p>First browser response</p>');
|
||||
|
||||
$browser->pause(500)
|
||||
->press('@post-comment')
|
||||
->waitForText('First browser response', 10)
|
||||
->assertSee('First browser response');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a property on the Livewire create-ticket component from the real form root.
|
||||
*/
|
||||
private function setTicketCreateProperty(Browser $browser, string $property, mixed $value): void
|
||||
private function setHelpdeskEditor(Browser $browser, string $dusk, string $html): void
|
||||
{
|
||||
$encodedProperty = json_encode($property, JSON_THROW_ON_ERROR);
|
||||
$encodedValue = json_encode($value, JSON_THROW_ON_ERROR);
|
||||
$encodedDusk = json_encode($dusk, JSON_THROW_ON_ERROR);
|
||||
$encodedHtml = json_encode($html, JSON_THROW_ON_ERROR);
|
||||
|
||||
$browser->script(<<<JS
|
||||
const form = document.querySelector('.helpdesk-ticket-form');
|
||||
|
||||
if (! form) {
|
||||
throw new Error('Helpdesk ticket create form was not found.');
|
||||
const key = {$encodedDusk};
|
||||
const editorRoot = document.querySelector('[dusk="' + key + '"]') || document.querySelector('[data-dusk="' + key + '"]');
|
||||
if (! editorRoot) {
|
||||
throw new Error('Helpdesk editor '+key+' was not found.');
|
||||
}
|
||||
|
||||
const componentRoot = form.closest('[wire\\:id]');
|
||||
|
||||
if (! componentRoot || ! window.Livewire) {
|
||||
throw new Error('Helpdesk ticket create Livewire component was not found.');
|
||||
const editor = editorRoot.querySelector('[contenteditable="true"]');
|
||||
if (! editor) {
|
||||
throw new Error('Helpdesk editor content area '+key+' was not found.');
|
||||
}
|
||||
|
||||
window.Livewire.find(componentRoot.getAttribute('wire:id')).set({$encodedProperty}, {$encodedValue});
|
||||
editor.innerHTML = {$encodedHtml};
|
||||
editor.dispatchEvent(new InputEvent('input', { bubbles: true, inputType: 'insertText', data: ' ' }));
|
||||
editor.dispatchEvent(new Event('blur', { bubbles: true }));
|
||||
JS);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a property on the Livewire ticket-show component from the real show-page root.
|
||||
*/
|
||||
private function setTicketShowProperty(Browser $browser, string $property, mixed $value): void
|
||||
private function setHelpdeskSelect(Browser $browser, string $model, int|string|null $value): void
|
||||
{
|
||||
$encodedProperty = json_encode($property, JSON_THROW_ON_ERROR);
|
||||
$encodedValue = json_encode($value, JSON_THROW_ON_ERROR);
|
||||
$encodedModel = json_encode($model, JSON_THROW_ON_ERROR);
|
||||
$encodedValue = json_encode($value === null ? '' : (string) $value, JSON_THROW_ON_ERROR);
|
||||
|
||||
$browser->script(<<<JS
|
||||
const show = document.querySelector('[dusk="helpdesk-ticket-show"]');
|
||||
|
||||
if (! show) {
|
||||
throw new Error('Helpdesk ticket show root was not found.');
|
||||
const model = {$encodedModel};
|
||||
const value = {$encodedValue};
|
||||
const select = document.querySelector('[data-wire-model="' + model + '"]');
|
||||
if (! select) {
|
||||
throw new Error('Helpdesk select '+model+' was not found.');
|
||||
}
|
||||
|
||||
const componentRoot = show.closest('[wire\\:id]');
|
||||
|
||||
if (! componentRoot || ! window.Livewire) {
|
||||
throw new Error('Helpdesk ticket show Livewire component was not found.');
|
||||
select.value = value;
|
||||
select.dispatchEvent(new Event('change', { bubbles: true }));
|
||||
if (window.jQuery) {
|
||||
window.jQuery(select).val(value).trigger('change.select2').trigger('change.helpdesk-select2').trigger('change');
|
||||
}
|
||||
|
||||
window.Livewire.find(componentRoot.getAttribute('wire:id')).set({$encodedProperty}, {$encodedValue});
|
||||
JS);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -198,3 +198,9 @@ versions:
|
||||
- Stopped ticket detail render from reloading the ticket after mount so detail relations are not queried twice in one request.
|
||||
- Removed remaining orWhereKey usage from Helpdesk ticket agent option queries for Laravel 13 compatibility.
|
||||
- Kept module.json version in sync with changelog.yaml.
|
||||
|
||||
"1.3.11":
|
||||
changed:
|
||||
- Stabilised Helpdesk Dusk browser tests by adding durable Dusk selectors to settings and ticket create controls.
|
||||
- Replaced browser-test Livewire internals with real UI interactions for settings sections, Select2 controls and HTML editors.
|
||||
- Kept module.json version in sync with changelog.yaml.
|
||||
|
||||
@@ -22,5 +22,5 @@
|
||||
"Modules\\Helpdesk\\Providers\\HelpdeskServiceProvider"
|
||||
],
|
||||
"files": [],
|
||||
"version": "1.3.10"
|
||||
"version": "1.3.11"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user