修复AJAX 引擎

This commit is contained in:
2026-08-23 18:01:56 +08:00
parent c4512f2bc2
commit 616beb8c03
8 changed files with 50 additions and 32 deletions
@@ -105,6 +105,24 @@ test('forced mode wins and thumb_if_has ignores spare and lazy placeholders', ()
assert.match(data, /has_post_format\(\['image', 'gallery'\]/);
});
test('category card mode carries its term id through archive, AJAX and REST rendering', () => {
const resolver = read('inc/helpers/aksrt-archive.php');
const config = read('inc/helpers/posts-renderer/config.php');
const admin = read('src/Admin/Admin.php');
const global = read('src/Admin/GlobalController.php');
assert.match(resolver, /'term_id'\s*=>\s*0/);
assert.match(resolver, /foreach \(\['type', 'term_id'/);
assert.match(resolver, /\$context === 'category' && !\$has_top_level_term_id && !\$has_override_term_id/);
assert.match(config, /!\$is_forced && !\$is_card && !empty\(\$args\['is_category'\]\)/);
assert.match(config, /\$term_id = absint\(\$args\['term_id'\]\)/);
assert.doesNotMatch(config, /get_queried_object_id/);
assert.match(admin, /\$clean\['term_id'\]\s*=\s*absint\(\$config\['term_id'\]\)/);
assert.match(global, /aksrt_resolve_post_list_render_config\(\[\s*'context'\s*=>\s*\$archive_type,\s*'term_id'\s*=>\s*\$archive_type === 'category' \? \$term_id : 0,/);
assert.doesNotMatch(config, /\b(?:list_scale|card_scale|mobile_meta)\b/);
assert.doesNotMatch(resolver, /aksrt_archive_get_list_style_settings/);
});
test('image resolution counts only content images and applies the configured WordPress size', () => {
const config = read('inc/helpers/posts-renderer/config.php');
const data = read('inc/helpers/posts-renderer/post-data.php');
@@ -216,7 +234,8 @@ test('related posts, author page and widgets use their dedicated renderers', ()
assert.match(resourceRelated, /aksrt_render_related_graphic_card/);
assert.doesNotMatch(resourceRelated, /aksrt_render_post_list/);
assert.match(author, /aksrt_render_post_list/);
assert.match(author, /'type'\s*=>\s*'list'/);
assert.doesNotMatch(author, /'type'\s*=>\s*'list'/);
assert.match(author, /'context'\s*=>\s*'author'/);
assert.match(author, /'no_author'\s*=>\s*true/);
assert.match(author, /'no_margin'\s*=>\s*true/);
assert.match(author, /'wrapper_class'\s*=>\s*'aksrt-user-home__post-list'/);
@@ -322,11 +341,13 @@ test('profile routes load versioned leaf styles and keep dialogs hidden initiall
assert.match(accountModals, /id="email-modal" class="aksrt-modal" hidden/);
assert.match(userCenterJs, /function closeModal\(m\)[\s\S]*?m\.hidden = true;/);
assert.match(userHomeCss, /\.aksrt-profile-details-modal\[hidden\]\s*\{\s*display:\s*none\s*!important;\s*\}/);
assert.match(userHomeCss, /\.aksrt-user-home \.aksrt-user-home__post-list \.posts-item\s*\{[^}]*background:\s*transparent;[^}]*box-shadow:\s*none;/);
assert.match(userHomeCss, /@media \(min-width: 992px\)\s*\{[\s\S]*?\.aksrt-user-home \.aksrt-user-home__post-list\s*\{[^}]*display:\s*grid;[^}]*grid-template-columns:\s*repeat\(2,\s*minmax\(0,\s*1fr\)\);/);
assert.match(userHomeCss, /@media \(min-width: 992px\)\s*\{[\s\S]*?\.aksrt-user-home \.aksrt-user-home__post-list > \.posts-item\s*\{[^}]*width:\s*auto;[^}]*margin:\s*0 !important;/);
assert.match(userHomeCss, /@media \(max-width: 767px\)\s*\{[\s\S]*?\.aksrt-user-home \.aksrt-user-home__post-list \.posts-item\s*\{[^}]*padding:\s*10px 0;/);
assert.match(userHomeCss, /\.aksrt-user-home \.aksrt-user-home__post-list\[data-view="list"\] \.posts-item\s*\{[^}]*background:\s*transparent;[^}]*box-shadow:\s*none;/);
assert.match(userHomeCss, /@media \(min-width: 992px\)\s*\{[\s\S]*?\.aksrt-user-home \.aksrt-user-home__post-list\[data-view="list"\]\s*\{[^}]*display:\s*grid;[^}]*grid-template-columns:\s*repeat\(2,\s*minmax\(0,\s*1fr\)\);/);
assert.match(userHomeCss, /@media \(min-width: 992px\)\s*\{[\s\S]*?\.aksrt-user-home \.aksrt-user-home__post-list\[data-view="list"\] > \.posts-item\s*\{[^}]*width:\s*auto;[^}]*margin:\s*0 !important;/);
assert.match(userHomeCss, /@media \(max-width: 767px\)\s*\{[\s\S]*?\.aksrt-user-home \.aksrt-user-home__post-list\[data-view="list"\] \.posts-item\s*\{[^}]*padding:\s*10px 0;/);
const panelFavorites = read('templates/parts/user-home/panel-favorites.php');
assert.doesNotMatch(panelFavorites, /'type'\s*=>\s*'list'/);
assert.match(panelFavorites, /'context'\s*=>\s*'author'/);
assert.match(panelFavorites, /aksrt_render_user_home_pagination\(\(int\) \$favorites_query->max_num_pages, \(int\) \$favorites_page\)/);
assert.match(panelFavorites, /array_merge\(\$user_home_render_config, \['wrapper_class' => 'aksrt-user-home__post-list'\]\), \$favorites_query\)/);
assert.doesNotMatch(panelFavorites, /profile-list-item|\$_GET|add_query_arg/);