feat(topics): restore topic taxonomy workflow

This commit is contained in:
kate522 committed 2026-11-10 22:31:11 +08:00
1 parent f3dd1ec3b1
commit a254cbd3e9
59 files changed
+771 -192

No files matched your search

@@ -548,7 +548,8 @@ test('publish settings use a multi-select category picker and a creatable tag in
assert.match(category, /createPortal/);
assert.match(category, /type="checkbox"/);
assert.match(category, /onChange\(/);
assert.match(category, /选择分类(可多选)/);
assert.match(category, /选择%s(可多选)/);
assert.match(settings, /label=\{__\('专题', 'jio'\)\}/);
// 旧的分类平铺复选列表已移除(自定义分类法仍是复选标签,不受影响)。
assert.doesNotMatch(settings, /toggleCategory/);
assert.doesNotMatch(settings, /categories\.includes\(/);
@@ -11,7 +11,7 @@ test('modern widget schemas expose reference field names and defaults', () => {
for (const field of ['mini_opt', 'paginate', 'tabs', "'id' => 'cat'", "'id' => 'pay_type'", 'layout_ratio', 'slide_scale', 'm_layout_type', 'm_cover_ratio', 'image_layer', 'image_select']) {
assert.match(source, new RegExp(field.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')));
}
assert.doesNotMatch(source, /'id' => 'topics'/);
assert.match(source, /'id' => 'topics'/);
assert.match(source, /'热门推荐'.*'orderby' => 'views'/s);
assert.match(source, /'最近更新'.*'orderby' => 'modified'/s);
assert.match(source, /'猜你喜欢'.*'orderby' => 'rand'/s);
@@ -62,15 +62,15 @@ function topLevelFieldIds(name) {
return [...functionBody(name).matchAll(/self::field\('([^']+)'/g)].map(match => match[1])
}
test('page display exposes exactly eight ordered routes', () => {
const expected = ['header-nav', 'header-components', 'footer', 'homepage', 'category', 'tag', 'user-home', 'other']
test('page display exposes nine ordered routes', () => {
const expected = ['header-nav', 'header-components', 'footer', 'homepage', 'category', 'tag', 'topics', 'user-home', 'other']
const schemaOrder = [...schema.matchAll(/^\t\t\t\t'([^']+)'\s+=> self::/gm)].map(match => match[1])
assert.deepEqual(schemaOrder, expected)
const routeOrder = [...routes.matchAll(/section:\s*'([^']+)'/g)].map(match => match[1])
assert.deepEqual(routeOrder, expected)
})
test('top-level field IDs match the legacy V9.0 eight-page contract', () => {
test('top-level field IDs cover all nine page settings', () => {
assert.deepEqual(topLevelFieldIds('header_nav'), [
'header_theme_custom', 'header_theme_bg_custom', 'header_theme_bg', 'header_theme_color_custom',
'header_layout', 'mobile_header_layout', 'mobile_navbar_align', 'nav_fixed', 'nav_scroll_down_hide',
@@ -96,10 +96,17 @@ test('top-level field IDs match the legacy V9.0 eight-page contract', () => {
assert.deepEqual(topLevelFieldIds('category'), [
'page_cover_cat_s', 'cat_post_count_s', 'cat_default_cover', 'cat_orderby_s', 'cat_orderby_option',
'ajax_list_cat_cat', 'ajax_list_option_cat_cat', 'ajax_list_cat_tag', 'ajax_list_option_cat_tag',
'ajax_list_cat_topics', 'ajax_list_option_cat_topics',
])
assert.deepEqual(topLevelFieldIds('tag'), [
'tag_post_count_s', 'page_cover_tag_s', 'tag_default_cover', 'tag_orderby_s', 'tag_orderby_option',
'ajax_list_tag_cat', 'ajax_list_option_tag_cat', 'ajax_list_tag_tag', 'ajax_list_option_tag_tag',
'ajax_list_tag_topics', 'ajax_list_option_tag_topics',
])
assert.deepEqual(topLevelFieldIds('topics'), [
'topics_post_count_s', 'topics_default_cover', 'topics_orderby_s', 'topics_orderby_option',
'ajax_list_topics_cat', 'ajax_list_option_topics_cat', 'ajax_list_topics_tag',
'ajax_list_option_topics_tag', 'ajax_list_topics_topics', 'ajax_list_option_topics_topics',
])
assert.deepEqual(topLevelFieldIds('user_home'), ['author_main_tab_opt', 'author_main_tab_swiper'])
assert.deepEqual(topLevelFieldIds('other'), ['page_header_style', 'page_header_cover_img'])
@@ -115,7 +122,7 @@ test('defaults, nested structures, dependencies, and excluded product families a
assert.match(schema, /'header_slider_card_s'.*?'dependsOn' => self::not_empty\('header_slider_show'\)/)
assert.match(schema, /'header_slider_filter_blur'.*?'dependsOn' => self::not_empty\('header_slider_show'\)/)
assert.match(schema, /'all' => \[self::enabled\('home_posts_list_s'\), self::enabled\('home_list1_orderby_s'\)\]/)
for (const dead of ['nav_newposts_btns', 'forum_home', 'forum_plate', 'forum_post', 'ajax_list_cat_topics', 'ajax_list_tag_topics']) {
for (const dead of ['nav_newposts_btns', 'forum_home', 'forum_plate', 'forum_post']) {
assert.equal(schema.includes(dead), false, `legacy/excluded field remains: ${dead}`)
}
assert.equal(headerMenuButtons.includes('nav_newposts_btns'), false)
@@ -209,7 +216,7 @@ test('schema REST saves are privileged, section-whitelisted, and deeply sanitize
assert.match(provider, /wp_kses_post/)
assert.match(provider, /esc_url_raw/)
assert.match(provider, /has an invalid value/)
assert.match(controller, /search\/\(\?P<source>posts\|categories\|tags\)/)
assert.match(controller, /search\/\(\?P<source>posts\|categories\|tags\|topics\|terms\)/)
assert.match(controller, /'permission_callback' => \[\$this, 'check_permission'\]/)
})
@@ -13,15 +13,11 @@ const pay = read('inc/helpers/jio-pay.php')
const metabox = read('src/Core/PostMetaBox.php')
const resourceBox = read('src/Core/ResourceMetaBox.php')
test('quick and bulk edit boxes hook the post list with no topics column', () => {
// 参考主题把配置项挂在「专题」分类法列上;本项目没有专题,统一挂在互动数据列。
test('quick and bulk edit boxes hook the topics taxonomy column', () => {
assert.match(list, /quick_edit_custom_box/)
assert.match(list, /bulk_edit_custom_box/)
assert.match(list, /COLUMN_STATS/)
// 代码里不得再出现专题分类法列(类文档块的说明除外,只看 namespace 之后的部分)。
const code = list.slice(list.indexOf('namespace Jio'))
assert.doesNotMatch(code, /taxonomy-topics/)
assert.doesNotMatch(code, /topics/)
assert.match(code, /\$column_name !== 'taxonomy-topics'/)
})
test('every quick-edit field group is rendered', () => {
@@ -87,8 +87,8 @@ test('settings use legacy list modes, grouped options, and destructive related k
for (const key of legacyKeys) {
assert.equal(source.includes(key), false, `legacy article key remains: ${key}`);
}
// bare `topics` is legal again: the related-posts query mirrors the legacy taxonomy OR.
assert.doesNotMatch(source, /list_card_topics|is_topics/);
assert.match(listSchema, /list_card_topics: false/);
assert.match(source, /list_card_topics/);
});
test('forced mode wins and thumb_if_has ignores spare and lazy placeholders', () => {
@@ -275,7 +275,7 @@ test('related posts, author page and widgets use their dedicated renderers', ()
// 翻页 / 切 tab 是整页替换语义(author.js 最终就是 panel.innerHTML = html),
// 骨架必须独占内容区。若骨架只是追加在旧卡片下方,加载期会先看到
// 「第 1 页卡片 + 脚下一摞骨架」再换页。对齐参考主题 post_ajax() 的
// 「第 1 页卡片 + 脚下一摞骨架」再换页。
// beforeSend:replace 时 $item.remove() + find(pag).remove()。
// 刻意不按 data-view 收窄:card 模式下真实卡片同样是直接子级 .posts-item,
// 也要一起收起,否则卡片面板旧内容不会让位。
@@ -572,7 +572,7 @@ test('profile routes load versioned leaf styles and settings dialogs use the sha
assert.match(userCenterCreditsCss, /#panel-credits\.dashboard-panel\s*\{[^}]*background:\s*transparent;[^}]*box-shadow:\s*none;/);
assert.match(userCenterCreditsCss, /\.uc-asset-tabs\s*\{[^}]*background:\s*var\(--surface-1,\s*#fff\);[^}]*border:[^;}]+;[^}]*box-shadow:[^;}]+;/);
assert.doesNotMatch(profileCredits, /credits-signin\.php|data-jio-signin-calendar/);
// 签到详情弹窗为参考主题 1:1 结构(src/Credits/Signin.php),日历已随
// 签到详情弹窗的日历已随
// 旧版 lite 弹窗一并移除;用户中心里的孤儿渲染器也已整包移除。
assert.equal(fs.existsSync(path.join(root, 'inc/helpers/user-center-renderers/credits-signin.php')), false);
assert.doesNotMatch(userCenterCreditsCss + read('assets/css/frontend/enhancements/components/custom-amount.css'), /uc-signin-calendar/);
+7 -2
View File
@@ -113,7 +113,10 @@ final class WidgetSystemTest {
], 3);
$this->same('1,-2,3', $reference['cat'], 'reference cat preserves cleaned signed IDs for WP_Query descendant semantics');
$this->false(isset($reference['category__in']) || isset($reference['category__not_in']), 'reference cat does not narrow matches to direct categories');
$this->false(isset($reference['tax_query']), 'topic filters are removed with the topics feature');
$this->false(isset($reference['tax_query']), 'queries without a topic filter remain unrestricted');
$topic_query = PostQuery::arguments(['count' => 6, 'topics' => '7,8'], 1);
$this->same('topics', $topic_query['tax_query'][0]['taxonomy'], 'topic query uses the topics taxonomy');
$this->same([7, 8], $topic_query['tax_query'][0]['terms'], 'topic IDs reach the taxonomy query');
$this->same('jio_post_views', $reference['meta_key'], 'reference view ordering uses numeric view meta');
$this->false(isset($reference['meta_query']), 'modern reference queries do not apply commerce filters by default');
$this->same(1, $reference['paged'], 'no-pagination queries stay on first page');
@@ -148,7 +151,9 @@ final class WidgetSystemTest {
'order' => 'asc',
]]]);
$this->same('1,-2,3', $tab['tabs'][0]['cat'], 'tab cat keeps signed reference IDs');
$this->false(isset($tab['tabs'][0]['topics']), 'topic filters are gone from tab configuration');
$this->same('', $tab['tabs'][0]['topics'], 'tab exposes the topic filter');
$topic_tab = FieldSchema::normalize($tab_fields, ['tabs' => [['title' => '专题', 'topics' => '7,8']]]);
$this->same('7,8', $topic_tab['tabs'][0]['topics'], 'tab preserves selected topic IDs');
$this->same(['1', '6'], $tab['tabs'][0]['pay_type'], 'tab commerce filters are preserved');
$this->contains('<b>栏目</b>', $tab['tabs'][0]['title'], 'tab title keeps controlled HTML');
$this->false(str_contains($tab['tabs'][0]['title'], '<script>'), 'tab title strips unsafe HTML');
@@ -120,6 +120,7 @@ namespace {
function get_the_ID(): int { return (int) ($GLOBALS['tab_fixture_current_post']->ID ?? 0); }
function strip_shortcodes(string $value): string { return $value; }
function get_the_category(int $id = 0): array { unset($id); return []; }
function get_the_terms(int $id, string $taxonomy): array { unset($id, $taxonomy); return []; }
function get_the_tags(int $id = 0): array { unset($id); return []; }
function get_the_excerpt(int $id = 0): string { unset($id); return '首页通用文章列表的长摘要,这里只用于卡片和列表样式的内容渲染'; }
function get_post_field(string $field, int $id = 0, string $context = 'display'): string {