more tests fixes for duck tests

This commit is contained in:
Mark Gregory
2026-06-17 07:51:09 +01:00
parent 5ec593e802
commit 433a906699
7 changed files with 97 additions and 117 deletions
@@ -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);
}
}