Files
laralog/tests/Feature/ImportedContentTest.php
T
goukiandCursor ae47447062
Build and Deploy / verify (push) Successful in 40s
Build and Deploy / deploy (push) Successful in 36s
feat: restore sablog browse modes and clean imported HTML
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>
2026-09-18 21:33:02 +00:00

67 lines
1.9 KiB
PHP

<?php
namespace Tests\Feature;
use App\Models\Category;
use App\Models\Post;
use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
class ImportedContentTest extends TestCase
{
use RefreshDatabase;
private Post $post;
protected function setUp(): void
{
parent::setUp();
$this->seed();
$user = User::create(['name' => '作者', 'email' => 'import-html@test.com', 'password' => bcrypt('x')]);
$category = Category::create(['name' => '运维', 'slug' => 'ops']);
$html = '<p>&nbsp;不多说,上代码:</p>'
.'<div class="codeText"><div class="codeHead">XML/HTML代码</div>'
.'<ol class="dp-xml">'
.'<li>docker&nbsp;run -d\\</li>'
.'<li>&nbsp; --restart always \\</li>'
.'<li>&nbsp; --name derper</li>'
.'</ol></div>'
.'<div><div>curl -fsSL example.com \\</div><div>&nbsp; | sh</div></div>';
$this->post = Post::create([
'user_id' => $user->id,
'category_id' => $category->id,
'title' => '还是得derp',
'slug' => 'derp-import',
'excerpt' => '',
'content' => $html,
'content_format' => 'html',
'status' => 'published',
'published_at' => now(),
]);
}
public function test_show_page_hides_nbsp_and_wraps_code(): void
{
$this->get('/show-'.$this->post->id.'.shtml')
->assertOk()
->assertDontSee('&nbsp;', false)
->assertDontSee('codeText', false)
->assertSee('<pre', false)
->assertSee('docker run', false)
->assertSee('language-bash', false);
}
public function test_homepage_excerpt_does_not_show_nbsp(): void
{
$this->get('/')
->assertOk()
->assertSee('不多说,上代码', false)
->assertDontSee('&nbsp;', false);
}
}