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>
125 lines
5.9 KiB
PHP
125 lines
5.9 KiB
PHP
<?php
|
|
|
|
use Illuminate\Pagination\LengthAwarePaginator;
|
|
use Illuminate\Pagination\Paginator;
|
|
use Illuminate\Support\Arr;
|
|
use Illuminate\Support\Collection;
|
|
use Illuminate\Support\Facades\Blade;
|
|
use Illuminate\Support\Facades\File;
|
|
use Illuminate\Support\ServiceProvider;
|
|
use NoNameWeb\LivewireMaterial\LivewireMaterialServiceProvider;
|
|
|
|
/**
|
|
* The anonymous component paths Blade holds for this package's components.
|
|
*
|
|
* @return Collection<int, array{path: string, prefix: ?string, prefixHash: string}>
|
|
*/
|
|
function packageComponentPaths(): Collection
|
|
{
|
|
$components = realpath(__DIR__.'/../../resources/views/components');
|
|
|
|
return collect(Blade::getAnonymousComponentPaths())
|
|
->filter(fn (array $entry): bool => realpath($entry['path']) === $components)
|
|
->values();
|
|
}
|
|
|
|
it('registers the components under its own name when no prefix is configured', function () {
|
|
expect(packageComponentPaths())->toHaveCount(1)
|
|
->and(packageComponentPaths()->first()['prefix'])->toBe('livewire-material')
|
|
->and(Blade::render('<x-badge value="New" tonal />'))->toContain('New');
|
|
});
|
|
|
|
it('compiles an unprefixed component to the same view on every machine', function () {
|
|
$compiled = Blade::compileString('<x-input label="Name" />');
|
|
|
|
expect($compiled)->toContain("'view' => '".hash('xxh128', 'livewire-material')."::input'")
|
|
->not->toContain(hash('xxh128', LivewireMaterialServiceProvider::componentPath()));
|
|
});
|
|
|
|
it('registers the components under a configured prefix', function () {
|
|
config(['livewire-material.prefix' => 'm']);
|
|
|
|
$provider = app()->getProvider(LivewireMaterialServiceProvider::class);
|
|
(fn () => $this->registerComponents())->call($provider);
|
|
|
|
expect(packageComponentPaths()->last()['prefix'])->toBe('m');
|
|
});
|
|
|
|
it('keeps blade-icons from registering an <x-icon> that would shadow ours', function () {
|
|
expect(Blade::getClassComponentAliases())->not->toHaveKey('icon');
|
|
});
|
|
|
|
it('publishes the error pages into the application\'s errors folder', function () {
|
|
expect(ServiceProvider::pathsToPublish(LivewireMaterialServiceProvider::class, 'livewire-material-errors'))->toBe([
|
|
LivewireMaterialServiceProvider::errorViewPath().'/errors' => resource_path('views/errors'),
|
|
]);
|
|
});
|
|
|
|
it('publishes the mail components where Laravel looks for them', function () {
|
|
expect(ServiceProvider::pathsToPublish(LivewireMaterialServiceProvider::class, 'livewire-material-mail'))->toBe([
|
|
LivewireMaterialServiceProvider::mailComponentPath().'/html' => resource_path('views/vendor/mail/html'),
|
|
LivewireMaterialServiceProvider::mailComponentPath().'/text' => resource_path('views/vendor/mail/text'),
|
|
])->and(config('mail.markdown.paths'))->toContain(resource_path('views/vendor/mail'));
|
|
|
|
expect(File::files(LivewireMaterialServiceProvider::mailComponentPath().'/html'))->not->toBeEmpty()
|
|
->and(File::files(LivewireMaterialServiceProvider::mailComponentPath().'/text'))->not->toBeEmpty();
|
|
});
|
|
|
|
/**
|
|
* Pagination: the provider takes over Laravel's and Livewire's default theme when
|
|
* `livewire-material.pagination` is on (the default), so `->links()` reaches the package's views
|
|
* without either framework being told which view to render.
|
|
*/
|
|
it('sets Paginator::defaultView() to the package\'s renamed views, so a plain ->links() call renders them', function () {
|
|
$pages = new LengthAwarePaginator(range(1, 10), 95, 10, 3, ['path' => '/shares']);
|
|
|
|
expect(Paginator::$defaultView)->toBe('pagination::material')
|
|
->and(Paginator::$defaultSimpleView)->toBe('pagination::simple-material')
|
|
->and((string) $pages->links())->toContain('data-md-pagination');
|
|
});
|
|
|
|
it('takes over livewire.pagination_theme only while it still reads as Livewire\'s own default', function (?string $before, string $after) {
|
|
if ($before === null) {
|
|
// Livewire's own SupportPagination.php reads the key with a `'tailwind'` fallback, so a
|
|
// missing key must be treated the same as an explicit `tailwind` — this is the "missing"
|
|
// half of that. Config::offsetUnset() only sets the key to null (Repository::set()), so
|
|
// the key is removed for real by rebuilding the array without it.
|
|
config(['livewire' => Arr::except(config('livewire'), ['pagination_theme'])]);
|
|
} else {
|
|
config(['livewire.pagination_theme' => $before]);
|
|
}
|
|
|
|
$provider = app()->getProvider(LivewireMaterialServiceProvider::class);
|
|
(fn () => $this->registerPagination())->call($provider);
|
|
|
|
expect(config('livewire.pagination_theme'))->toBe($after);
|
|
})->with([
|
|
'Livewire\'s default, unset' => [null, 'material'],
|
|
'Livewire\'s default, explicit' => ['tailwind', 'material'],
|
|
'already material' => ['material', 'material'],
|
|
'another theme, left alone' => ['bootstrap', 'bootstrap'],
|
|
]);
|
|
|
|
it('changes neither the default views nor the pagination theme when the config turns pagination off', function () {
|
|
$restoreView = Paginator::$defaultView;
|
|
$restoreSimpleView = Paginator::$defaultSimpleView;
|
|
|
|
try {
|
|
config(['livewire-material.pagination' => false, 'livewire.pagination_theme' => 'tailwind']);
|
|
Paginator::defaultView('pagination::tailwind');
|
|
Paginator::defaultSimpleView('pagination::simple-tailwind');
|
|
|
|
$provider = app()->getProvider(LivewireMaterialServiceProvider::class);
|
|
(fn () => $this->registerPagination())->call($provider);
|
|
|
|
expect(config('livewire.pagination_theme'))->toBe('tailwind')
|
|
->and(Paginator::$defaultView)->toBe('pagination::tailwind')
|
|
->and(Paginator::$defaultSimpleView)->toBe('pagination::simple-tailwind');
|
|
} finally {
|
|
// Both are global statics on Laravel's own class, outliving this test's app instance —
|
|
// left as 'tailwind' they would fail the file's other pagination tests that run after.
|
|
Paginator::defaultView($restoreView);
|
|
Paginator::defaultSimpleView($restoreSimpleView);
|
|
}
|
|
});
|