Scaffold the Livewire Material package
tests / lint (push) Successful in 1m14s
tests / feature (8.4) (push) Successful in 56s
tests / feature (8.5) (push) Successful in 56s
tests / browser (chrome, chromium) (push) Successful in 2m9s
tests / browser (firefox, firefox) (push) Successful in 1m34s
tests / browser (safari, webkit) (push) Successful in 1m41s
tests / lint (push) Successful in 1m14s
tests / feature (8.4) (push) Successful in 56s
tests / feature (8.5) (push) Successful in 56s
tests / browser (chrome, chromium) (push) Successful in 2m9s
tests / browser (firefox, firefox) (push) Successful in 1m34s
tests / browser (safari, webkit) (push) Successful in 1m41s
The skeleton for nonameweb/livewire-material: service provider and config (unprefixed components, blade-icons' own <x-icon> switched off, an opt-in showcase at /material), the Testbench Workbench with its Vite build, the CSS and JS entry points applications import, the Boost guideline and skill with a drift test, and Gitea CI running Pint, feature tests on PHP 8.4 and 8.5, and browser tests in Chrome, Firefox and Safari. The plan moved here from SealShare: docs/plans/livewire-material.md. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01V9NnLxnPp8vaaurb3Z1MFy
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
|
||||
it('opens the showcase in a real browser', function () {
|
||||
visit('/material')
|
||||
->assertSee('Livewire Material')
|
||||
->assertNoJavaScriptErrors();
|
||||
});
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\File;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
const SKILL_PATH = __DIR__.'/../../resources/boost/skills/livewire-material-development/SKILL.md';
|
||||
|
||||
it('gives the skill the frontmatter Boost requires', function () {
|
||||
$skill = File::get(SKILL_PATH);
|
||||
|
||||
expect($skill)
|
||||
->toStartWith("---\n")
|
||||
->toContain("\nname: livewire-material-development\n")
|
||||
->toMatch('/\ndescription: \S.+\n/');
|
||||
});
|
||||
|
||||
it('names every component in the skill', function () {
|
||||
$skill = File::get(SKILL_PATH);
|
||||
|
||||
$undocumented = collect(File::allFiles(__DIR__.'/../../resources/views/components'))
|
||||
->filter(fn (SplFileInfo $file): bool => str_ends_with($file->getFilename(), '.blade.php'))
|
||||
->map(fn (SplFileInfo $file): string => Str::of($file->getRelativePathname())
|
||||
->beforeLast('.blade.php')
|
||||
->replace(DIRECTORY_SEPARATOR, '.')
|
||||
->toString())
|
||||
->reject(fn (string $component): bool => str_contains($skill, "<x-{$component}"))
|
||||
->values();
|
||||
|
||||
expect($undocumented)->toBeEmpty();
|
||||
});
|
||||
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\Blade;
|
||||
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 without a prefix', function () {
|
||||
expect(packageComponentPaths())->toHaveCount(1)
|
||||
->and(packageComponentPaths()->first()['prefix'])->toBeNull();
|
||||
});
|
||||
|
||||
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');
|
||||
});
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Reboot the application with the showcase switched on or off. The routes are mounted
|
||||
* while the provider boots, so the flag has to be in the environment before that.
|
||||
*/
|
||||
function rebootWithShowcase(bool $enabled): void
|
||||
{
|
||||
$value = $enabled ? 'true' : 'false';
|
||||
|
||||
putenv("MATERIAL_SHOWCASE={$value}");
|
||||
$_ENV['MATERIAL_SHOWCASE'] = $_SERVER['MATERIAL_SHOWCASE'] = $value;
|
||||
|
||||
test()->refreshApplication();
|
||||
}
|
||||
|
||||
afterEach(function () {
|
||||
rebootWithShowcase(true);
|
||||
});
|
||||
|
||||
it('mounts the showcase when enabled', function () {
|
||||
$this->withoutVite()
|
||||
->get('/material')
|
||||
->assertOk()
|
||||
->assertSee('Livewire Material');
|
||||
});
|
||||
|
||||
it('does not mount the showcase when disabled', function () {
|
||||
rebootWithShowcase(false);
|
||||
|
||||
$this->get('/material')->assertNotFound();
|
||||
});
|
||||
@@ -0,0 +1,5 @@
|
||||
<?php
|
||||
|
||||
use NoNameWeb\LivewireMaterial\Tests\TestCase;
|
||||
|
||||
pest()->extend(TestCase::class)->in('Feature', 'Browser');
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace NoNameWeb\LivewireMaterial\Tests;
|
||||
|
||||
use Orchestra\Testbench\Concerns\WithWorkbench;
|
||||
use Orchestra\Testbench\TestCase as Orchestra;
|
||||
|
||||
use function Orchestra\Testbench\workbench_path;
|
||||
|
||||
abstract class TestCase extends Orchestra
|
||||
{
|
||||
use WithWorkbench;
|
||||
|
||||
/**
|
||||
* Serve the Workbench's built assets. `composer serve` links them into the skeleton
|
||||
* instead, but a browser test boots the application without that command.
|
||||
*/
|
||||
protected function defineEnvironment($app): void
|
||||
{
|
||||
$app->usePublicPath(workbench_path('public'));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user