Files
kate522andClaude Opus 5 35bb96e82f refactor: rename the theme brand and every identifier from AKSRT to Jio
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>
2026-11-01 20:05:04 +08:00

90 lines
4.1 KiB
JavaScript

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('badges use server-rendered admin-ajax modal actions only', () => {
const badges = read('src/User/Badges.php');
const identity = read('inc/helpers/jio-identity.php');
const scripts = read('src/Core/ScriptsPart1b.php');
for (const action of [
'jio_user_medal_info_modal',
'jio_single_medal_info_modal',
'jio_user_medal_manually_add_modal',
'jio_user_medal_wear',
'jio_user_medal_manually_add',
'jio_user_medal_manually_remove',
]) {
assert.match(badges, new RegExp(`wp_ajax_${action}`));
}
assert.match(badges, /wp_ajax_nopriv_jio_user_medal_info_modal/);
assert.match(badges, /wp_ajax_nopriv_jio_single_medal_info_modal/);
assert.match(identity, /data-jio-modal-cache="false"/);
assert.match(identity, /data-jio-modal-loading="spinner"/);
assert.match(identity, /data-jio-modal-swipe-close="true"/);
assert.match(identity, /admin-ajax\.php/);
assert.match(identity, /jio-badge-modal--overview/);
assert.match(identity, /jio-badge-modal--grant/);
assert.match(badges, /jio-badge-modal--single/);
assert.match(badges, /data-jio-modal-loading="spinner"/);
assert.match(badges, /data-jio-modal-swipe-close="true"/);
assert.doesNotMatch(identity, /data-jio-modal-class="full-sm"/);
assert.doesNotMatch(badges, /data-jio-modal-class="modal-mini"/);
assert.match(scripts, /user-badge-actions\.js/);
assert.doesNotMatch(scripts, /user-badges\.js/);
assert.doesNotMatch(badges, /register_rest_route|rest_wear|rest_list|rest_grant|rest_revoke/);
assert.doesNotMatch(identity, /data-jio-badges-open|data-jio-badges-can-wear/);
});
test('badge mutations enforce the public nonce, login, ownership, and manual grant rules', () => {
const badges = read('src/User/Badges.php');
assert.match(badges, /ajax_nonce\(\): string \{ return 'jio_public_nonce'; \}/);
assert.match(badges, /wp_verify_nonce\(\$nonce, self::ajax_nonce\(\)\)/);
assert.match(badges, /if \(!is_user_logged_in\(\)\) self::ajax_error/);
assert.match(badges, /if \(\$operation !== 'wear' && !self::can_manually_set\(\)\)/);
assert.match(badges, /\$operation === 'grant' && \(\$item\['get_type'\] \?\? ''\) !== 'manually_add'/);
assert.match(badges, /\$operation === 'revoke' && empty\(\$item\['owned'\]\)/);
assert.match(badges, /if \(!in_array\(\$slug, \$owned, true\)\)/);
assert.match(badges, /'show_unearned'\s*=>\s*\$show_unearned/);
});
test('badge actions close their HTML dialog without reloading the page', () => {
const actions = read('assets/js/user-badge-actions.js');
assert.match(actions, /jio_user_medal_wear/);
assert.match(actions, /jio_user_medal_manually_add/);
assert.match(actions, /jio_user_medal_manually_remove/);
assert.match(actions, /JioModalRuntime\.close\('badge-action'\)/);
assert.match(actions, /getActive\(\) === modal/);
assert.doesNotMatch(actions, /window\.location\.reload|setTimeout/);
assert.doesNotMatch(actions, /JioRequest|fetchJson|restUrl/);
});
test('the retired badge rollout and JSON modal CSS are absent', () => {
const retired = [
'src/Settings/FrontendModalRuntime.php',
'src/Admin/Schema/SchemaToolsFrontendModalRollout.php',
'assets/admin/src/schema/sections/tools/frontend-modal-rollout.js',
];
for (const file of retired) {
assert.equal(fs.existsSync(path.join(root, file)), false, `${file} should be deleted`);
}
const sources = [
'src/Core/ScriptsPart1c.php',
'assets/css/frontend/medal.css',
].map(read).join('\n');
assert.doesNotMatch(sources, /frontend_modal_rollout_badge/);
assert.doesNotMatch(sources, /\.uc-badges-/);
assert.doesNotMatch(sources, /grid-template-columns|\.medal-card__|\.medal-modal__|\.medal-grant-item/);
const main = read('assets/css/main.css');
assert.match(main, /\.medal-list\s*\{\s*width:\s*calc\(20% - 14px\);\s*margin:\s*10px 7px/);
assert.match(main, /\.medal-list\s*\{\s*width:\s*calc\(25% - 14px\)/);
});