waitForEvent('networkidle') ->assertScript("document.readyState === 'complete' && typeof window.Alpine !== 'undefined' && typeof window.Livewire !== 'undefined'"); $page->script("materialToast('First', { type: 'success', timeout: 600 }); materialToast('Second', { type: 'error' })"); $page->assertScript(SNACKBAR."?.textContent.includes('First')") ->assertScript(SNACKBAR."?.getAttribute('role') === 'status'"); $page->wait(1.2); $page->assertScript(SNACKBAR."?.textContent.includes('Second')") ->assertScript(SNACKBAR."?.getAttribute('role') === 'alert'"); }); it('shows a toast dispatched as a browser event, as the Toasts concern does', function () { $page = visit('/material/communication')->waitForEvent('networkidle') ->assertScript("document.readyState === 'complete' && typeof window.Alpine !== 'undefined' && typeof window.Livewire !== 'undefined'"); // Through Livewire, in the page's own realm: an event built inside Playwright's evaluate // carries a detail object Firefox's sandbox will not let the page read. $page->script("window.eval(\"Livewire.dispatch('toast', { type: 'info', title: 'Link copied', description: null, timeout: 4000 })\")"); $page->assertScript(SNACKBAR."?.textContent.includes('Link copied')"); }); it('runs a toast\'s action and dismisses it', function () { $page = visit('/material/communication')->waitForEvent('networkidle') ->assertScript("document.readyState === 'complete' && typeof window.Alpine !== 'undefined' && typeof window.Livewire !== 'undefined'"); $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') ->assertScript(SNACKBAR.' === null'); }); it('opens a persistent rich tooltip on press', function () { $bubble = "document.querySelector('#communication [role=\"dialog\"][popover]')"; visit('/material/communication')->waitForEvent('networkidle') ->assertScript("document.readyState === 'complete' && typeof window.Alpine !== 'undefined' && typeof window.Livewire !== 'undefined'") ->click('#communication button:has-text("Press for details")') ->assertScript("{$bubble}.matches(':popover-open')"); });