Fold the four groups' import check into one dataset over every component view

Action/Input/Containment/NavigationStylesheetsTest.php each carried the same
"imports the stylesheet of every component its view renders" check on their
own group's dataset. StylesheetsTest.php now runs it once, over every
resources/views/components/*.blade.php backed by a stylesheet of its own
(icon and shape included, no longer needing a group to run in at all;
tabs/tab's shared stylesheet, N-16, still handled) — a new component gets
the check by existing, not by being added to the right group's array too.
Each group file keeps its own dataset for the checks that stay group-shaped
(shape, tokens, breakpoints, the block it imports from).

Plan step 42 (Phase F), Part A.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Qwx5USif3wFFmxtHg5U1g9
This commit is contained in:
Andreas Reinhold / reini
2026-09-15 09:38:25 +02:00
co-authored by Claude Sonnet 5
parent 4cf0997712
commit 34b77cfd31
5 changed files with 71 additions and 81 deletions
+47
View File
@@ -471,6 +471,53 @@ it('gives every component view a stylesheet, or lists it on a short, documented
}
});
/**
* Every component view the four group stylesheet tests (Action/Input/Containment/Navigation) used
* to check one at a time, in one dataset instead: every `resources/views/components/*.blade.php`
* backed by a `components/*.css` file of its own, `tabs` and `tab` folded into the one entry
* `imports…()` below already special-cases (they share tabs.css, N-16), `theme-script` (no
* stylesheet at all) and every layout component (the test above covers those) left out.
*
* @return list<string>
*/
function componentStylesheetViews(): array
{
// Plain glob(), not the File facade: dataset() below runs while the file is parsed, before
// Pest has booted the application the facade needs.
return collect(glob(__DIR__.'/../../resources/views/components/*.blade.php'))
->map(fn (string $file): string => basename($file, '.blade.php'))
->reject(fn (string $name): bool => in_array($name, ['theme-script', 'tab'], true))
->filter(fn (string $name): bool => is_file(__DIR__."/../../resources/css/components/{$name}.css"))
->values()
->all();
}
dataset('component stylesheet views', componentStylesheetViews());
it('imports, from every component stylesheet, the stylesheet of each component its view renders', function (string $name) {
// tabs.css is shared by two views, tabs.blade.php and tab.blade.php (N-16); every other
// component stylesheet in this dataset has exactly one view of its own name.
$views = $name === 'tabs' ? ['tabs', 'tab'] : [$name];
$rendered = collect($views)
->flatMap(function (string $view): array {
preg_match_all('/<x-livewire-material::([a-z-]+)/', File::get(__DIR__."/../../resources/views/components/{$view}.blade.php"), $tags);
return $tags[1];
})
->unique()
// A rendered tag that is not a components/ stylesheet at all (a layout component's, e.g.
// <x-pane>) has no import of its own to check here.
->filter(fn (string $tag): bool => is_file(stylesheetPath("components/{$tag}.css")) && str_contains(File::get(stylesheetPath("components/{$tag}.css")), '@layer material.components'))
->map(fn (string $tag): string => "./{$tag}.css")
->values()
->all();
$imports = stylesheetImports(stylesheetPath("components/{$name}.css"));
expect(array_values(array_diff($rendered, $imports)))->toBe([]);
})->with('component stylesheet views');
it('imports a stylesheet for every layout component from all.css, each beside its view', function () {
$imports = array_values(array_filter(
stylesheetImports(stylesheetPath('all.css')),