进行了一些小修复
This commit is contained in:
1 parent
ed1a47cf4e
commit
d4b7ec1deb
9 files changed
+1763
-80
No files matched your search
@@ -434,3 +434,62 @@ test('public user home stays param-free and swaps panels via REST fragments', ()
|
||||
assert.match(authorJs, /data-uh-sub/);
|
||||
assert.match(authorJs, /AksrtFrontend\.rehydrate\(panel, 'ajax'\)/);
|
||||
});
|
||||
|
||||
test('single articles enqueue only content and settings driven assets', () => {
|
||||
const enqueue = read('src/Core/ScriptsPart1b.php');
|
||||
const runtime = read('src/Core/ScriptsPart1c.php');
|
||||
const builder = read('tools/build-public-assets.mjs');
|
||||
const singleStart = enqueue.indexOf('// Normal articles: one small core bundle');
|
||||
const staticPageStart = enqueue.indexOf('// 静态页面 + 用户中心', singleStart);
|
||||
const singleBlock = enqueue.slice(singleStart, staticPageStart);
|
||||
|
||||
assert.ok(singleStart >= 0 && staticPageStart > singleStart);
|
||||
assert.match(builder, /'single\.css': \[[\s\S]*?single-post\/shell\.css'[\s\S]*?single-post\/content\.css'[\s\S]*?single-post\/author-actions\.css'/);
|
||||
assert.match(builder, /'comments\.css': \[[\s\S]*?comments\/shell\.css'[\s\S]*?comments\/mobile-item\.css'/);
|
||||
assert.match(singleBlock, /build\/single\.min\.css/);
|
||||
assert.match(singleBlock, /wp_register_style\([\s\S]*?'aksrt-single-post'[\s\S]*?array_merge\(\['aksrt-single-core'\], \$single_feature_handles\)/);
|
||||
assert.doesNotMatch(singleBlock, /\$enqueue_module\('single-post'\)|\$enqueue_module\('comments'\)/);
|
||||
|
||||
for (const requirement of [
|
||||
'has_code',
|
||||
'needs_navigation',
|
||||
'needs_cover',
|
||||
'needs_related_toc',
|
||||
'has_hidden_content',
|
||||
]) {
|
||||
assert.match(singleBlock, new RegExp(`'${requirement}'\\s*=>`));
|
||||
}
|
||||
|
||||
for (const requirement of [
|
||||
'needs_post_card',
|
||||
'needs_comments',
|
||||
'needs_sidebar',
|
||||
'needs_breadcrumb',
|
||||
]) {
|
||||
assert.match(singleBlock, new RegExp(`singular_assets\\['${requirement}'\\]`));
|
||||
}
|
||||
|
||||
assert.match(runtime, /wp:\(\?:code\|preformatted\|aksrt\\\/enlighter\)/);
|
||||
assert.match(runtime, /preg_match_all\('\/<h\[1-4\]/);
|
||||
assert.match(runtime, /data-aksrt-video/);
|
||||
assert.match(runtime, /post_password_required\(\$post_id\)/);
|
||||
assert.match(runtime, /comment_settings\['close_comments'\]/);
|
||||
assert.match(runtime, /comment_settings\['require_login'\]/);
|
||||
assert.match(runtime, /needs_reward'[\s\S]*?rewards_enabled/);
|
||||
assert.match(runtime, /needs_yiyan'[\s\S]*?yiyan_header/);
|
||||
assert.match(runtime, /needs_share'[\s\S]*?share_enabled/);
|
||||
|
||||
for (const requirement of [
|
||||
'has_code',
|
||||
'has_toc',
|
||||
'has_video',
|
||||
'needs_reward',
|
||||
'needs_yiyan',
|
||||
'needs_comments',
|
||||
'needs_comment_tools',
|
||||
'needs_page_template',
|
||||
'needs_share',
|
||||
]) {
|
||||
assert.match(runtime, new RegExp(`singular_assets\\['${requirement}'\\]`));
|
||||
}
|
||||
});
|
||||
Reference in new issue
Block a user