diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index a9efa664..72cee4bc 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -115,3 +115,5 @@ jobs: - name: Run browser tests run: vendor/bin/pest --testsuite=Browser --browser ${{ matrix.browser }} + env: + BROWSER_TIMEOUT: 15000 diff --git a/tests/Browser/ThemeTest.php b/tests/Browser/ThemeTest.php index c1a69748..8a197d02 100644 --- a/tests/Browser/ThemeTest.php +++ b/tests/Browser/ThemeTest.php @@ -19,8 +19,10 @@ it('follows the operating system while the visitor has not chosen', function () }); it('keeps the visitor\'s choice over the operating system', function () { + // The theme switch waits for Alpine (x-cloak); a press before then would find nothing to press. $page = visit('/material')->inDarkMode() ->waitForEvent('networkidle') + ->assertScript("document.readyState === 'complete' && typeof window.Alpine !== 'undefined' && typeof window.Livewire !== 'undefined'") ->assertScript(theme('data-theme', 'dark')); $page->click('@theme-light') diff --git a/tests/Pest.php b/tests/Pest.php index 8a54bd45..ee795b8a 100644 --- a/tests/Pest.php +++ b/tests/Pest.php @@ -3,3 +3,9 @@ use NoNameWeb\LivewireMaterial\Tests\TestCase; pest()->extend(TestCase::class)->in('Feature', 'Browser'); + +// A shared CI runner is slower than a workstation: an animation or a smooth scroll can take longer +// than the default five seconds to settle there. BROWSER_TIMEOUT (milliseconds) raises the limit. +if (($timeout = (int) getenv('BROWSER_TIMEOUT')) > 0) { + pest()->browser()->timeout($timeout); +}