latest test updates
This commit is contained in:
@@ -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');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user