const assert = require('node:assert/strict'); const fs = require('node:fs'); const path = require('node:path'); const test = require('node:test'); const root = path.resolve(__dirname, '..', '..'); const read = (file) => fs.readFileSync(path.join(root, file), 'utf8'); test('block and classic editors share the reference article extension fields', () => { const meta = read('src/Core/PostMetaBox.php'); const fields = [ 'thumbnail_url', 'cover_image', 'featured_slide', 'featured_video', 'featured_video_title', 'featured_video_episode', 'subtitle', 'views', 'like', 'show_layout', 'no_article-navs', 'article_maxheight_xz', ]; assert.ok(meta.includes("add_meta_box('post_main', __('文章扩展'")); assert.match(meta, /\['post\.php', 'post-new\.php'\]/); assert.match(meta, /wp_enqueue_media\(\)/); fields.forEach((field) => assert.match(meta, new RegExp(field.replace('-', '\\-')))); assert.doesNotMatch(meta, /custom_excerpt|header_image_mode|show_reading_progress|enable_lightbox|enable_pdf|copyright_text|is_featured/); }); test('front submit follows the reference newposts shell and cards', () => { const page = read('templates/pages/page-submit.php'); const main = read('templates/parts/submit/editor-main.php'); const terms = read('templates/parts/submit/sidebar-terms.php'); const pay = read('templates/parts/submit/sidebar-pay.php'); const submit = read('templates/parts/submit/sidebar-submit.php'); const submitJs = read('assets/js/front-submit.js'); const submitCss = read('assets/css/frontend/pages/submit.css'); const publicCss = read('assets/css/build/public.min.css'); const mainCss = read('assets/css/main.css'); const layout = read('inc/helpers/template-tags/site-layout.php'); const mobileSubmitCss = submitCss.slice(submitCss.indexOf('@media (max-width: 991px)')); assert.match(page, /content-wrap newposts-wrap/); assert.match(page, /class="content-layout"/); assert.match(page, /<\/div>\s*<\/div>\s*
' \+ encoded \+ '<\/code><\/pre>'/);
assert.doesNotMatch(editor, /data-enlighter-language/);
assert.doesNotMatch(editor, /data-enlighter-theme/);
assert.doesNotMatch(editor, /enlighter-pre/);
assert.match(editor, /qe_wzk_c-red/);
assert.match(editor, /qe_wzk_lan/);
assert.match(editor, /qe_wzk_lv/);
assert.match(editorCss, /\.quote_q/);
assert.match(editorCss, /\.quote_q \[contenteditable="true"\][\s\S]*?box-shadow:\s*none/);
assert.match(editorCss, /\.file-download-box/);
assert.match(editorCss, /pre code \{/);
assert.doesNotMatch(editorCss, /\.enlighter-pre/);
assert.doesNotMatch(editor, /shop|forum|bbs_/i);
});
test('article paid-content metabox follows the reference field set without shop enhancements', () => {
const meta = read('src/Core/ResourceMetaBox.php');
const fields = [
'pay_type',
'pay_limit',
'pay_modo',
'order_expired_s',
'points_price',
'original_price',
'promotion_tag',
'gallery_show',
'video_episode',
'downloads',
'attributes',
'pay_doc',
'pay_details',
'pay_extra_hide',
];
assert.match(meta, /add_meta_box\('jio_pay_meta', __\('付费功能'/);
fields.forEach((field) => assert.match(meta, new RegExp(field)));
// video_scale_height 是参考主题轮播组件 widget 的参数,不属于付费视频字段,
// 当初误搬到付费 metabox 上且从未被消费,已移除。
assert.doesNotMatch(meta, /video_scale_height/);
assert.doesNotMatch(meta, /jio_pay_(?:stock|purchase_limit|card_keys|free_preview|require_login|require_captcha)/);
assert.doesNotMatch(meta, /电商增强|parse_json_array/);
});
test('ordinary article editor chain does not import shop or forum routes', () => {
const files = [
'src/Core/PostMetaBox.php',
'src/Core/FrontSubmit.php',
'src/Core/FrontSubmitSave.php',
'src/Core/FrontSubmitPay.php',
'src/Core/FrontSubmitFeatured.php',
'templates/pages/page-submit.php',
'templates/parts/submit/sidebar-pay.php',
];
const source = files.map(read).join('\n');
assert.doesNotMatch(source, /shop_product|forum_post|bbs_/i);
assert.doesNotMatch(source, /jiopay_s|featured_payload|vip_1_(?:price|points)|vip_2_(?:price|points)/);
});