Files
Andreas Reinhold / reiniandClaude Sonnet 5 925d9a4439 Fold layout.css and components.css into all.css
Plan step 37: all.css replaces the two interim import lists with one
entry for an application that wants everything — the foundation, every
layout stylesheet and every component stylesheet, grouped under the
same block comments components.css used, plus a Layout block. It also
directly imports the three files nothing imported by name before
(layout/spacing.css, layout/visibility.css, components/selection.css),
so every file under components/ and layout/ is now one @import away.

Every test that read a block of components.css or layout.css now reads
the matching block of all.css through one shared helper (allCssBlock(),
in tests/Pest.php so it loads for any test run) instead of repeating
the same substr() search in each file. StylesheetsTest.php's shape,
Tailwind-free and breakpoint checks, previously run twice (once for
the foundation, once for the layout tree), now run once over the whole
tree all.css reaches, since every component and layout stylesheet is
plain CSS after step 36; a new test asserts all.css imports everything
under components/ and layout/ exactly once. The Workbench imports
all.css in place of layout.css and components.css.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Qwx5USif3wFFmxtHg5U1g9
2026-09-15 02:49:29 +02:00

52 lines
2.1 KiB
PHP

<?php
use Illuminate\Support\Facades\File;
use NoNameWeb\LivewireMaterial\Tests\TestCase;
pest()->extend(TestCase::class)->in('Feature', 'Browser');
/**
* The element name (under `<`) and the attributes of the first tag in a rendered component, by
* name; a boolean attribute Blade renders as `name="name"`. For the layout components' render
* tests, which assert what their root carries.
*
* @return array<string, string>
*/
function layoutRoot(string $html): array
{
preg_match('/^\s*<([a-z]+)\b([^>]*)>/s', $html, $tag);
preg_match_all('/([\w:.@-]+)(?:="([^"]*)")?/', $tag[2] ?? '', $pairs, PREG_SET_ORDER);
return ['<' => $tag[1] ?? ''] + collect($pairs)->mapWithKeys(fn (array $pair): array => [$pair[1] => $pair[2] ?? ''])->all();
}
// 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);
}
/**
* The named block of resources/css/all.css — the content between its `/* Heading *\/` comment and
* the next one, or the end of the file for the last block ("Navigation"). components.css and
* layout.css grouped their imports the same way before plan step 37 folded both into all.css; this
* is the one place that block lookup lives now, so a stylesheet test asks "is this imported from
* the Containment block" without repeating the search in every file that needs it. It is here,
* rather than in tests/Feature/StylesheetsTest.php, because Pest.php is always loaded, whichever
* test file or path is run.
*/
function allCssBlock(string $heading): string
{
$all = File::get(__DIR__.'/../resources/css/all.css');
$marker = "/* {$heading} */";
$start = strpos($all, $marker);
if ($start === false) {
throw new RuntimeException("all.css has no `{$marker}` block.");
}
$next = strpos($all, '/*', $start + strlen($marker));
return $next === false ? substr($all, $start) : substr($all, $start, $next - $start);
}