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>
67 lines
1.9 KiB
PHP
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> 不多说,上代码:</p>'
|
|
.'<div class="codeText"><div class="codeHead">XML/HTML代码</div>'
|
|
.'<ol class="dp-xml">'
|
|
.'<li>docker run -d\\</li>'
|
|
.'<li> --restart always \\</li>'
|
|
.'<li> --name derper</li>'
|
|
.'</ol></div>'
|
|
.'<div><div>curl -fsSL example.com \\</div><div> | 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(' ', 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(' ', false);
|
|
}
|
|
}
|