Full-project rename. `git grep -i aksrt` is now empty apart from the
DBMigrator 3.3.0 changelog note that documents the rename itself.
Code identifiers
- PHP namespace AKSRT\ -> Jio\ (composer PSR-4 + 378 declarations)
- global constants AKSRT_* -> JIO_* (VERSION/DIR/URI, PAY_TYPE_*, CAPTCHA_*)
- procedural functions, hooks, options, meta keys, table names,
cookies, query vars, ajax actions and nonces: aksrt_ -> jio_
- text domain aksrt -> jio; Theme Name -> Jio
- JS globals: aksrtData/aksrtAdminData/... -> jioData/jioAdminData/...,
window.AKSRTCaptcha & friends -> window.JioCaptcha, Aksrt* -> Jio*
- Vue components Aks*.vue -> Jio*.vue (15 files renamed + imports)
- CSS classes/data-attrs/custom properties: aksrt- -> jio-
- REST namespace aksrt/v1 -> jio/v1 (incl. payment gateway callbacks)
Storage layer
- DB tables {prefix}aksrt_* -> {prefix}jio_*; SCHEMA_VERSION 3.2.0 -> 3.3.0
so dbDelta creates the new names on install
- widget id_base aksrt_widget_* -> jio_widget_*
- uninstall.php drop list rebuilt from the actual migrator tables
(dropped 3 stale entries, added the 17 missing ones)
Removed
- hardcoded https://api.aksrt.com/version.json default update endpoint;
get_endpoint() now reads the 「更新端点」 setting and do_check() no-ops
when it is empty
Files renamed: inc/helpers/aksrt-*.php -> jio-*.php (54),
assets/admin/src/components/form/Aks*.vue -> Jio*.vue (15).
Build artifacts regenerated: assets/css/build, assets/js/runtime,
assets/admin/build.
Verified: audit-psr4-paths errors=0, audit-admin-contracts errors=0
(warnings=56, unchanged baseline), 813/813 widget-system tests,
44/44 phpunit, php -l clean across all PHP.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
101 lines
4.2 KiB
JavaScript
101 lines
4.2 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 vm = require('node:vm');
|
|
const root = path.resolve(__dirname, '../..');
|
|
const read = (file) => fs.readFileSync(path.join(root, file), 'utf8');
|
|
const runtime = read('assets/js/runtime/main.js');
|
|
|
|
function handlerBetween(start, end, context) {
|
|
let handler;
|
|
vm.runInNewContext(runtime.slice(runtime.indexOf(start), runtime.indexOf(end)), {
|
|
_win: { bd: { on(event, selector, callback) { handler = callback; } } },
|
|
...context,
|
|
});
|
|
assert.equal(typeof handler, 'function');
|
|
return handler;
|
|
}
|
|
|
|
test('search type changes reset only the active form placeholder', () => {
|
|
const field = { length: 1, attr: () => '开启精彩搜索', text(value) { this.value = value; } };
|
|
const control = {};
|
|
const handler = handlerBetween('//搜索功能-恢复默认占位符', '//搜索功能->删除多余的input', {
|
|
jQuery(target) {
|
|
assert.equal(target, control, 'must not select all search boxes');
|
|
return { closest(selector) {
|
|
assert.equal(selector, 'form');
|
|
return { find(selector) { assert.equal(selector, '.scale-placeholder'); return field; } };
|
|
} };
|
|
},
|
|
});
|
|
handler.call(control);
|
|
assert.equal(field.value, '开启精彩搜索');
|
|
});
|
|
|
|
test('clearing history expires the saved cookie at its original WordPress path and domain', () => {
|
|
const control = {};
|
|
const history = {};
|
|
const cookies = [];
|
|
let removed = false;
|
|
let confirmed = true;
|
|
const jQuery = (target) => {
|
|
if (target === control) return { attr(name) {
|
|
return { 'data-cookie-path': '/blog/', 'data-cookie-domain': '.example.test' }[name];
|
|
} };
|
|
if (target === '.history-search') return { slideUp(duration, complete) {
|
|
assert.equal(duration, 300);
|
|
complete.call(history);
|
|
} };
|
|
assert.equal(target, history);
|
|
return { remove() { removed = true; } };
|
|
};
|
|
jQuery.cookie = (name, value, options) => cookies.push({ name, value, ...options });
|
|
const handler = handlerBetween('//清空搜索关键词', '//用户签到', {
|
|
jQuery, confirm: () => confirmed, jio__: (key) => key,
|
|
});
|
|
handler.call(control);
|
|
assert.deepEqual(cookies, [{ name: 'history_search', value: null, path: '/blog/', domain: '.example.test' }]);
|
|
assert.equal(removed, true);
|
|
confirmed = false;
|
|
handler.call(control);
|
|
assert.equal(cookies.length, 1, 'cancelling must preserve history');
|
|
});
|
|
|
|
test('removed search markup has no orphaned JavaScript owner', () => {
|
|
assert.doesNotMatch(read('assets/js/core/article.js'), /initSearchClear|search-clear-btn|search-page-input|search-category-filter|jio_search_type|jio_category/);
|
|
assert.doesNotMatch(runtime, /eval\('\/' \+ val|search-tab \.item-heading/);
|
|
assert.doesNotMatch(runtime, /css\/dplayer\.min\.css/);
|
|
});
|
|
|
|
test('search submissions replace results with encoded filters and navigate normally when cleared', () => {
|
|
const handlers = {};
|
|
const form = {};
|
|
let data = { s: '主题 & "搜索"', type: 'post', trem: '7' };
|
|
let linkMarkup = '';
|
|
let clicks = 0;
|
|
const link = { click() { clicks++; return this; }, remove() {} };
|
|
const pager = { length: 1, append(node) { assert.equal(node, link); } };
|
|
const jQuery = (target) => {
|
|
if (target === '.search-page-ajaxpager') return pager;
|
|
if (target === form) return { serializeObject: () => data, attr: () => 'https://example.test/blog/' };
|
|
linkMarkup = target;
|
|
return link;
|
|
};
|
|
vm.runInNewContext(runtime.slice(runtime.indexOf('//搜索页面关键词ajax'), runtime.indexOf('function nav_folding()')), {
|
|
_win: { bd: { on(event, selector, handler) { handlers[event] = handler; } } },
|
|
jQuery, URL, URLSearchParams,
|
|
});
|
|
assert.equal(handlers.submit.call(form), false);
|
|
const url = new URL(linkMarkup.match(/href="([^"]+)"/)[1]);
|
|
assert.equal(url.searchParams.get('s'), data.s);
|
|
assert.equal(url.searchParams.get('type'), 'post');
|
|
assert.equal(url.searchParams.get('trem'), '7');
|
|
assert.equal(clicks, 1);
|
|
data = { s: ' ', type: 'post' };
|
|
assert.equal(handlers.submit.call(form), undefined);
|
|
assert.equal(clicks, 1, 'the empty page has no AJAX pager and must use normal form navigation');
|
|
});
|