Keep the public site readable after import (nbsp, highlighter, wrapping code, compact pager) and finish the admin extras already in this tree: sticky levels, preview, page cache, and live llms.txt. Co-authored-by: Cursor <cursoragent@cursor.com>
139 lines
4.3 KiB
PHP
139 lines
4.3 KiB
PHP
<?php
|
|
|
|
namespace Tests\Feature;
|
|
|
|
use App\Blog\Support\PluginManager;
|
|
use App\Filament\Support\AdminEnvironment;
|
|
use App\Models\User;
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
use Plugins\Demo\HelloWorld\ServiceProvider;
|
|
use Tests\TestCase;
|
|
|
|
class AdminPagesTest extends TestCase
|
|
{
|
|
use RefreshDatabase;
|
|
|
|
private User $admin;
|
|
|
|
protected function setUp(): void
|
|
{
|
|
parent::setUp();
|
|
|
|
$this->seed();
|
|
|
|
$this->admin = User::query()->firstOrCreate(
|
|
['email' => 'admin@laralog.test'],
|
|
['name' => '管理员', 'password' => bcrypt('password')]
|
|
);
|
|
}
|
|
|
|
public function test_dashboard_loads(): void
|
|
{
|
|
$this->actingAs($this->admin)->get('/admin')->assertOk();
|
|
}
|
|
|
|
public function test_post_resource_loads(): void
|
|
{
|
|
$this->actingAs($this->admin)->get('/admin/posts')->assertOk();
|
|
$this->actingAs($this->admin)->get('/admin/posts/create')
|
|
->assertOk()
|
|
->assertSee('Slug(留空自动生成)', false)
|
|
->assertSee('封面图', false)
|
|
->assertSee('ll-media-picker-preview', false)
|
|
->assertSee('评论状态', false)
|
|
->assertSee('访问设置', false)
|
|
->assertSee('会员专享', false)
|
|
->assertSee('价格', false)
|
|
->assertSee('置顶头条', false)
|
|
->assertSee('轻置顶', false);
|
|
}
|
|
|
|
public function test_settings_page_loads(): void
|
|
{
|
|
$this->actingAs($this->admin)
|
|
->get('/admin/blog-settings')
|
|
->assertOk()
|
|
->assertSee('首页浏览模式', false);
|
|
}
|
|
|
|
public function test_page_cache_and_language_pages_load(): void
|
|
{
|
|
$this->actingAs($this->admin)
|
|
->get('/admin/page-cache')
|
|
->assertOk()
|
|
->assertSee('页面缓存', false)
|
|
->assertSee('已缓存的前台页面', false);
|
|
|
|
$this->actingAs($this->admin)
|
|
->get('/admin/languages')
|
|
->assertOk()
|
|
->assertSee('文章多语言', false)
|
|
->assertSee('未开通', false);
|
|
}
|
|
|
|
public function test_comment_resource_loads(): void
|
|
{
|
|
$this->actingAs($this->admin)->get('/admin/comments')->assertOk();
|
|
}
|
|
|
|
public function test_media_resource_loads(): void
|
|
{
|
|
$this->actingAs($this->admin)->get('/admin/media')->assertOk();
|
|
}
|
|
|
|
public function test_media_library_resource_loads(): void
|
|
{
|
|
$this->actingAs($this->admin)->get('/admin/media-library')->assertOk();
|
|
$this->actingAs($this->admin)->get('/admin/media-folders')->assertOk();
|
|
$this->actingAs($this->admin)->get('/admin/posts/create')
|
|
->assertOk()
|
|
->assertSee('media:ID', false);
|
|
}
|
|
|
|
public function test_plugin_and_payment_pages_load(): void
|
|
{
|
|
$this->actingAs($this->admin)->get('/admin/plugins')->assertOk();
|
|
$this->actingAs($this->admin)->get('/admin/payments')->assertOk();
|
|
$this->actingAs($this->admin)->get('/admin/ai-settings')->assertOk();
|
|
$this->actingAs($this->admin)->get('/admin/redirects')->assertOk();
|
|
}
|
|
|
|
public function test_guest_is_redirected_to_login(): void
|
|
{
|
|
$this->get('/admin')->assertRedirect('/admin/login');
|
|
}
|
|
|
|
public function test_admin_environment_maps_production_to_prod(): void
|
|
{
|
|
$original = app()->environment();
|
|
app()['env'] = 'production';
|
|
|
|
$this->assertSame('prod', AdminEnvironment::name());
|
|
$this->assertSame('danger', AdminEnvironment::color());
|
|
|
|
app()['env'] = $original;
|
|
}
|
|
|
|
public function test_admin_topbar_shows_environment_and_create_post_button(): void
|
|
{
|
|
$this->actingAs($this->admin)
|
|
->get('/admin')
|
|
->assertOk()
|
|
->assertSee(AdminEnvironment::name(), false)
|
|
->assertSee('写文章', false)
|
|
->assertSee('网站', false)
|
|
->assertSee('/admin/posts/create', false);
|
|
}
|
|
|
|
public function test_hello_world_plugin_pages_load_when_enabled(): void
|
|
{
|
|
$manager = app(PluginManager::class);
|
|
$manager->enable('demo.hello-world');
|
|
ServiceProvider::bootPlugin($manager);
|
|
|
|
$this->actingAs($this->admin)->get('/admin')->assertOk();
|
|
$this->actingAs($this->admin)->get('/admin/posts/create')->assertOk();
|
|
$this->get('/hello-world')->assertOk();
|
|
}
|
|
}
|