- 删除 AksrtFrontend registry/rehydrate 双路架构及 build/public.js 拼包入口,
前台唯一初始路径为 PHP 本地栈(jQuery 1.9.1 → Bootstrap 3.4.1)
→ loader_js(_win/aksrtData 唯一注入)→ tbquire(['main']) → runtime/main.min.js
- window.auto_fun = debounce(z_auto_fun, 100) 为唯一重扫入口;所有模块改为
执行一次 + off/on('auto_fun.aksrt-*') 命名空间重扫,data/class 标记幂等
- 局部更新协议统一:HTML 注入 → post_ajax.ed → auto_fun();
远程 modal → loaded.bs.modal → auto_fun();JSON 成功 → zib_ajax.success
- 灯箱恢复 Miniimgbox/imgbox 唯一 owner(imgbox-container、a[data-imgbox]、
imgbox_data),删除 AksrtLightbox/data-aksrt-lightbox 第二实现及 CSS/overlay,
_win.imgbox* 重新接上 post-display 设置
- 死代码清理:runtime 下 11 组被自有实现替代的旧模块副本、无消费 vendored 库、
顶层 grade.min.js、revenue.js、无调用方的 aksrt_get_win_runtime_config(),
以及 loader 中 16 条死 mapping
- PHP 入队改为本地栈 + loader_js,routed/widget/submit 依赖统一换绑;
用户卡片发布按钮恢复 nav_user_newposts_btn 设置门控
- 测试对齐:新增 frontend-lifecycle-contract,重写 navigation/lazyload/toast/
auth-source/comment/page-display/post-visual 等断言为目标架构契约
验证:node --test widget-system+navigation 223 通过 0 失败;
构建脚本重建 main/imgbox min 与 CSS bundles;改动 PHP php -l、JS node --check
全部通过;git diff --check 干净;credits 重入 harness 通过。
279 lines
13 KiB
JavaScript
279 lines
13 KiB
JavaScript
'use strict';
|
|
|
|
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');
|
|
const join = (files) => files.map(read).join('\n');
|
|
const exists = (file) => fs.existsSync(path.join(root, file));
|
|
const listFiles = (directory, extensions) => {
|
|
const base = path.join(root, directory);
|
|
const files = [];
|
|
const walk = (current) => {
|
|
for (const entry of fs.readdirSync(current, { withFileTypes: true })) {
|
|
if (['build', 'node_modules', 'third-party'].includes(entry.name)) continue;
|
|
const absolute = path.join(current, entry.name);
|
|
if (entry.isDirectory()) walk(absolute);
|
|
else if (extensions.has(path.extname(entry.name))) files.push(path.relative(root, absolute));
|
|
}
|
|
};
|
|
walk(base);
|
|
return files;
|
|
};
|
|
|
|
const scripts = join([
|
|
'src/Core/ScriptsPart1b.php',
|
|
'src/Core/ScriptsPart1c.php',
|
|
]);
|
|
const header = join([
|
|
'header.php',
|
|
'inc/helpers/header/aksrt-header-render.php',
|
|
'inc/helpers/header/aksrt-header-navbar.php',
|
|
'inc/helpers/header/aksrt-header-mobile.php',
|
|
'inc/helpers/aksrt-header-menu-buttons.php',
|
|
'inc/helpers/aksrt-header-userbox.php',
|
|
]);
|
|
|
|
test('the public dependency graph is the single local runtime stack', () => {
|
|
assert.match(scripts, /wp_deregister_script\('jquery'\)/);
|
|
assert.match(scripts, /jquery\.min\.js'[\s\S]*?'1\.9\.1'/);
|
|
assert.match(scripts, /bootstrap\.min\.css'[\s\S]*?'3\.4\.1'/);
|
|
assert.match(scripts, /fontawesome5'[\s\S]*?all\.min\.css'[\s\S]*?'5\.15\.4'/);
|
|
assert.match(scripts, /main\.min\.css/);
|
|
assert.match(scripts, /loader\.js'[\s\S]*?\['jquery', 'bootstrap'\]/);
|
|
assert.match(read('assets/js/runtime/loader.js'), /tbquire\(\['main'\]\)/);
|
|
for (const file of [
|
|
'assets/js/runtime/libs/jquery.min.js',
|
|
'assets/js/runtime/libs/bootstrap.min.js',
|
|
'assets/css/bootstrap.min.css',
|
|
'assets/fontawesome5/css/all.min.css',
|
|
'assets/css/main.min.css',
|
|
'assets/js/runtime/loader.js',
|
|
'assets/js/runtime/main.min.js',
|
|
]) assert.equal(exists(file), true, `${file} must be local`);
|
|
|
|
assert.doesNotMatch(scripts, /bootstrap5|bootstrap-5|font-awesome\.min\.css|swiper(?:\.min)?\.(?:css|js)|aksrt-mini-touch/);
|
|
assert.equal(exists('assets/css/frontend/nav.css'), false);
|
|
assert.equal(exists('assets/js/core/nav.js'), false);
|
|
assert.equal(exists('assets/js/core/search.js'), false);
|
|
assert.equal(exists('assets/js/core/scroll.js'), false);
|
|
assert.equal(exists('assets/js/core/slider.js'), false);
|
|
assert.equal(exists('assets/js/mini-touch.js'), false);
|
|
});
|
|
|
|
test('payment entry points use only the AKSRT payment runtime', () => {
|
|
const loader = read('assets/js/runtime/loader.js');
|
|
const main = join([
|
|
'assets/js/runtime/main.js',
|
|
'assets/js/runtime/main.min.js',
|
|
]);
|
|
const paymentRuntime = join([
|
|
'assets/js/pay-vip.js',
|
|
'assets/js/cms-download.js',
|
|
'src/Core/ScriptsPart1b.php',
|
|
]);
|
|
|
|
assert.doesNotMatch(loader, /['"]pay['"]\s*:/);
|
|
assert.doesNotMatch(main, /tbquire\(\[['"]pay['"]\]\)/);
|
|
assert.doesNotMatch(main, /indexOf\(['"]zippay['"]\)/);
|
|
assert.match(paymentRuntime, /\.pay-vip/);
|
|
assert.match(paymentRuntime, /data-aksrt-pay-content/);
|
|
assert.match(paymentRuntime, /'aksrt-pay-vip'/);
|
|
assert.match(paymentRuntime, /'aksrt-cms-download'/);
|
|
});
|
|
|
|
test('Font Awesome 5 is the only icon contract across every runtime path', () => {
|
|
const extensions = new Set(['.php', '.js', '.vue']);
|
|
const runtimeFiles = [
|
|
...fs.readdirSync(root)
|
|
.filter((file) => path.extname(file) === '.php'),
|
|
...listFiles('src', extensions),
|
|
...listFiles('inc', extensions),
|
|
...listFiles('templates', extensions),
|
|
...listFiles('assets/js', extensions),
|
|
...listFiles('assets/admin/src', extensions),
|
|
];
|
|
const runtime = join(runtimeFiles);
|
|
const iconCss = join([
|
|
...listFiles('assets/css', new Set(['.css'])),
|
|
]);
|
|
const fa5 = read('assets/fontawesome5/css/all.min.css');
|
|
const iconTokens = new Set([...runtime.matchAll(/\bfa-[a-z0-9]+(?:-[a-z0-9]+)*\b/g)].map((match) => match[0]));
|
|
const utility = /^fa-(?:xs|sm|lg|[2-9]x|10x|fw|ul|li|border|pull-left|pull-right|spin|pulse|rotate|rotate-(?:90|180|270)|flip|flip-(?:horizontal|vertical|both)|stack|stack-1x|stack-2x|inverse|sr-only|sr-only-focusable)$/;
|
|
const custom = new Set([
|
|
'fa-chevron', 'fa-icon', 'fa-icon-picker', 'fa-icons', 'fa-input',
|
|
'fa-mask', 'fa-spin-hover', 'fa-toggle-theme', 'fa-xxx',
|
|
]);
|
|
|
|
assert.doesNotMatch(runtime, /\bfa fa-/);
|
|
assert.doesNotMatch(runtime, /FontAwesome|font-awesome\.min\.css|Font Awesome 4|4\.7\.0/);
|
|
assert.doesNotMatch(iconCss, /FontAwesome|font-awesome\.min\.css|Font Awesome 4|4\.7\.0/);
|
|
assert.doesNotMatch(iconCss, /font:\s*normal\s+normal\s+normal\s+[^;]+Font Awesome 5 Free/);
|
|
assert.equal(exists('assets/css/font-awesome.min.css'), false);
|
|
for (const token of iconTokens) {
|
|
if (utility.test(token) || custom.has(token)) continue;
|
|
assert.ok(fa5.includes(`.${token}:before`), `${token} is not available in Font Awesome 5.15.4`);
|
|
}
|
|
});
|
|
|
|
test('header output owns all three layouts and reference state classes', () => {
|
|
assert.match(header, /header-layout-'\s*\.\s*\$layout/);
|
|
assert.match(header, /in_array\(\$layout, \[['"]1['"], ['"]2['"], ['"]3['"]\], true\)/);
|
|
assert.match(header, /navbar-top/);
|
|
assert.match(header, /container-header/);
|
|
assert.match(header, /nav_fixed/);
|
|
assert.match(header, /nav_scroll_down_hide/);
|
|
assert.match(header, /nav-fixed/);
|
|
assert.match(header, /show-slide/);
|
|
assert.match(header, /main-search-btn/);
|
|
assert.doesNotMatch(header, /data-bs-|navbar-expand|offcanvas/);
|
|
});
|
|
|
|
test('mobile navigation is one setting-driven left right or top drawer', () => {
|
|
assert.match(header, /mobile_navbar_align/);
|
|
for (const align of ['left', 'right', 'top']) {
|
|
assert.match(header, new RegExp(`'${align}'`));
|
|
}
|
|
assert.match(header, /mini-touch="mobile-nav"/);
|
|
assert.match(header, /touch-direction/);
|
|
assert.match(header, /mobile-navbar-show/);
|
|
assert.match(header, /class="mobile-navbar visible-xs-block scroll-y mini-scrollbar/);
|
|
assert.match(header, /class="fixed-body" data-toggle-class="mobile-navbar-show"/);
|
|
});
|
|
|
|
test('guest account member VIP and publish contracts share reference header DOM', () => {
|
|
const userboxCss = read('assets/css/frontend/header-userbox.css');
|
|
|
|
assert.match(header, /is_user_logged_in\(\)/);
|
|
assert.match(header, /sub-user-box aksrt-header-userbox/);
|
|
assert.match(header, /signin-loader|signin/);
|
|
assert.match(header, /get_payment_vip_settings/);
|
|
assert.match(header, /nav_user_newposts_btn/);
|
|
assert.match(header, /nav_newposts/);
|
|
assert.match(header, /navbar-form navbar-right navbar-but/);
|
|
assert.match(header, /pay-vip/);
|
|
assert.match(scripts, /\$enqueue_module\('header-userbox'\)/);
|
|
assert.match(userboxCss, /\.aksrt-header-userbox \.user-info > \.avatar/);
|
|
assert.match(userboxCss, /\.aksrt-header-wallet/);
|
|
assert.match(userboxCss, /\.aksrt-header-checkin/);
|
|
assert.match(userboxCss, /\.aksrt-header-payvip__cta/);
|
|
assert.match(userboxCss, /\.header-user-href > a[\s\S]*?max-height: none/);
|
|
assert.match(userboxCss, /body\.dark-theme \.aksrt-header-checkin/);
|
|
assert.doesNotMatch(userboxCss, /user-dropdown|nav-user|html\.dark|theme-dark/);
|
|
assert.doesNotMatch(userboxCss, /--(?:main|muted|key)-|@import/);
|
|
});
|
|
|
|
test('the only menu metadata and Walker contract is the legacy runtime', () => {
|
|
const walker = read('src/Frontend/NavWalker.php');
|
|
const menuAdmin = read('src/Admin/NavMenuOptions.php');
|
|
const decoration = read('inc/helpers/menu-decoration.php');
|
|
const source = walker + menuAdmin + decoration;
|
|
|
|
assert.match(source, /aksrt_menu_options/);
|
|
assert.doesNotMatch(source, /zib_menu_options/);
|
|
assert.match(walker, /start_lvl|start_el|end_el/);
|
|
assert.match(walker, /submenu_graphic_card/);
|
|
assert.match(walker, /submenu_multi_column_links/);
|
|
assert.match(walker, /senior-submenu/);
|
|
assert.match(walker, /swiper-container swiper-scroll/);
|
|
assert.match(walker, /swiper-wrapper/);
|
|
assert.match(walker, /show-nav-but|collapse|submenu_s/);
|
|
assert.match(menuAdmin, /graphic_card_opts_json/);
|
|
assert.match(menuAdmin, /multi_column_links_opts_json/);
|
|
});
|
|
|
|
test('search is footer-lazy and exposes only reference actions and request fields', () => {
|
|
const shell = read('inc/helpers/header/aksrt-header-menu-search.php');
|
|
const box = read('inc/helpers/search/aksrt-search-box.php');
|
|
const results = read('search.php');
|
|
const settings = read('src/Settings/ThemeSearch.php');
|
|
const source = shell + box + results + settings;
|
|
|
|
assert.match(shell, /add_action\('wp_footer', 'aksrt_footer_navbar_search'/);
|
|
assert.match(shell, /wp_ajax_menu_search/);
|
|
assert.match(shell, /wp_ajax_search_box/);
|
|
assert.match(shell, /wp_verify_nonce/);
|
|
assert.match(shell, /navbar-search/);
|
|
assert.match(source, /['"]trem['"]/);
|
|
assert.match(source, /['"]type['"]/);
|
|
assert.match(source, /['"]user['"]/);
|
|
assert.match(box, /history_search/);
|
|
assert.match(box, /array_slice\(\$history, 0, 30\)/);
|
|
assert.match(box, /search_keywords/);
|
|
assert.match(settings, /search_custom_key/);
|
|
assert.match(settings, /aksrt_search_terms\.name LIKE/);
|
|
assert.match(results, /search-tab-filter/);
|
|
assert.match(results, /aksrt_get_search_tab_nav_filter/);
|
|
assert.equal(exists('templates/parts/navbar-search.php'), false);
|
|
assert.equal(exists('templates/parts/search-panel.php'), false);
|
|
});
|
|
|
|
test('search settings preserve every original field ID and nested field type', () => {
|
|
const php = read('src/Admin/Schema/GlobalSchema.php');
|
|
const js = read('assets/admin/src/schema/sections/global/search.js');
|
|
const source = php + js;
|
|
for (const key of [
|
|
'search_placeholder', 'search_popular_key', 'search_popular_title',
|
|
'search_popular_sticky', 'search_popular_key_num', 'search_cat',
|
|
'search_cat_in', 'search_more_cat_obj', 'search_type', 'search_type_in',
|
|
'search_history', 'search_posts', '404_search_s', 'search_no_page',
|
|
'search_exclude_cats', 'search_custom_key_s', 'search_custom_key',
|
|
'search_facets', 'search_ms_s', 'search_ms_opt',
|
|
]) assert.ok(source.includes(key), `${key} missing`);
|
|
assert.match(js, /key: 'search_facets'[\s\S]*?type: 'fieldset'/);
|
|
assert.match(js, /key: 'search_ms_opt'[\s\S]*?type: 'fieldset'/);
|
|
assert.match(js, /key: 'synonyms'[\s\S]*?type: 'repeater'/);
|
|
});
|
|
|
|
test('header slider is the only top visual path and uses global plus page_config fields', () => {
|
|
const renderer = read('inc/helpers/homepage/header-components.php');
|
|
const globalSchema = read('src/Admin/Schema/SchemaPageDisplay.php');
|
|
const pageMeta = read('src/Admin/PageConfigMetaBox.php');
|
|
const defaults = read('src/Settings/DisplayPageGroups.php');
|
|
const source = renderer + globalSchema + pageMeta + defaults;
|
|
|
|
assert.match(renderer, /function aksrt_header_slide\(\): void/);
|
|
assert.match(renderer, /function aksrt_header_slide_is_show\(\): bool/);
|
|
assert.match(pageMeta, /page_config/);
|
|
for (const key of [
|
|
'header_slider_show', 'header_slider_show_type', 'header_slider_nav_color',
|
|
'header_slider', 'header_slider_option', 'header_slider_search_s',
|
|
'header_slider_search_option', 'header_slider_card_s',
|
|
'header_slider_card_option', 'header_slider_filter_blur',
|
|
]) assert.ok(source.includes(key), `${key} missing`);
|
|
assert.match(defaults, /slider-bg\.jpg/);
|
|
assert.match(defaults, /user_t\.jpg/);
|
|
assert.match(defaults, /\['pc_s', 'm_s'\]/);
|
|
assert.equal(exists('templates/parts/home-modules/module-hero.php'), false);
|
|
assert.equal(exists('assets/admin/src/pages/content/HeroManager.vue'), false);
|
|
assert.doesNotMatch(read('assets/admin/src/constants/sections/page-display.js'), /page-display-hero|HeroManager/);
|
|
assert.doesNotMatch(read('assets/admin/src/api/modules/page-display.js'), /getHeroes|createHero|updateHero|deleteHero/);
|
|
});
|
|
|
|
test('responsive contract pins the requested viewport matrix to reference breakpoints', () => {
|
|
const viewports = [375, 640, 768, 991, 1200, 1380, 1440];
|
|
const css = read('assets/css/main.min.css');
|
|
assert.deepEqual(viewports, [375, 640, 768, 991, 1200, 1380, 1440]);
|
|
for (const breakpoint of [375, 640, 768, 991, 1200, 1380]) {
|
|
assert.ok(css.includes(String(breakpoint)), `reference rule for ${breakpoint}px missing`);
|
|
}
|
|
assert.match(css, /@media\s*\(max-width:640px\)/);
|
|
assert.match(css, /@media\s*\(max-width:991px\)/);
|
|
assert.match(css, /@media\s*\(min-width:1200px\)/);
|
|
});
|
|
|
|
test('old navigation settings and runtime handles do not survive the hard switch', () => {
|
|
const source = join([
|
|
'src/Settings/Settings.php',
|
|
'src/Settings/FacadeBulk.php',
|
|
'src/Core/ScriptsPart1b.php',
|
|
'src/Core/ScriptsPart1c.php',
|
|
'assets/js/runtime/main.js',
|
|
]);
|
|
assert.doesNotMatch(source, /bootstrap5|aksrt-mini-touch|aksrt\.Drawer|aksrt\.minitouch|updateScrollBus/);
|
|
assert.doesNotMatch(source, /aksrt_nav_|legacy_nav|nav_compat/);
|
|
});
|