more tests fixes
This commit is contained in:
+1
-1
@@ -1,4 +1,4 @@
|
||||
APP_URL=http://127.0.0.1:8000
|
||||
APP_URL=https://wms.vm
|
||||
SESSION_DRIVER=file
|
||||
CACHE_STORE=array
|
||||
|
||||
|
||||
@@ -36,57 +36,61 @@ final class HelpdeskSettingsBrowserTest extends DuskTestCase
|
||||
->assertSourceHas('Tags')
|
||||
->assertSourceHas('Products');
|
||||
|
||||
$this->setHelpdeskSettingsSection($browser, 'git');
|
||||
$browser->waitForText('Git repositories', 10)
|
||||
->assertSee('Remote URL');
|
||||
$this->openSettingsSection($browser, 'Git', 'Git repositories');
|
||||
$browser->assertSee('Remote URL');
|
||||
|
||||
$this->setHelpdeskSettingsSection($browser, 'workflow');
|
||||
$browser->waitForText('Workflow messages', 10)
|
||||
->assertSee('HTML email body');
|
||||
$this->openSettingsSection($browser, 'Workflow', 'Workflow messages');
|
||||
$browser->assertSee('HTML email body');
|
||||
|
||||
$this->setHelpdeskSettingsSection($browser, 'canned');
|
||||
$browser->waitForText('Canned responses', 10)
|
||||
->assertSee('Reply body');
|
||||
$this->openSettingsSection($browser, 'Canned', 'Canned responses');
|
||||
$browser->assertSee('Reply body');
|
||||
|
||||
$this->setHelpdeskSettingsSection($browser, 'sla');
|
||||
$browser->waitForText('SLA policies', 10)
|
||||
->assertSee('First response minutes');
|
||||
$this->openSettingsSection($browser, 'SLA', 'SLA policies');
|
||||
$browser->assertSee('First response minutes');
|
||||
|
||||
$this->setHelpdeskSettingsSection($browser, 'automation');
|
||||
$browser->waitForText('Email automation rules', 10)
|
||||
->assertSee('Subject contains');
|
||||
$this->openSettingsSection($browser, 'Rules', 'Email automation rules');
|
||||
$browser->assertSee('Subject contains');
|
||||
|
||||
$this->setHelpdeskSettingsSection($browser, 'checklists');
|
||||
$browser->waitForText('Checklist templates', 10)
|
||||
->assertSee('Checklist items');
|
||||
$this->openSettingsSection($browser, 'Checks', 'Checklist templates');
|
||||
$browser->assertSee('Checklist items');
|
||||
|
||||
$this->setHelpdeskSettingsSection($browser, 'tags');
|
||||
$browser->waitForText('Ticket tags', 10)
|
||||
->assertSee('Colour');
|
||||
$this->openSettingsSection($browser, 'Tags', 'Ticket tags');
|
||||
$browser->assertSee('Colour');
|
||||
|
||||
$this->setHelpdeskSettingsSection($browser, 'products');
|
||||
$browser->waitForText('Products and services', 10)
|
||||
->assertSee('Release/build');
|
||||
$this->openSettingsSection($browser, 'Products', 'Products and services');
|
||||
$browser->assertSee('Release/build');
|
||||
});
|
||||
}
|
||||
|
||||
private function setHelpdeskSettingsSection(Browser $browser, string $section): void
|
||||
/**
|
||||
* 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
|
||||
{
|
||||
$encodedSection = json_encode($section, JSON_THROW_ON_ERROR);
|
||||
$encodedLabel = json_encode($label, JSON_THROW_ON_ERROR);
|
||||
|
||||
$browser->script(<<<JS
|
||||
const settings = document.querySelector('[dusk="helpdesk-settings-manager"]');
|
||||
const manager = document.querySelector('[dusk="helpdesk-settings-manager"]');
|
||||
|
||||
let component = settings;
|
||||
while (component && ! component.hasAttribute('wire:id')) {
|
||||
component = component.parentElement;
|
||||
if (! manager) {
|
||||
throw new Error('Helpdesk settings manager was not found.');
|
||||
}
|
||||
|
||||
if (! component) {
|
||||
throw new Error('Helpdesk settings Livewire component 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});
|
||||
}
|
||||
|
||||
window.Livewire.find(component.getAttribute('wire:id')).set('section', {$encodedSection});
|
||||
button.click();
|
||||
JS);
|
||||
|
||||
$browser->waitForText($expectedText, 10);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,6 +68,9 @@ final class HelpdeskTicketBrowserTest extends DuskTestCase
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a property on the Livewire create-ticket component from the real form root.
|
||||
*/
|
||||
private function setTicketCreateProperty(Browser $browser, string $property, mixed $value): void
|
||||
{
|
||||
$encodedProperty = json_encode($property, JSON_THROW_ON_ERROR);
|
||||
@@ -76,19 +79,23 @@ final class HelpdeskTicketBrowserTest extends DuskTestCase
|
||||
$browser->script(<<<JS
|
||||
const form = document.querySelector('.helpdesk-ticket-form');
|
||||
|
||||
let component = form;
|
||||
while (component && ! component.hasAttribute('wire:id')) {
|
||||
component = component.parentElement;
|
||||
if (! form) {
|
||||
throw new Error('Helpdesk ticket create form was not found.');
|
||||
}
|
||||
|
||||
if (! component) {
|
||||
const componentRoot = form.closest('[wire\\:id]');
|
||||
|
||||
if (! componentRoot || ! window.Livewire) {
|
||||
throw new Error('Helpdesk ticket create Livewire component was not found.');
|
||||
}
|
||||
|
||||
window.Livewire.find(component.getAttribute('wire:id')).set({$encodedProperty}, {$encodedValue});
|
||||
window.Livewire.find(componentRoot.getAttribute('wire:id')).set({$encodedProperty}, {$encodedValue});
|
||||
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
|
||||
{
|
||||
$encodedProperty = json_encode($property, JSON_THROW_ON_ERROR);
|
||||
@@ -97,16 +104,17 @@ JS);
|
||||
$browser->script(<<<JS
|
||||
const show = document.querySelector('[dusk="helpdesk-ticket-show"]');
|
||||
|
||||
let component = show;
|
||||
while (component && ! component.hasAttribute('wire:id')) {
|
||||
component = component.parentElement;
|
||||
if (! show) {
|
||||
throw new Error('Helpdesk ticket show root was not found.');
|
||||
}
|
||||
|
||||
if (! component) {
|
||||
const componentRoot = show.closest('[wire\\:id]');
|
||||
|
||||
if (! componentRoot || ! window.Livewire) {
|
||||
throw new Error('Helpdesk ticket show Livewire component was not found.');
|
||||
}
|
||||
|
||||
window.Livewire.find(component.getAttribute('wire:id')).set({$encodedProperty}, {$encodedValue});
|
||||
window.Livewire.find(componentRoot.getAttribute('wire:id')).set({$encodedProperty}, {$encodedValue});
|
||||
JS);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -170,6 +170,7 @@
|
||||
"@php artisan dusk"
|
||||
],
|
||||
"dusk:serve": [
|
||||
"Composer\\Config::disableProcessTimeout",
|
||||
"php artisan serve --env=dusk.local --host=127.0.0.1 --port=8000"
|
||||
],
|
||||
"dusk:fresh": [
|
||||
|
||||
@@ -30,13 +30,15 @@ abstract class DuskTestCase extends BaseTestCase
|
||||
*/
|
||||
protected function driver(): RemoteWebDriver
|
||||
{
|
||||
$options = (new ChromeOptions)->addArguments([
|
||||
$options = (new ChromeOptions())->addArguments([
|
||||
'--disable-gpu',
|
||||
'--headless=new',
|
||||
'--window-size=1920,1080',
|
||||
'--no-sandbox',
|
||||
'--disable-dev-shm-usage',
|
||||
'--disable-search-engine-choice-screen',
|
||||
'--ignore-certificate-errors',
|
||||
'--allow-insecure-localhost',
|
||||
]);
|
||||
|
||||
return RemoteWebDriver::create(
|
||||
@@ -80,7 +82,8 @@ abstract class DuskTestCase extends BaseTestCase
|
||||
));
|
||||
|
||||
usort($candidates, static function (string $left, string $right): int {
|
||||
$score = static fn (string $path): int => str_contains($path, 'mac-arm64') ? 0
|
||||
$score = static fn (string $path): int =>
|
||||
str_contains($path, 'mac-arm64') ? 0
|
||||
: (str_contains($path, 'mac-arm') ? 1
|
||||
: (str_contains($path, 'mac') ? 2 : 3));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user