Run the design guard's smoke test with missingStylesheets(), as Blade resolves

Plan step 41 review: the committed smoke test scanned the package's views
without the stylesheet check, so the claim that the package, showcase and
Workbench pass it through all.css was untested; it now runs it, and
checks the showcase's plain tags do need imports from a foundation-only
entry, so the pass is not vacuous. Doing so exposed that a component class
one test evals leaked into every later check in the process: the shadow
check now guesses the class the way Blade does (Blade::component()
aliases, component namespaces, the application's own root namespace), and
the test gives its class a namespace of its own.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Qwx5USif3wFFmxtHg5U1g9
This commit is contained in:
Andreas Reinhold / reini
2026-09-15 08:50:13 +02:00
co-authored by Claude Opus 5
parent 2073480da4
commit 2d75091b82
2 changed files with 36 additions and 11 deletions
+12 -5
View File
@@ -486,8 +486,12 @@ it('reports a package tag the application shadows with its own anonymous compone
});
it('reports a package tag the application shadows with its own component class', function () {
if (! class_exists('App\View\Components\Card', false)) {
eval('namespace App\View\Components; class Card {}');
// Under a namespace of its own, which Blade's class guess reads from the application, so the
// class cannot shadow `<x-card>` for any later test in this process.
(fn () => $this->namespace = 'DesignGuardShadow\\')->call(app());
if (! class_exists('DesignGuardShadow\View\Components\Card', false)) {
eval('namespace DesignGuardShadow\View\Components; class Card {}');
}
$violations = fixtureRelative(DesignGuard::scan(realpath(GUARD_FIXTURES.'/stylesheets/views/shadow-class.blade.php'))
@@ -539,8 +543,11 @@ it('never reads a Tailwind-shaped word out of running text', function () {
expect($violations)->toBe([]);
});
it('passes the package\'s own views', function () {
$violations = DesignGuard::scan([__DIR__.'/../../resources/views', __DIR__.'/../../resources/js', __DIR__.'/../../src'])->violations();
it('passes the package\'s own views, showcase and Workbench, every stylesheet imported through all.css', function () {
$root = realpath(__DIR__.'/../..');
$paths = [$root.'/resources/views', $root.'/resources/js', $root.'/src', $root.'/workbench/resources'];
expect($violations)->toBe([]);
expect(DesignGuard::scan($paths)->missingStylesheets($root.'/resources/css/all.css')->violations())->toBe([])
// …and the stylesheet check is not vacuous there: the showcase's plain tags do need imports.
->and(DesignGuard::scan($root.'/resources/views/showcase')->missingStylesheets(realpath(GUARD_FIXTURES.'/stylesheets/foundation-only.css'))->violations())->not->toBe([]);
});