Files
ad_testbed/tests/Feature/StylistIntegrationTest.php
Mark Gregory c15221c98f
tests / ci (push) Canceled after 0s
updates for active directory
2026-11-11 16:19:50 +00:00

70 lines
2.7 KiB
PHP

<?php
use App\Models\User;
use Illuminate\Filesystem\Filesystem;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Blade;
use Illuminate\Support\Facades\View;
use Illuminate\Support\Str;
use Modules\Stylist\Providers\StylistServiceProvider;
it('resolves backend theme views', function () {
expect(View::exists('dashboard'))->toBeTrue()
->and(View::exists('livewire.settings.security'))->toBeTrue()
->and(View::exists('livewire.settings.profile'))->toBeTrue();
});
it('registers the custom backend Flux icons', function () {
$html = Blade::render(
'<flux:icon.folder-git-2 />'
);
expect($html)->toContain('<svg');
});
it('renders the authenticated dashboard', function () {
$this->actingAs(User::factory()->create())
->get(route('dashboard'))
->assertOk();
});
it('renders the authenticated security settings', function () {
$this->actingAs(User::factory()->create())
->withSession(['auth.password_confirmed_at' => time()])
->get(route('security.edit'))
->assertOk();
});
it('resolves shared views using the request theme and preserves the backend layout namespace', function (string $uri, string $theme) {
$files = new Filesystem;
$root = sys_get_temp_dir().'/stylist-precedence-'.Str::uuid();
$request = Request::create($uri);
app()->instance('request', $request);
$console = new ReflectionProperty(app(), 'isRunningInConsole');
$console->setValue(app(), false);
try {
foreach (['frontend', 'backend'] as $key) {
$files->makeDirectory("$root/$key/views/layouts", recursive: true);
$files->copy(resource_path("themes/$key/theme.json"), "$root/$key/theme.json");
$files->put("$root/$key/views/layouts/app.blade.php", $key);
}
$files->put("$root/frontend/views/welcome.blade.php", 'welcome');
$files->put("$root/backend/views/dashboard.blade.php", 'dashboard');
config(['stylist.themes_path' => $root]);
app()->getProvider(StylistServiceProvider::class)->boot();
$finder = View::getFinder();
expect($finder->find('layouts.app'))->toBe("$root/$theme/views/layouts/app.blade.php")
->and($finder->find('layouts::app'))->toBe("$root/backend/views/layouts/app.blade.php")
->and($finder->find('welcome'))->toBe("$root/frontend/views/welcome.blade.php")
->and($finder->find('dashboard'))->toBe("$root/backend/views/dashboard.blade.php");
} finally {
$console->setValue(app(), true);
$files->deleteDirectory($root);
}
})->with([
'frontend request' => ['/', 'frontend'],
'backend request' => ['/dashboard', 'backend'],
]);