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>
166 lines
8.1 KiB
JavaScript
166 lines
8.1 KiB
JavaScript
const assert = require('node:assert/strict');
|
|
const fs = require('node:fs');
|
|
const path = require('node:path');
|
|
const { spawnSync } = require('node:child_process');
|
|
const test = require('node:test');
|
|
|
|
const root = path.resolve(__dirname, '..', '..');
|
|
const read = (file) => fs.readFileSync(path.join(root, file), 'utf8');
|
|
|
|
test('message center exposes only the four configured-alias parameter-free routes', () => {
|
|
const routing = read('inc/modules/user-parts/routing.php');
|
|
const urls = read('inc/modules/user-parts/urls.php');
|
|
const registry = read('inc/modules/user-parts/template-registry.php');
|
|
|
|
assert.match(urls, /function jio_get_messages_rewrite_slug[\s\S]*?Settings::notification_settings\(\)[\s\S]*?\['slug'\]/);
|
|
assert.match(routing, /\$message_slug = preg_quote\(jio_get_messages_rewrite_slug\(\), '#'\)/);
|
|
assert.match(routing, /add_rewrite_rule\('\^' \. \$message_slug \. '\/\?\$',[\s\S]*?jio_message_view=unread/);
|
|
assert.match(routing, /add_rewrite_rule\('\^' \. \$message_slug \. '\/\(posts\|like\|system\)\/\?\$'/);
|
|
assert.match(routing, /message-routing:' \. jio_get_messages_rewrite_slug\(\)/);
|
|
assert.doesNotMatch(routing, /add_rewrite_rule\('\^message/);
|
|
assert.doesNotMatch(routing, /message\/\(\[0-9]|jio_message_id/);
|
|
const messageUrlFunction = urls.slice(
|
|
urls.indexOf('function jio_get_messages_page_url'),
|
|
urls.indexOf('endif;', urls.indexOf('function jio_get_messages_page_url')),
|
|
);
|
|
assert.match(messageUrlFunction, /jio_get_messages_rewrite_slug\(\)/);
|
|
assert.doesNotMatch(messageUrlFunction, /add_query_arg|\/messages\/|\/message\//);
|
|
assert.doesNotMatch(registry, /'messages'\s*=>/);
|
|
assert.match(registry, /page-messages\.php'\)\s*\{[\s\S]*?return ''/);
|
|
assert.match(routing, /get_page_template_slug[\s\S]*?page-messages\.php[\s\S]*?set_404/);
|
|
});
|
|
|
|
test('message center URL helper builds every view from the configured alias', () => {
|
|
const result = spawnSync(process.env.PHP_BINARY || 'php', [path.join(__dirname, 'message-center-url-harness.php')], {
|
|
cwd: root,
|
|
encoding: 'utf8',
|
|
});
|
|
assert.equal(result.status, 0, result.stderr || result.stdout);
|
|
assert.deepEqual(JSON.parse(result.stdout), {
|
|
slug: 'inbox-center',
|
|
unread: 'https://example.test/inbox-center/',
|
|
posts: 'https://example.test/inbox-center/posts/',
|
|
like: 'https://example.test/inbox-center/like/',
|
|
system: 'https://example.test/inbox-center/system/',
|
|
});
|
|
});
|
|
|
|
test('message pagination setting switches between cumulative loading and numeric replacement', () => {
|
|
const result = spawnSync(process.env.PHP_BINARY || 'php', [path.join(__dirname, 'message-center-pagination-harness.php')], {
|
|
cwd: root,
|
|
encoding: 'utf8',
|
|
});
|
|
assert.equal(result.status, 0, result.stderr || result.stdout);
|
|
assert.deepEqual(JSON.parse(result.stdout), {
|
|
ajax_items: 40,
|
|
ajax_has_more: true,
|
|
ajax_has_numbers: false,
|
|
default_items: 20,
|
|
default_has_more: false,
|
|
default_numbers: true,
|
|
default_current_2: true,
|
|
});
|
|
|
|
const script = read('assets/js/messages.js');
|
|
const styles = read('assets/css/frontend/messages.css');
|
|
assert.match(script, /data-message-next-page|dataset\.messageNextPage/);
|
|
assert.match(script, /appendMessagePage\(result\.data\.content\)/);
|
|
assert.match(styles, /\.messages-pagination__more/);
|
|
assert.match(styles, /\.messages-pagination__button\.is-current/);
|
|
});
|
|
|
|
test('message centre shows a skeleton during the AJAX load-more cycle', () => {
|
|
const list = read('inc/modules/message-center.php');
|
|
const placeholder = read('inc/helpers/message-placeholder.php');
|
|
const script = read('assets/js/messages.js');
|
|
const styles = read('assets/css/frontend/messages.css');
|
|
|
|
// The skeleton ships inside .messages-list so the loader is anchored to the
|
|
// end of the list, mirroring the reference post_ajax beforeSend hook.
|
|
assert.match(list, /jio_get_message_placeholder\(4\)/);
|
|
assert.match(placeholder, /message-item--placeholder/);
|
|
assert.match(placeholder, /class="post_ajax_loader"/);
|
|
// The message skeleton reuses the shared .placeholder shimmer contract.
|
|
assert.match(placeholder, /placeholder t1/);
|
|
assert.match(placeholder, /placeholder k2/);
|
|
assert.match(placeholder, /placeholder s1/);
|
|
|
|
// Load cycle: show on start, hide on finish, and never remove the node.
|
|
assert.match(script, /content\.querySelector\('\.messages-list > \.post_ajax_loader'\)/);
|
|
assert.match(script, /skeleton\.classList\.add\('is-loading'\)/);
|
|
assert.match(script, /loader\.classList\.remove\('is-loading'\)/);
|
|
// Teardown must sweep every loader, not just `.messages-list >` children:
|
|
// a loader stranded outside a list (empty view / detail) would stay open.
|
|
assert.match(script, /content\.querySelectorAll\('\.post_ajax_loader\.is-loading'\)/);
|
|
// Full replacement must not carry the old (still is-loading) node across.
|
|
assert.doesNotMatch(script, /list\.appendChild\(keep\)/);
|
|
assert.doesNotMatch(script, /content\.appendChild\(keep\)/);
|
|
// Appended rows land before the skeleton so it stays flush under the list.
|
|
assert.match(script, /currentList\.insertBefore\(item, skeleton\)/);
|
|
|
|
// Visibility is class-driven; the old button spinner / opacity dim are gone.
|
|
assert.match(styles, /\.messages-list > \.post_ajax_loader \{/);
|
|
assert.match(styles, /\.messages-list > \.post_ajax_loader\.is-loading \{/);
|
|
assert.doesNotMatch(styles, /messages-pagination-spin/);
|
|
assert.doesNotMatch(styles, /opacity: 0\.55/);
|
|
});
|
|
|
|
test('tabs, pagination, actions, and detail all replace DOM fragments', () => {
|
|
const center = read('inc/modules/message-center.php');
|
|
const script = read('assets/js/messages.js');
|
|
const template = read('templates/pages/page-messages.php');
|
|
|
|
for (const label of ['未读消息', '文章评论', '点赞喜欢', '系统通知']) {
|
|
assert.ok(center.includes(label));
|
|
}
|
|
assert.match(center, /wp_ajax_jio_load_message_center/);
|
|
assert.match(center, /jio_render_message_center_detail/);
|
|
assert.match(template, /data-message-content/);
|
|
assert.match(script, /nav\.innerHTML = result\.data\.nav/);
|
|
assert.match(script, /content\.innerHTML = result\.data\.content/);
|
|
assert.match(script, /\.js-msg-detail/);
|
|
assert.match(script, /data-message-back/);
|
|
assert.doesNotMatch(script, /searchParams|msg_type|msg_page|location\.href\s*=/);
|
|
assert.doesNotMatch(script, /pushState\([^\n]+detail/);
|
|
});
|
|
|
|
test('message detail exposes neither internal type labels nor a related-content link', () => {
|
|
const center = read('inc/modules/message-center.php');
|
|
const detailStart = center.indexOf('function jio_render_message_center_detail');
|
|
const detailEnd = center.indexOf("add_action('wp_ajax_jio_load_message_center'", detailStart);
|
|
const detail = center.slice(detailStart, detailEnd);
|
|
|
|
assert.doesNotMatch(detail, /jio_notification_type_label/);
|
|
assert.doesNotMatch(detail, /查看相关内容|message-detail__primary|target_url|\['url'\]/);
|
|
assert.doesNotMatch(detail, /<a\s/i);
|
|
});
|
|
|
|
test('asset notifications are absent and interaction notification hooks are present', () => {
|
|
const notifications = read('inc/modules/user-notifications.php');
|
|
const settings = read('src/Settings/Integration.php');
|
|
const adminSettings = read('assets/admin/src/pages/content/NotificationCenterSettings.vue');
|
|
const combined = [notifications, settings, adminSettings].join('\n');
|
|
|
|
for (const retired of [
|
|
'asset_points_increase',
|
|
'asset_points_decrease',
|
|
'asset_balance_increase',
|
|
'asset_balance_decrease',
|
|
]) {
|
|
assert.equal(combined.includes(retired), false, `${retired} should be absent`);
|
|
}
|
|
assert.doesNotMatch(notifications, /add_action\('jio_asset_transaction_committed'/);
|
|
for (const hook of ['jio_post_favorited', 'jio_post_liked', 'jio_comment_liked', 'jio_user_followed']) {
|
|
assert.ok(notifications.includes(`add_action('${hook}'`));
|
|
}
|
|
});
|
|
|
|
test('notification storage has no message-center legacy metadata fallback', () => {
|
|
const notifications = read('inc/modules/user-notifications.php');
|
|
const service = read('src/Messages/Message.php');
|
|
const combined = `${notifications}\n${service}`;
|
|
|
|
assert.doesNotMatch(combined, /jio_notifications|jio_unread_message_count/);
|
|
assert.doesNotMatch(combined, /legacy|兼容|降级/i);
|
|
});
|