tests / feature (8.4) (push) Successful in 2m0s
tests / feature (8.5) (push) Successful in 2m0s
tests / browser (chrome, chromium) (push) Failing after 8m3s
tests / browser (firefox, firefox) (push) Failing after 12m58s
tests / browser (safari, webkit) (push) Failing after 13m8s
Tailwind left the stack in 2.0.0, but the package still carried about 330 mentions of it. What the guard's Tailwind detection protected — a class that compiles to nothing — is now protected by a check that does not care where a dead class came from. DesignGuard: about 500 lines of Tailwind tables, scales, palettes and "2.0.0 replacement" hints give way to one check — a class a view or PHP file writes that neither the application's stylesheets nor the package's own declare. It catches a utility of any framework, a typo and a class whose rules were deleted alike, so it also found two classes ReStride draws nothing with. A stylesheet has to be in reach for it: the `.css` files among the scanned paths, or what the `missingStylesheets()` entry imports. The class reader no longer mistakes an array index for a class list (`$block['base']`), and it reads the array a class helper is given, where it read nothing before. The package's own three Tailwind self-guards go with it. Only their one unique check stays, as a test of its own: every `matchMedia` width in resources/js is an M3 breakpoint. The pagination views are `material.blade.php` and `simple-material.blade.php`; only Laravel's and Livewire's default theme names ever made them `tailwind`. The provider sets `Paginator`'s default views and switches `livewire.pagination_theme` to `material` when it is still Livewire's own default, so no application can forget the config; a theme an application chose, and a component's own `$paginationTheme` or `paginationView()`, still win. The rest is prose: the layer-order guidance for an application that still builds Tailwind, the Tailwind wording in the README, the Boost guidelines and the development skill, and about 25 "this used to be a Tailwind utility" comments, along with every "plan step NN" pointer into a gitignored folder. The reset keeps its credit, and NOTICE now carries it too. Feature suite 1159 passed, Chrome browser suite 299 passed. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
77 lines
3.4 KiB
PHP
77 lines
3.4 KiB
PHP
<?php
|
|
|
|
use Illuminate\Support\Facades\Blade;
|
|
use Illuminate\Support\Facades\File;
|
|
use Illuminate\Support\Facades\View;
|
|
use NoNameWeb\LivewireMaterial\LivewireMaterialServiceProvider;
|
|
|
|
/**
|
|
* The package's own component names, longest first.
|
|
*
|
|
* @return list<string>
|
|
*/
|
|
function packageComponentNames(): array
|
|
{
|
|
return collect(File::files(LivewireMaterialServiceProvider::componentPath()))
|
|
->map(fn (SplFileInfo $file): string => $file->getBasename('.blade.php'))
|
|
->sortByDesc(fn (string $name): int => strlen($name))
|
|
->values()
|
|
->all();
|
|
}
|
|
|
|
it('refers to its own components through its namespace, which no prefix or app component changes', function () {
|
|
$names = implode('|', array_map(fn (string $name): string => preg_quote($name, '/'), packageComponentNames()));
|
|
|
|
$unqualified = collect(File::allFiles(__DIR__.'/../../resources/views'))
|
|
->filter(fn (SplFileInfo $file): bool => str_ends_with($file->getFilename(), '.blade.php'))
|
|
->flatMap(function (SplFileInfo $file) use ($names): array {
|
|
// Comments document usage as an application writes it, and the showcase's examples
|
|
// are that usage; neither is compiled as the package's own markup. An example heredoc
|
|
// ends `BLADE,` as an array's value (most sections) or `BLADE;` assigned to its own
|
|
// variable (a Layout page with a single example of its own).
|
|
$source = preg_replace(['/\{\{--.*?--\}\}/s', "/<<<'BLADE'.*?^\\s*BLADE[,;]/sm"], '', $file->getContents());
|
|
|
|
preg_match_all('/<\/?x-('.$names.')(?=[\s\/>])/', $source, $matches);
|
|
|
|
return array_map(fn (string $tag): string => $file->getRelativePathname().': '.$tag, $matches[0]);
|
|
})
|
|
->values();
|
|
|
|
expect($unqualified->all())->toBe([]);
|
|
});
|
|
|
|
it('renders components that use others under a prefix', function () {
|
|
config(['livewire-material.prefix' => 'm']);
|
|
|
|
Blade::anonymousComponentPath(LivewireMaterialServiceProvider::componentPath(), 'm');
|
|
|
|
expect(Blade::render('<x-m::drawer title="Share" with-close-button separator><x-m::input label="Name" clearable /></x-m::drawer>'))
|
|
->toContain('aria-label="Close"')
|
|
->toContain('role="separator"')
|
|
->toContain('data-md-field-clear');
|
|
});
|
|
|
|
it('is not shadowed by an application component of the same name', function () {
|
|
$views = sys_get_temp_dir().'/livewire-material-shadow-'.uniqid();
|
|
File::ensureDirectoryExists($views.'/components');
|
|
File::put($views.'/components/button.blade.php', '<span>the application\'s button</span>');
|
|
View::getFinder()->prependLocation($views);
|
|
|
|
try {
|
|
expect(Blade::render('<x-button />'))->toContain('the application\'s button')
|
|
->and(Blade::render('<x-drawer title="Share" with-close-button />'))->not->toContain('the application\'s button')
|
|
->toContain('aria-label="Close"');
|
|
} finally {
|
|
File::deleteDirectory($views);
|
|
}
|
|
});
|
|
|
|
it('shows the showcase\'s examples as an application with a prefix writes them', function () {
|
|
config(['livewire-material.prefix' => 'm']);
|
|
Blade::anonymousComponentPath(LivewireMaterialServiceProvider::componentPath(), 'm');
|
|
|
|
expect(Blade::render('<x-showcase::example title="Buttons" :code="$code" />', ['code' => '<x-button label="Save" />']))
|
|
->toContain('<x-m::button label="Save" />')
|
|
->toContain('Save</span>');
|
|
});
|