Press once whatever a second press would open over or undo
tests / feature (8.4) (push) Successful in 1m50s
tests / feature (8.5) (push) Successful in 1m54s
tests / browser (chrome, chromium) (push) Successful in 7m52s
tests / browser (firefox, firefox) (push) Successful in 11m56s
tests / browser (safari, webkit) (push) Successful in 12m35s
tests / feature (8.4) (push) Successful in 1m50s
tests / feature (8.5) (push) Successful in 1m54s
tests / browser (chrome, chromium) (push) Successful in 7m52s
tests / browser (firefox, firefox) (push) Successful in 11m56s
tests / browser (safari, webkit) (push) Successful in 12m35s
The browser plugin runs every call on a page again when its first attempt takes over a second, and on the runner a press can. For most presses that costs nothing. For two kinds it breaks the test: a press that opens a dialog, a sheet, a full-screen view or a modal rail over its own trigger, whose second press can never land, and a press that changes state a second one would change again — a menu trigger, a toggle, a chip, a range picker's day, a paging key, a Save. The bottom sheet with preset heights timed out on WebKit that way after the date picker had on Firefox. Every such press in the browser suite now goes through pressOnce(), 253 of them across sixteen files, not only the ones the runner happened to catch; focus moves inside an open view, Escape, links and plain "set" actions keep the retry, which is harmless for them. Two samples that were still racing the machine: - The standard side sheet's exit is caught half-way with its motion stretched, as every other mid-exit sample is, and fullSpeed() takes the stretch off again before the test times a reopen against the real exit. Under load on Linux WebKit it had failed two runs in five; it passes ten in ten. - The switch-and-checkbox row measures its widths once, so it now waits for the resize to land and the brand face to load before it does. Browser 300 passed on Firefox and WebKitGTK in a Linux container held to two busy cores, and on Chrome, Firefox and WebKit on macOS. Feature 1159 passed. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
ad230e0f48
commit
ebdc2ef2e1
@@ -73,8 +73,10 @@ it('runs a toast\'s action and dismisses it', function () {
|
||||
|
||||
$page->script("window.__undone = false; materialToast('Share deleted', { action: { label: 'Undo', handler: () => window.__undone = true } })");
|
||||
|
||||
$page->click('[x-data="materialSnackbar"] button:has-text("Undo")')
|
||||
->assertScript('window.__undone === true')
|
||||
// The Undo button vanishes once the toast is dismissed: pressOnce(), tests/Pest.php.
|
||||
pressOnce($page)->click('[x-data="materialSnackbar"] button:has-text("Undo")');
|
||||
|
||||
$page->assertScript('window.__undone === true')
|
||||
->assertScript(TOAST.' === null')
|
||||
->assertScript(SNACKBAR.' !== null');
|
||||
});
|
||||
@@ -112,16 +114,20 @@ it('keeps a sticky toast aside while a passing one shows, brings back the newest
|
||||
|
||||
$page->assertScript(TOAST."?.textContent.includes('Version 2 is ready')");
|
||||
|
||||
$page->click('[data-md-toast-dismiss]')
|
||||
->assertScript(TOAST.' === null');
|
||||
// The dismiss button vanishes with its toast: pressOnce(), tests/Pest.php.
|
||||
pressOnce($page)->click('[data-md-toast-dismiss]');
|
||||
|
||||
$page->assertScript(TOAST.' === null');
|
||||
|
||||
// Dismissed rather than left to time out: the pointer still rests where the snackbar appears,
|
||||
// and hovering pauses it.
|
||||
$page->script("window.eval(\"materialToast('Link copied', { timeout: 0 })\")");
|
||||
|
||||
$page->assertScript(TOAST."?.textContent.includes('Link copied')")
|
||||
->click('[data-md-toast-dismiss]')
|
||||
->assertScript(TOAST.' === null');
|
||||
$page->assertScript(TOAST."?.textContent.includes('Link copied')");
|
||||
|
||||
pressOnce($page)->click('[data-md-toast-dismiss]');
|
||||
|
||||
$page->assertScript(TOAST.' === null');
|
||||
});
|
||||
|
||||
it('dispatches a toast action\'s window event alongside its handler, and closes', function () {
|
||||
@@ -129,8 +135,10 @@ it('dispatches a toast action\'s window event alongside its handler, and closes'
|
||||
|
||||
$page->script("window.eval(\"window.reloads = 0; window.handled = 0; window.addEventListener('material:test-reload', () => window.reloads++); materialToast('A new version is ready', { sticky: true, action: { label: 'Reload', event: 'material:test-reload', handler: () => window.handled++ } })\")");
|
||||
|
||||
$page->click('[data-md-toast-action]')
|
||||
->assertScript(TOAST.' === null')
|
||||
// The action closes the toast: pressOnce(), tests/Pest.php.
|
||||
pressOnce($page)->click('[data-md-toast-action]');
|
||||
|
||||
$page->assertScript(TOAST.' === null')
|
||||
->assertScript("window.eval('window.reloads') === 1")
|
||||
->assertScript("window.eval('window.handled') === 1");
|
||||
});
|
||||
@@ -144,9 +152,12 @@ it('keeps an actioned snackbar on screen past the default timeout, until it is a
|
||||
$page->assertScript(TOAST."?.textContent.includes('Share deleted')")
|
||||
->wait(4.5);
|
||||
|
||||
$page->assertScript(TOAST."?.textContent.includes('Share deleted')")
|
||||
->click('[data-md-toast-dismiss]')
|
||||
->assertScript(TOAST.' === null');
|
||||
$page->assertScript(TOAST."?.textContent.includes('Share deleted')");
|
||||
|
||||
// The dismiss button vanishes with its toast: pressOnce(), tests/Pest.php.
|
||||
pressOnce($page)->click('[data-md-toast-dismiss]');
|
||||
|
||||
$page->assertScript(TOAST.' === null');
|
||||
});
|
||||
|
||||
it('dismisses a focused snackbar with Escape', function () {
|
||||
@@ -209,9 +220,12 @@ it('keeps a two-line snackbar\'s action on the title\'s row from 600px, wrapping
|
||||
it('opens a persistent rich tooltip on press', function () {
|
||||
$bubble = "document.querySelector('#communication [role=\"dialog\"][popover]')";
|
||||
|
||||
ready(visit('/material/communication'))
|
||||
->click('#communication button:has-text("Press for details")')
|
||||
->assertScript("{$bubble}.matches(':popover-open')");
|
||||
$page = ready(visit('/material/communication'));
|
||||
|
||||
// Opens the persistent tooltip over the button that triggers it: pressOnce(), tests/Pest.php.
|
||||
pressOnce($page)->click('#communication button:has-text("Press for details")');
|
||||
|
||||
$page->assertScript("{$bubble}.matches(':popover-open')");
|
||||
});
|
||||
|
||||
it('closes a transient rich tooltip 1.5s after focus leaves, not at once', function () {
|
||||
@@ -263,10 +277,14 @@ it('keeps a rich tooltip open while its action renders the component, and opens
|
||||
$page = ready(visit('/rich-tooltip-morph-probe'))
|
||||
->assertNoJavaScriptErrors();
|
||||
|
||||
$page->click('@details')
|
||||
->assertScript("{$persistent}.matches(':popover-open')")
|
||||
->click('@refresh')
|
||||
->assertSeeIn('#renders', '1')
|
||||
// Opens the tooltip, then a counter a retry would double: pressOnce(), tests/Pest.php.
|
||||
pressOnce($page)->click('@details');
|
||||
|
||||
$page->assertScript("{$persistent}.matches(':popover-open')");
|
||||
|
||||
pressOnce($page)->click('@refresh');
|
||||
|
||||
$page->assertSeeIn('#renders', '1')
|
||||
->assertScript("{$persistent}.matches(':popover-open')");
|
||||
|
||||
// Past the reopen guard (rich-tooltip.js's REOPEN_GUARD_MS), which takes a press this soon after
|
||||
@@ -275,8 +293,9 @@ it('keeps a rich tooltip open while its action renders the component, and opens
|
||||
->assertScript("! {$persistent}.matches(':popover-open')")
|
||||
->wait(0.3);
|
||||
|
||||
$page->click('@details')
|
||||
->assertScript("{$persistent}.matches(':popover-open')");
|
||||
pressOnce($page)->click('@details');
|
||||
|
||||
$page->assertScript("{$persistent}.matches(':popover-open')");
|
||||
|
||||
$page->click('#outside')
|
||||
->hover('@hint')
|
||||
@@ -292,9 +311,13 @@ it('fades a persistent rich tooltip out when a second press closes it', function
|
||||
// Slow tokens, so the exit copy (resources/js/popover-exit.js) is still on screen after the round trip.
|
||||
$page->script("document.head.insertAdjacentHTML('beforeend', '<style>:root { --md-sys-motion-effects-fast-duration: 1500ms; }</style>')");
|
||||
|
||||
$page->click('#communication button:has-text("Press for details")')
|
||||
->assertScript("{$bubble}.matches(':popover-open')")
|
||||
->click('#communication button:has-text("Press for details")')
|
||||
->assertScript("! {$bubble}.matches(':popover-open')")
|
||||
// The trigger toggles the tooltip, so each press is pressed once: pressOnce(), tests/Pest.php.
|
||||
pressOnce($page)->click('#communication button:has-text("Press for details")');
|
||||
|
||||
$page->assertScript("{$bubble}.matches(':popover-open')");
|
||||
|
||||
pressOnce($page)->click('#communication button:has-text("Press for details")');
|
||||
|
||||
$page->assertScript("! {$bubble}.matches(':popover-open')")
|
||||
->assertScript("(() => { const copy = document.querySelector('[data-md-popover-ghost]'); const opacity = copy && parseFloat(getComputedStyle(copy).opacity); return copy !== null && copy.hasAttribute('data-md-rich-tooltip-bubble') && copy.inert && opacity > 0.02 && opacity < 0.98; })()");
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user