latest test updates

This commit is contained in:
Mark Gregory
2026-06-15 11:59:41 +01:00
parent 1fd9be097e
commit 330d6922a4
4 changed files with 88 additions and 20 deletions
@@ -33,11 +33,29 @@ trait InteractsWithWmsBrowser
protected function clickSidebarHref(Browser $browser, string $path): void
{
$browser->script(<<<JS
window.location.href = '{$path}';
JS);
$browser->script(sprintf(
<<<'JS'
const expectedPath = %s;
const links = Array.from(document.querySelectorAll('a'));
const link = links.find((candidate) => {
const href = candidate.getAttribute('href') || '';
try {
return new URL(href, window.location.origin).pathname === expectedPath;
} catch (error) {
return href === expectedPath || href.endsWith(expectedPath);
}
});
$browser->waitForLocation($path, 10);
if (link) {
link.click();
} else {
window.location.href = expectedPath;
}
JS,
json_encode($path, JSON_THROW_ON_ERROR)
));
$browser->waitForLocation($path, 15);
}
protected function openMobileNavigation(Browser $browser): void
@@ -45,15 +63,18 @@ trait InteractsWithWmsBrowser
$browser->resize(390, 844)
->waitFor('.wms-mobile-header', 10)
->assertVisible('.wms-mobile-header')
->assertVisible('[data-wms-mobile-open]')
->click('[data-wms-mobile-open]')
->waitUntil('document.documentElement.dataset.wmsMobileSidebar === "open"', 10)
->assertPresent('[data-wms-mobile-open]');
$browser->script('document.querySelector("[data-wms-mobile-open]")?.click();');
$browser->waitUntil('document.documentElement.dataset.wmsMobileSidebar === "open"', 10)
->assertAttribute('[data-wms-mobile-open]', 'aria-expanded', 'true');
}
protected function closeMobileNavigation(Browser $browser): void
{
$browser->script('document.querySelector("[data-wms-mobile-close]")?.click();');
$browser->waitUntil('document.documentElement.dataset.wmsMobileSidebar !== "open"', 10)
->assertAttribute('[data-wms-mobile-open]', 'aria-expanded', 'false');
}