test(admin): 站点管理页样式治理护栏(禁止 inline style)
This commit is contained in:
37
tests/Feature/AdminMerchantIndexUsesExternalCssTest.php
Normal file
37
tests/Feature/AdminMerchantIndexUsesExternalCssTest.php
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Tests\Feature;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||||
|
use Tests\TestCase;
|
||||||
|
|
||||||
|
class AdminMerchantIndexUsesExternalCssTest extends TestCase
|
||||||
|
{
|
||||||
|
use RefreshDatabase;
|
||||||
|
|
||||||
|
protected function loginAsPlatformAdmin(): void
|
||||||
|
{
|
||||||
|
$this->seed();
|
||||||
|
|
||||||
|
$this->post('/admin/login', [
|
||||||
|
'email' => 'platform.admin@demo.local',
|
||||||
|
'password' => 'Platform@123456',
|
||||||
|
])->assertRedirect('/admin');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_admin_merchants_index_should_not_include_inline_style_blocks(): void
|
||||||
|
{
|
||||||
|
$this->loginAsPlatformAdmin();
|
||||||
|
|
||||||
|
$res = $this->get('/admin/merchants');
|
||||||
|
$res->assertOk();
|
||||||
|
|
||||||
|
$html = (string) $res->getContent();
|
||||||
|
|
||||||
|
// 样式治理:后台页面不应新增大段 inline <style>
|
||||||
|
$this->assertStringNotContainsString('<style', $html);
|
||||||
|
|
||||||
|
// 并且应包含统一的后台样式文件
|
||||||
|
$this->assertStringContainsString('/css/admin-components.css', $html);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user