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>
This commit is contained in:
1 parent
5b16bc6e15
commit
35bb96e82f
997 files changed
+28216
-28188
No files matched your search
@@ -21,7 +21,7 @@ const submitContext = read('templates/parts/submit/context.php');
|
||||
const submitPage = read('templates/pages/page-submit.php');
|
||||
|
||||
const removed = [
|
||||
'aksrt_ai_settings',
|
||||
'jio_ai_settings',
|
||||
'AI 连接配置',
|
||||
'AI连接配置',
|
||||
'ExtensionAI',
|
||||
|
||||
@@ -45,7 +45,7 @@ namespace {
|
||||
function wp_nonce_field($action, $name) { echo '<input type="hidden" name="' . $name . '" value="nonce" />'; }
|
||||
function wp_unslash($s) { return $s; }
|
||||
function sanitize_text_field($s) { return trim(strip_tags((string) $s)); }
|
||||
function wp_verify_nonce($nonce, $action) { return $nonce === 'valid-nonce' && $action === 'aksrt_push_meta_save'; }
|
||||
function wp_verify_nonce($nonce, $action) { return $nonce === 'valid-nonce' && $action === 'jio_push_meta_save'; }
|
||||
function is_wp_error($t) { return $t instanceof WP_Error; }
|
||||
function home_url($path = '/') { return 'https://example.test' . $path; }
|
||||
function current_time($type = 'mysql') { return '2026-10-13 12:00:00'; }
|
||||
@@ -56,7 +56,7 @@ namespace {
|
||||
}
|
||||
function wp_is_post_revision($id) { return false; }
|
||||
function wp_is_post_autosave($id) { return false; }
|
||||
function aksrt_searchable_post_types(): array { return ['post']; }
|
||||
function jio_searchable_post_types(): array { return ['post']; }
|
||||
function get_object_taxonomies($types, $output = 'names') { return ['post_tag', 'category', 'post_format']; }
|
||||
|
||||
// Outgoing HTTP: every call is captured so channel/URL/body can be asserted.
|
||||
@@ -79,7 +79,7 @@ namespace {
|
||||
function delete_term_meta($id, $key) { unset($GLOBALS['push_term_meta'][$id][$key]); return true; }
|
||||
}
|
||||
|
||||
namespace AKSRT\Settings {
|
||||
namespace Jio\Settings {
|
||||
class Settings {
|
||||
public static array $config = [];
|
||||
public static function get_search_push_settings(): array { return self::$config; }
|
||||
@@ -90,8 +90,8 @@ namespace {
|
||||
require_once dirname(__DIR__, 2) . '/src/Extensions/SearchPush.php';
|
||||
require_once dirname(__DIR__, 2) . '/src/Extensions/SearchPushMetaBox.php';
|
||||
|
||||
use AKSRT\Extensions\SearchPush;
|
||||
use AKSRT\Extensions\SearchPushMetaBox;
|
||||
use Jio\Extensions\SearchPush;
|
||||
use Jio\Extensions\SearchPushMetaBox;
|
||||
|
||||
$failures = [];
|
||||
$check = static function (string $label, bool $ok) use (&$failures): void {
|
||||
@@ -101,7 +101,7 @@ namespace {
|
||||
};
|
||||
|
||||
$reset = static function (array $config): void {
|
||||
\AKSRT\Settings\Settings::$config = $config;
|
||||
\Jio\Settings\Settings::$config = $config;
|
||||
$GLOBALS['push_requests'] = [];
|
||||
$GLOBALS['push_post_meta'] = [];
|
||||
$GLOBALS['push_term_meta'] = [];
|
||||
@@ -236,8 +236,8 @@ namespace {
|
||||
$check('面板含普通收录成功', str_contains($html, '普通收录:成功'));
|
||||
$check('面板含快速收录失败', str_contains($html, '快速收录:失败'));
|
||||
$check('面板含更新时间', str_contains($html, '2026-10-13 09:00:00'));
|
||||
$check('面板含重新提交勾选', str_contains($html, 'name="aksrt_push_resubmit"'));
|
||||
$check('面板含 nonce 字段', str_contains($html, 'name="aksrt_push_meta_nonce"'));
|
||||
$check('面板含重新提交勾选', str_contains($html, 'name="jio_push_resubmit"'));
|
||||
$check('面板含 nonce 字段', str_contains($html, 'name="jio_push_meta_nonce"'));
|
||||
$check('面板转义接口 JSON', str_contains($html, '{"success":1}'));
|
||||
|
||||
ob_start();
|
||||
@@ -251,7 +251,7 @@ namespace {
|
||||
$box->render_term_panel($term);
|
||||
$termHtml = (string) ob_get_clean();
|
||||
$check('术语编辑表单为表单行', str_contains($termHtml, '<tr class="form-field">'));
|
||||
$check('术语编辑表单含重新提交', str_contains($termHtml, 'name="aksrt_push_resubmit"'));
|
||||
$check('术语编辑表单含重新提交', str_contains($termHtml, 'name="jio_push_resubmit"'));
|
||||
|
||||
if ($failures) {
|
||||
echo "Baidu push harness FAILED\n";
|
||||
|
||||
@@ -27,7 +27,7 @@ const displayGroups = fs.readFileSync(path.join(root, 'src/Settings/DisplayPageG
|
||||
const metaBox = fs.readFileSync(path.join(root, 'src/Extensions/SearchPushMetaBox.php'), 'utf8');
|
||||
const functions = fs.readFileSync(path.join(root, 'functions.php'), 'utf8');
|
||||
|
||||
// 参考主题(zibll)百度推送字段全集,AKSRT 单一 canonical 配置面(扩展&增强 → 百度推送)。
|
||||
// 参考主题(zibll)百度推送字段全集,Jio 单一 canonical 配置面(扩展&增强 → 百度推送)。
|
||||
const REFERENCE_KEYS = [
|
||||
'baidu_push_enabled',
|
||||
'baidu_push_token',
|
||||
@@ -136,7 +136,7 @@ test('前台自动推送 JS 与参考主题一致', () => {
|
||||
|
||||
test('发布/更新触发沿用 transition_post_status 且仅限可检索内容类型', () => {
|
||||
assert.match(runtime, /transition_post_status/);
|
||||
assert.match(runtime, /aksrt_searchable_post_types/);
|
||||
assert.match(runtime, /jio_searchable_post_types/);
|
||||
assert.match(runtime, /wp_is_post_revision/);
|
||||
assert.match(runtime, /wp_is_post_autosave/);
|
||||
});
|
||||
@@ -156,12 +156,12 @@ test('分类法推送接入 saved_term 且排除文章形式', () => {
|
||||
assert.match(runtime, /add_action\('saved_term'/);
|
||||
assert.match(runtime, /public static function pushable_taxonomies/);
|
||||
assert.match(runtime, /array_diff\(\(array\) \$taxonomies, \['post_format', 'nav_menu'\]\)/);
|
||||
assert.match(runtime, /aksrt_baidu_push_taxonomies/);
|
||||
assert.match(runtime, /jio_baidu_push_taxonomies/);
|
||||
assert.match(runtime, /get_term_link\(\$term_id, \$taxonomy\)/);
|
||||
});
|
||||
|
||||
test('推送结果写入 meta 并按记录去重', () => {
|
||||
assert.match(runtime, /META_KEY\s*=\s*'_aksrt_baidu_push_back'/);
|
||||
assert.match(runtime, /META_KEY\s*=\s*'_jio_baidu_push_back'/);
|
||||
assert.match(runtime, /private function record_is_complete/);
|
||||
assert.match(runtime, /private function build_record/);
|
||||
assert.match(runtime, /'normal_push'/);
|
||||
@@ -172,14 +172,14 @@ test('推送结果写入 meta 并按记录去重', () => {
|
||||
});
|
||||
|
||||
test('「重新提交」勾选需通过 metabox nonce 校验', () => {
|
||||
assert.match(runtime, /NONCE_ACTION\s*=\s*'aksrt_push_meta_save'/);
|
||||
assert.match(runtime, /NONCE_FIELD\s*=\s*'aksrt_push_meta_nonce'/);
|
||||
assert.match(runtime, /RESUBMIT_FIELD\s*=\s*'aksrt_push_resubmit'/);
|
||||
assert.match(runtime, /NONCE_ACTION\s*=\s*'jio_push_meta_save'/);
|
||||
assert.match(runtime, /NONCE_FIELD\s*=\s*'jio_push_meta_nonce'/);
|
||||
assert.match(runtime, /RESUBMIT_FIELD\s*=\s*'jio_push_resubmit'/);
|
||||
assert.match(runtime, /wp_verify_nonce\(\$nonce, self::NONCE_ACTION\)/);
|
||||
});
|
||||
|
||||
test('编辑页面板与参考主题「百度资源提交」Metabox 对齐', () => {
|
||||
assert.match(metaBox, /add_meta_box\(\s*'aksrt_baidu_push',\s*__\('百度资源提交', 'aksrt'\)/);
|
||||
assert.match(metaBox, /add_meta_box\(\s*'jio_baidu_push',\s*__\('百度资源提交', 'jio'\)/);
|
||||
assert.match(metaBox, /'side',\s*'high'/);
|
||||
assert.match(metaBox, /\{\$taxonomy\}_edit_form_fields/);
|
||||
assert.match(metaBox, /\{\$taxonomy\}_add_form_fields/);
|
||||
|
||||
@@ -84,10 +84,10 @@ function extractCalls(source, marker) {
|
||||
/** 收集一行渲染调用携带的依赖规则与显示标签。 */
|
||||
function rowsWithDeps(source) {
|
||||
const markers = [
|
||||
{ marker: '->field_row(', label: (t) => (t.match(/__\(\s*'([^']*)'\s*,\s*'aksrt'\s*\)/) || [])[1] },
|
||||
{ marker: '->field_row(', label: (t) => (t.match(/__\(\s*'([^']*)'\s*,\s*'jio'\s*\)/) || [])[1] },
|
||||
{
|
||||
marker: '->submessage_row(',
|
||||
label: (t) => (t.match(/<b>'\s*\.\s*esc_html__\(\s*'([^']*)'\s*,\s*'aksrt'\s*\)/) || [])[1],
|
||||
label: (t) => (t.match(/<b>'\s*\.\s*esc_html__\(\s*'([^']*)'\s*,\s*'jio'\s*\)/) || [])[1],
|
||||
},
|
||||
];
|
||||
const calls = [];
|
||||
@@ -147,7 +147,7 @@ function createForm() {
|
||||
const document = {
|
||||
readyState: 'loading',
|
||||
querySelectorAll(sel) {
|
||||
if (sel === '.aksrt-cardpass-form [name]') return inputs;
|
||||
if (sel === '.jio-cardpass-form [name]') return inputs;
|
||||
if (sel === '[data-dep]') return rows.map((row) => row.el);
|
||||
return [];
|
||||
},
|
||||
@@ -220,10 +220,10 @@ test('两种行渲染都接入服务端预隐藏,避免首帧铺开', () => {
|
||||
// wp-admin/js/common.js 会把页面上的 notice 搬到页头,见下一条用例),
|
||||
// 它仍能被求值并保持隐藏。
|
||||
assert.match(page, /<td colspan="2"><div'\s*\.\s*\$dep_attr/, '提示块必须自带 data-dep');
|
||||
assert.match(page, /class="aksrt-submsg"'\s*\.\s*\$hidden/, '提示块必须自带初始隐藏状态');
|
||||
assert.match(page, /class="jio-submsg"'\s*\.\s*\$hidden/, '提示块必须自带初始隐藏状态');
|
||||
// 求值范围不限域:提示块被移出表格/表单子树后仍必须被求值。
|
||||
assert.match(script, /querySelectorAll\('\[data-dep\]'\)/, '求值必须全文档查找 data-dep');
|
||||
assert.doesNotMatch(script, /querySelectorAll\('\.aksrt-cardpass-form \[data-dep\]'\)/, '求值不得限域在表单内');
|
||||
assert.doesNotMatch(script, /querySelectorAll\('\.jio-cardpass-form \[data-dep\]'\)/, '求值不得限域在表单内');
|
||||
});
|
||||
|
||||
test('导入提示不得使用 WP 的 .notice 类(否则被 common.js 搬到页面顶部)', () => {
|
||||
@@ -234,19 +234,19 @@ test('导入提示不得使用 WP 的 .notice 类(否则被 common.js 搬到
|
||||
// 且搬迁发生在 evalDeps 之后,行内显隐逻辑无法纠正(历史故障:提示一直显示在页面最上方)。
|
||||
assert.match(
|
||||
page,
|
||||
/private function submessage_row\([\s\S]*?class="aksrt-submsg"/,
|
||||
'提示块只应带自有类名 aksrt-submsg'
|
||||
/private function submessage_row\([\s\S]*?class="jio-submsg"/,
|
||||
'提示块只应带自有类名 jio-submsg'
|
||||
);
|
||||
assert.doesNotMatch(
|
||||
page,
|
||||
/class="aksrt-submsg[^"]*\bnotice\b/,
|
||||
/class="jio-submsg[^"]*\bnotice\b/,
|
||||
'提示块不得带 notice 类:会被 common.js 搬到页面顶部'
|
||||
);
|
||||
// 外观改由自有类名承担,删掉样式规则会让提示失去底色与左侧色条。
|
||||
assert.match(
|
||||
page,
|
||||
/\.aksrt-submsg \{[^}]*background:[^}]*border-left:/,
|
||||
'.aksrt-submsg 必须自带 background 与 border-left 外观'
|
||||
/\.jio-submsg \{[^}]*background:[^}]*border-left:/,
|
||||
'.jio-submsg 必须自带 background 与 border-left 外观'
|
||||
);
|
||||
// 允许(且要求)真正需要置顶的提示保留 notice:确认本用例没有误伤其它通知输出。
|
||||
assert.match(page, /class="notice notice-error"/, '页面级错误通知仍应使用 notice');
|
||||
@@ -266,17 +266,17 @@ test('导入提示的条目列表由 <ul> 承载,圆点不越出文字边界',
|
||||
checked++;
|
||||
assert.match(
|
||||
call.text,
|
||||
/<ul class="aksrt-submsg-list">/,
|
||||
'提示内的 <li> 必须包在 <ul class="aksrt-submsg-list"> 中'
|
||||
/<ul class="jio-submsg-list">/,
|
||||
'提示内的 <li> 必须包在 <ul class="jio-submsg-list"> 中'
|
||||
);
|
||||
assert.equal([...call.text.matchAll(/<ul class="aksrt-submsg-list">/g)].length, 1, '每条提示只应有一个条目列表');
|
||||
assert.equal([...call.text.matchAll(/<ul class="jio-submsg-list">/g)].length, 1, '每条提示只应有一个条目列表');
|
||||
assert.equal(opens, [...call.text.matchAll(/<\/li>/g)].length, '<li> 标签必须成对');
|
||||
assert.equal([...call.text.matchAll(/<\/ul>/g)].length, 1, '</ul> 必须成对');
|
||||
}
|
||||
assert.equal(checked, 4, '四条导入提示都应带条目列表');
|
||||
|
||||
assert.match(page, /\.aksrt-submsg-list \{[^}]*padding-left:/, '.aksrt-submsg-list 必须给出 padding-left,圆点才有落点');
|
||||
assert.match(page, /\.aksrt-submsg-list \{[^}]*list-style:\s*disc/, '.aksrt-submsg-list 应显式声明圆点样式,不依赖 UA 默认值');
|
||||
assert.match(page, /\.jio-submsg-list \{[^}]*padding-left:/, '.jio-submsg-list 必须给出 padding-left,圆点才有落点');
|
||||
assert.match(page, /\.jio-submsg-list \{[^}]*list-style:\s*disc/, '.jio-submsg-list 应显式声明圆点样式,不依赖 UA 默认值');
|
||||
});
|
||||
|
||||
test('行内脚本不再保留解析期的空操作求值(死代码)', () => {
|
||||
|
||||
@@ -156,7 +156,7 @@ test('整个后台页源码内没有任何输入携带原生约束属性', () =>
|
||||
|
||||
test('表单不用 novalidate 掩盖问题,且提交按钮仍是原生 submit', () => {
|
||||
assert.doesNotMatch(addForm, /novalidate/i, '不得通过关闭校验来绕过,应去掉约束本身');
|
||||
assert.match(addForm, /submit_button\(\s*__\('确认提交',\s*'aksrt'\)/);
|
||||
assert.match(addForm, /submit_button\(\s*__\('确认提交',\s*'jio'\)/);
|
||||
assert.match(addForm, /wp_nonce_field\(self::NONCE\)/);
|
||||
});
|
||||
|
||||
|
||||
@@ -48,8 +48,8 @@ test('标题右侧按钮只在页面头部输出一次', () => {
|
||||
// 列表页的两个入口按钮各自只有一处定义。
|
||||
assert.equal(count(page, /add_query_arg\('tab', 'add'/g), 1);
|
||||
assert.equal(count(page, /add_query_arg\('tab', 'export'/g), 1);
|
||||
assert.match(header, /esc_html__\('添加卡密', 'aksrt'\)/);
|
||||
assert.match(header, /esc_html__\('导出卡密', 'aksrt'\)/);
|
||||
assert.match(header, /esc_html__\('添加卡密', 'jio'\)/);
|
||||
assert.match(header, /esc_html__\('导出卡密', 'jio'\)/);
|
||||
});
|
||||
|
||||
test('搜索提示仍由页面头部输出且列表不再自建头部', () => {
|
||||
|
||||
@@ -77,7 +77,7 @@ test('ice_perpage 仍作为 URL 参数被尊重,默认每页 20', () => {
|
||||
// 明确约定:不在列表工具栏增加「每页显示」下拉/按钮。
|
||||
assert.doesNotMatch(page, /per_page_selector/);
|
||||
assert.doesNotMatch(page, /PER_PAGE_CHOICES/);
|
||||
assert.doesNotMatch(page, /aksrt-perpage-form/);
|
||||
assert.doesNotMatch(page, /jio-perpage-form/);
|
||||
assert.doesNotMatch(page, /name="ice_perpage"/);
|
||||
assert.doesNotMatch(page, /order-header-right/);
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
* 3) 插入表情(comment_smilie)、评论地理位置(comment_city_s/comment_city_type,
|
||||
* 由扩展&增强/IP归属地实现)不在本页;
|
||||
* 4) 快捷回复按评论区硬切换契约保持移除(comment_quick_* 不存在);
|
||||
* 5) 旧 AKSRT 私有字段(comment_order / comment_per_page / comment_pagination_type /
|
||||
* 5) 旧 Jio 私有字段(comment_order / comment_per_page / comment_pagination_type /
|
||||
* comment_nested_depth / comment_avatar_size / comment_close_comments /
|
||||
* comment_edit_window / comment_hot_threshold / comment_empty_text /
|
||||
* post_close_comments)已彻底移除,无双路兼容;
|
||||
@@ -29,7 +29,7 @@ const root = path.resolve(__dirname, '..', '..');
|
||||
const php = fs.readFileSync(path.join(root, 'src/Admin/Schema/SchemaPostList.php'), 'utf8');
|
||||
const js = fs.readFileSync(path.join(root, 'assets/admin/src/schema/sections/post-list/comment.js'), 'utf8');
|
||||
const runtime = fs.readFileSync(path.join(root, 'src/Settings/PostDisplay.php'), 'utf8');
|
||||
const commentsHelper = fs.readFileSync(path.join(root, 'inc/helpers/aksrt-comments.php'), 'utf8');
|
||||
const commentsHelper = fs.readFileSync(path.join(root, 'inc/helpers/jio-comments.php'), 'utf8');
|
||||
const geoHelper = fs.readFileSync(path.join(root, 'inc/helpers/comments/geo.php'), 'utf8');
|
||||
const actionsHelper = fs.readFileSync(path.join(root, 'inc/helpers/comments/actions.php'), 'utf8');
|
||||
|
||||
@@ -62,7 +62,7 @@ const EXCLUDED_KEYS = [
|
||||
'comment_quick_often',
|
||||
];
|
||||
|
||||
// 旧 AKSRT 私有字段(含已并入 WP 讨论设置与死字段 post_close_comments)。
|
||||
// 旧 Jio 私有字段(含已并入 WP 讨论设置与死字段 post_close_comments)。
|
||||
const LEGACY_KEYS = [
|
||||
'comment_order',
|
||||
'comment_per_page',
|
||||
@@ -204,7 +204,7 @@ test('旧字段在 schema 与运行时中均已移除(无双路)', () => {
|
||||
assert.ok(!php.includes(legacy), `PHP schema 残留旧字段: ${legacy}`);
|
||||
// 运行时按主题设置读取的形态 $settings['<legacy>'] 必须消失
|
||||
// (comment_order 允许以 WP 讨论选项 get_option('comment_order') 形态存在)。
|
||||
for (const source of [['PostDisplay', runtime], ['aksrt-comments.php', commentsHelper], ['comments/geo.php', geoHelper], ['comments/actions.php', actionsHelper]]) {
|
||||
for (const source of [['PostDisplay', runtime], ['jio-comments.php', commentsHelper], ['comments/geo.php', geoHelper], ['comments/actions.php', actionsHelper]]) {
|
||||
assert.ok(!source[1].includes(`$settings['${legacy}']`), `${source[0]} 残留旧字段读取: ${legacy}`);
|
||||
}
|
||||
}
|
||||
@@ -217,8 +217,8 @@ test('旧字段在 schema 与运行时中均已移除(无双路)', () => {
|
||||
// 排序回退到 WP 讨论设置(参考主题行为)。
|
||||
assert.match(runtime, /get_option\('comment_order', 'desc'\)/);
|
||||
// 评论区位置显示交由扩展 IP 归属地控制。
|
||||
assert.match(geoHelper, /aksrt_ip_geo_display_enabled\('comment'\)/);
|
||||
assert.match(geoHelper, /aksrt_ip_geo_format_key/);
|
||||
assert.match(geoHelper, /jio_ip_geo_display_enabled\('comment'\)/);
|
||||
assert.match(geoHelper, /jio_ip_geo_format_key/);
|
||||
// 编辑权限使用 user_edit 总开关。
|
||||
assert.match(actionsHelper, /\$display\['user_edit'\]/);
|
||||
});
|
||||
@@ -8,7 +8,7 @@
|
||||
* imagelightbox / imagelightbox_type / imagelightbox_thumbs_s /
|
||||
* imagelightbox_play_s / imagelightbox_zoom_s / imagelightbox_full_s /
|
||||
* imagelightbox_down_s / post_like_s / post_default_mate(views/like);
|
||||
* 3) 旧 AKSRT 私有/异名字段(feature_print / feature_pdf_export /
|
||||
* 3) 旧 Jio 私有/异名字段(feature_print / feature_pdf_export /
|
||||
* post_lightbox* / post_like_enabled / post_default_*_min/max)已彻底移除,
|
||||
* 文章页面(page)不再承载这些字段,无双路兼容;
|
||||
* 4) 运行时(PostDisplay::get_post_page_settings)只读取新键,灯箱复选框
|
||||
@@ -27,10 +27,10 @@ const pageJs = fs.readFileSync(path.join(root, 'assets/admin/src/schema/sections
|
||||
const runtime = fs.readFileSync(path.join(root, 'src/Settings/PostDisplay.php'), 'utf8');
|
||||
const scripts1c = fs.readFileSync(path.join(root, 'src/Core/ScriptsPart1c.php'), 'utf8');
|
||||
const scripts1b = fs.readFileSync(path.join(root, 'src/Core/ScriptsPart1b.php'), 'utf8');
|
||||
const frontendTags = fs.readFileSync(path.join(root, 'inc/helpers/aksrt-frontend-tags.php'), 'utf8');
|
||||
const frontendTags = fs.readFileSync(path.join(root, 'inc/helpers/jio-frontend-tags.php'), 'utf8');
|
||||
const coreHooks = fs.readFileSync(path.join(root, 'inc/core-hooks.php'), 'utf8');
|
||||
const singleRender = fs.readFileSync(path.join(root, 'inc/helpers/aksrt-single-render.php'), 'utf8');
|
||||
const mobileHeader = fs.readFileSync(path.join(root, 'inc/helpers/header/aksrt-header-mobile.php'), 'utf8');
|
||||
const singleRender = fs.readFileSync(path.join(root, 'inc/helpers/jio-single-render.php'), 'utf8');
|
||||
const mobileHeader = fs.readFileSync(path.join(root, 'inc/helpers/header/jio-header-mobile.php'), 'utf8');
|
||||
|
||||
const REFERENCE_KEYS = [
|
||||
'article_nav',
|
||||
@@ -46,7 +46,7 @@ const REFERENCE_KEYS = [
|
||||
'post_default_mate',
|
||||
];
|
||||
|
||||
// 旧 AKSRT 私有 / 异名字段(打印与 PDF 导出、旧灯箱六开关、旧点赞与默认数值四键)。
|
||||
// 旧 Jio 私有 / 异名字段(打印与 PDF 导出、旧灯箱六开关、旧点赞与默认数值四键)。
|
||||
const LEGACY_KEYS = [
|
||||
'feature_print',
|
||||
'feature_pdf_export',
|
||||
@@ -194,7 +194,7 @@ test('旧字段在 schema 与运行时中均已移除(无双路)', () => {
|
||||
assert.ok(!runtime.includes(legacy), `PostDisplay 残留旧字段: ${legacy}`);
|
||||
assert.ok(!js.includes(legacy), `feature.js 残留旧字段: ${legacy}`);
|
||||
assert.ok(!pageJs.includes(legacy), `page.js 残留旧字段: ${legacy}`);
|
||||
assert.ok(!frontendTags.includes(legacy), `aksrt-frontend-tags 残留旧字段: ${legacy}`);
|
||||
assert.ok(!frontendTags.includes(legacy), `jio-frontend-tags 残留旧字段: ${legacy}`);
|
||||
}
|
||||
assert.ok(!scripts1b.includes('needs_print'), 'ScriptsPart1b 残留 needs_print 分支');
|
||||
assert.ok(!scripts1c.includes('needs_print'), 'ScriptsPart1c 残留 needs_print 需求');
|
||||
@@ -228,5 +228,5 @@ test('运行时只读取新键并接入灯箱/目录树/预置参数', () => {
|
||||
// 预置参数:新建文章随机填入。
|
||||
assert.match(coreHooks, /save_post/);
|
||||
assert.match(coreHooks, /POST_VIEW_COUNT_KEY/);
|
||||
assert.match(coreHooks, /_aksrt_like_count/);
|
||||
assert.match(coreHooks, /_jio_like_count/);
|
||||
});
|
||||
@@ -18,7 +18,7 @@ const php = read('src/Admin/Schema/SchemaPostList.php');
|
||||
const postDisplay = read('src/Settings/PostDisplay.php');
|
||||
const settings = read('src/Settings/Settings.php');
|
||||
const termMeta = read('src/Core/TermMeta.php');
|
||||
const filtersHelper = read('inc/helpers/aksrt-archive-filters.php');
|
||||
const filtersHelper = read('inc/helpers/jio-archive-filters.php');
|
||||
const categoryTpl = read('category.php');
|
||||
const tagTpl = read('tag.php');
|
||||
const listJs = read('assets/js/runtime/main.js');
|
||||
@@ -26,7 +26,7 @@ const globalController = read('src/Admin/GlobalController.php');
|
||||
|
||||
// 参考主题字段键(顺序即参考主题定义顺序)。
|
||||
const REFERENCE_KEYS = ['custom_filter_show', 'custom_filter', 'cat_custom_filter'];
|
||||
// AKSRT 私有旧字段(参考主题无此配置,须移除避免双路)。
|
||||
// Jio 私有旧字段(参考主题无此配置,须移除避免双路)。
|
||||
const LEGACY_KEYS = [
|
||||
'filter_enabled',
|
||||
'filter_categories',
|
||||
@@ -149,17 +149,17 @@ test('前台链路:覆盖与门禁(参考主题 zib-category.php 语义)',
|
||||
|
||||
test('前台链路:维度筛选渲染与查询过滤', () => {
|
||||
// 渲染:维度 chip 组(全部 chip 参考主题 focus 语义)。
|
||||
assert.match(filtersHelper, /function aksrt_archive_build_custom_filter_groups\(/);
|
||||
assert.match(filtersHelper, /function jio_archive_build_custom_filter_groups\(/);
|
||||
assert.match(filtersHelper, /ajax-replace="true" class="ajax-next/);
|
||||
assert.match(filtersHelper, /\$keys !== 'all' && !in_array\(\$dim_key, \(array\) \$keys, true\)/);
|
||||
assert.match(categoryTpl, /aksrt_archive_build_custom_filter_groups\(/);
|
||||
assert.match(tagTpl, /aksrt_archive_build_custom_filter_groups\(/);
|
||||
// 查询:_aksrt_cf_{key} meta_query LIKE(主查询 + AJAX 端点)。
|
||||
assert.match(termMeta, /'_aksrt_cf_' \. \$dim_key/);
|
||||
assert.match(categoryTpl, /jio_archive_build_custom_filter_groups\(/);
|
||||
assert.match(tagTpl, /jio_archive_build_custom_filter_groups\(/);
|
||||
// 查询:_jio_cf_{key} meta_query LIKE(主查询 + AJAX 端点)。
|
||||
assert.match(termMeta, /'_jio_cf_' \. \$dim_key/);
|
||||
assert.match(termMeta, /'compare'\s*=>\s*'LIKE'/);
|
||||
// Category filtering uses the same HTML AJAX pipeline as the homepage.
|
||||
assert.doesNotMatch(globalController, /rest_archive_posts|\/archive\/posts/);
|
||||
assert.match(listJs, /win-ajax-replace/);
|
||||
assert.match(listJs, /post_ajax/);
|
||||
assert.match(filtersHelper, /'key'\s*=>\s*'_aksrt_cf_|\$dim_key/);
|
||||
assert.match(filtersHelper, /'key'\s*=>\s*'_jio_cf_|\$dim_key/);
|
||||
});
|
||||
@@ -110,7 +110,7 @@ test('每页条数默认 20 来自共享常量,且无「每页显示」控件'
|
||||
for (const [key, src] of Object.entries(pages)) {
|
||||
assert.doesNotMatch(src, /per_page_selector/, `${labels[key]} 出现 per_page 选择器`);
|
||||
assert.doesNotMatch(src, /PER_PAGE_CHOICES/, `${labels[key]} 出现 PER_PAGE_CHOICES`);
|
||||
assert.doesNotMatch(src, /aksrt-perpage-form/, `${labels[key]} 出现每页条数表单`);
|
||||
assert.doesNotMatch(src, /jio-perpage-form/, `${labels[key]} 出现每页条数表单`);
|
||||
assert.doesNotMatch(src, /name="ice_perpage"/, `${labels[key]} 出现 ice_perpage 输入框`);
|
||||
assert.doesNotMatch(src, /order-header-right/, `${labels[key]} 出现工具栏右侧每页控件`);
|
||||
}
|
||||
@@ -191,7 +191,7 @@ test('提现审核不把一次性动作参数带进翻页链接', () => {
|
||||
});
|
||||
|
||||
test('共享助手自身:页码夹取、四按钮标记与显式基准 URL', () => {
|
||||
assert.match(helper, /namespace AKSRT\\Admin\\Native;/);
|
||||
assert.match(helper, /namespace Jio\\Admin\\Native;/);
|
||||
assert.match(helper, /defined\('ABSPATH'\) \|\| exit;/);
|
||||
|
||||
// 总数为 0 或每页条数非法时不渲染;单页照样渲染(与原版 render_pagenavi 一致)。
|
||||
|
||||
@@ -12,10 +12,10 @@
|
||||
* post_front_content/after_content、post_related_*;
|
||||
* 3) 幻灯片 fieldset 全字段及嵌套依赖(direction/scale_height/auto_height 组合)
|
||||
* 对齐参考主题 CFS_Module::slide;
|
||||
* 4) 旧 AKSRT 私有/异名字段(阅读进度条、面包屑末项文本、作者卡片配置、收藏开关、
|
||||
* 4) 旧 Jio 私有/异名字段(阅读进度条、面包屑末项文本、作者卡片配置、收藏开关、
|
||||
* share_s 与 post_rewards_*、旧封面键)已彻底移除,无双路兼容;
|
||||
* 5) 运行时(PostDisplay::get_post_page_settings)只读取新键:幻灯片配置归一化并
|
||||
* 接线 aksrt_render_slider,p_indent 接线容器类,breadcrumbs_home_text 为
|
||||
* 接线 jio_render_slider,p_indent 接线容器类,breadcrumbs_home_text 为
|
||||
* switcher 布尔语义(true = 用「首页」替代网站名称)。
|
||||
*/
|
||||
|
||||
@@ -30,8 +30,8 @@ const js = fs.readFileSync(path.join(root, 'assets/admin/src/schema/sections/pos
|
||||
const runtime = fs.readFileSync(path.join(root, 'src/Settings/PostDisplay.php'), 'utf8');
|
||||
const facadeBulk = fs.readFileSync(path.join(root, 'src/Settings/FacadeBulk.php'), 'utf8');
|
||||
const metaBox = fs.readFileSync(path.join(root, 'src/Core/PostMetaBox.php'), 'utf8');
|
||||
const frontendTags = fs.readFileSync(path.join(root, 'inc/helpers/aksrt-frontend-tags.php'), 'utf8');
|
||||
const singleRender = fs.readFileSync(path.join(root, 'inc/helpers/aksrt-single-render.php'), 'utf8');
|
||||
const frontendTags = fs.readFileSync(path.join(root, 'inc/helpers/jio-frontend-tags.php'), 'utf8');
|
||||
const singleRender = fs.readFileSync(path.join(root, 'inc/helpers/jio-single-render.php'), 'utf8');
|
||||
const contentCss = fs.readFileSync(path.join(root, 'assets/css/frontend/single-post/content.css'), 'utf8');
|
||||
const shareJs = fs.readFileSync(path.join(root, 'assets/admin/src/schema/sections/global/share.js'), 'utf8');
|
||||
const sharePhp = fs.readFileSync(path.join(root, 'src/Admin/Schema/GlobalSchema.php'), 'utf8');
|
||||
@@ -104,7 +104,7 @@ const PAGE_FIELD_SEQUENCE = [
|
||||
'post_related_orderby',
|
||||
];
|
||||
|
||||
// 旧 AKSRT 私有/异名字段:已迁移(share_s / post_rewards_*)或无参考对应项被移除。
|
||||
// 旧 Jio 私有/异名字段:已迁移(share_s / post_rewards_*)或无参考对应项被移除。
|
||||
const LEGACY_KEYS = [
|
||||
'post_reading_progress',
|
||||
'post_author_card_limit',
|
||||
@@ -271,7 +271,7 @@ test('旧字段在 schema 与运行时中均已移除(无双路)', () => {
|
||||
assert.ok(!pagePhp.includes(`'breadcrumbs_single_text'`), 'page section 残留 breadcrumbs_single_text');
|
||||
assert.ok(!js.includes(`key: 'breadcrumbs_single_text'`), 'page.js 残留 breadcrumbs_single_text');
|
||||
assert.match(runtime, /'breadcrumbs_single_text'\s*=>\s*true/);
|
||||
// aksrt-frontend-tags 不再有 breadcrumbs_home_text 文本兼容(switcher 布尔语义)。
|
||||
// jio-frontend-tags 不再有 breadcrumbs_home_text 文本兼容(switcher 布尔语义)。
|
||||
assert.ok(!frontendTags.includes("breadcrumbs_home'] = (string) $settings['breadcrumbs_home_text'"), 'frontend-tags 残留 breadcrumbs_home_text 文本兼容');
|
||||
});
|
||||
|
||||
@@ -318,7 +318,7 @@ test('运行时只读取新键并接线封面/缩进/版权/一言', () => {
|
||||
});
|
||||
|
||||
test('前台链路:幻灯片配置接线渲染器,p_indent 接线容器与 CSS', () => {
|
||||
// 幻灯片配置接入 aksrt_render_slider(effect/direction/spaceBetween/speed/interval)。
|
||||
// 幻灯片配置接入 jio_render_slider(effect/direction/spaceBetween/speed/interval)。
|
||||
assert.match(singleRender, /article_slide_cover_option/);
|
||||
assert.match(singleRender, /'effect'\s*=>\s*\(string\) \(\$slide_option\['effect'\] \?\? 'slide'\)/);
|
||||
assert.match(singleRender, /'direction'\s*=>\s*\(string\) \(\$slide_option\['direction'\] \?\? 'horizontal'\)/);
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
* post_article_pay_vip_1_discount / post_article_pay_vip_2_discount /
|
||||
* post_t_placeholder / post_c_placeholder;
|
||||
* 3) 专题(topics)相关字段不存在;
|
||||
* 4) 旧 AKSRT 私有字段(front_submit_*、post_article_title_strlen_limit_min/max、
|
||||
* 4) 旧 Jio 私有字段(front_submit_*、post_article_title_strlen_limit_min/max、
|
||||
* post_article_pay_price_min/max)已彻底移除,无双路兼容;
|
||||
* 5) 运行时(PostDisplay::get_submit_settings)只读取新键。
|
||||
*/
|
||||
|
||||
@@ -42,7 +42,7 @@ namespace {
|
||||
}
|
||||
}
|
||||
|
||||
namespace AKSRT\Ticket {
|
||||
namespace Jio\Ticket {
|
||||
final class TicketSettings {
|
||||
public static bool $order_link_enabled = false;
|
||||
public static function order_link_enabled(): bool { return self::$order_link_enabled; }
|
||||
@@ -131,7 +131,7 @@ namespace AKSRT\Ticket {
|
||||
}
|
||||
}
|
||||
|
||||
namespace AKSRT\Attachment {
|
||||
namespace Jio\Attachment {
|
||||
final class PendingUploads {
|
||||
public static function claim_urls(array $attachment, int $user_id): void {}
|
||||
}
|
||||
@@ -148,45 +148,45 @@ namespace {
|
||||
}
|
||||
};
|
||||
$reset = static function (): void {
|
||||
\AKSRT\Ticket\TicketRepository::$tickets = [
|
||||
\Jio\Ticket\TicketRepository::$tickets = [
|
||||
1 => ['id' => 1, 'status' => 'handling', 'ticket_type_id' => 3, 'admin_id' => 11],
|
||||
2 => ['id' => 2, 'status' => 'closed', 'ticket_type_id' => 3, 'admin_id' => 11],
|
||||
3 => ['id' => 3, 'status' => 'handling', 'ticket_type_id' => 3, 'admin_id' => 11],
|
||||
];
|
||||
\AKSRT\Ticket\TicketRepository::$creates = [];
|
||||
\AKSRT\Ticket\TicketRepository::$updates = [];
|
||||
\AKSRT\Ticket\TicketNotifier::$closed = [];
|
||||
\AKSRT\Ticket\TicketNotifier::$user_replied = [];
|
||||
\AKSRT\Ticket\TicketNoteService::$created = [];
|
||||
\AKSRT\Ticket\TicketSettings::$order_link_enabled = false;
|
||||
\Jio\Ticket\TicketRepository::$creates = [];
|
||||
\Jio\Ticket\TicketRepository::$updates = [];
|
||||
\Jio\Ticket\TicketNotifier::$closed = [];
|
||||
\Jio\Ticket\TicketNotifier::$user_replied = [];
|
||||
\Jio\Ticket\TicketNoteService::$created = [];
|
||||
\Jio\Ticket\TicketSettings::$order_link_enabled = false;
|
||||
$GLOBALS['ticket_rest_user_can_calls'] = [];
|
||||
};
|
||||
$admin = new \AKSRT\Ticket\TicketRestAdmin();
|
||||
$admin = new \Jio\Ticket\TicketRestAdmin();
|
||||
$error_code = static fn($value): string => $value instanceof \WP_Error ? $value->code : '';
|
||||
|
||||
// Explicit admin_id=0 clears assignment and status updates always touch updated_at.
|
||||
$reset();
|
||||
$response = $admin->set_status(new \WP_REST_Request(['id' => 1, 'status' => 'handling', 'admin_id' => 0]));
|
||||
$saved = \AKSRT\Ticket\TicketRepository::$tickets[1] ?? [];
|
||||
$saved = \Jio\Ticket\TicketRepository::$tickets[1] ?? [];
|
||||
$check('解除指派接受 admin_id=0', !\is_wp_error($response) && ($saved['admin_id'] ?? null) === 0);
|
||||
$check('状态更新写入 updated_at', ($saved['updated_at'] ?? '') === '2026-10-31 12:34:56');
|
||||
|
||||
// Invalid department returns an explicit error and performs no write.
|
||||
$reset();
|
||||
$response = $admin->set_status(new \WP_REST_Request(['id' => 1, 'status' => 'handling', 'ticket_type_id' => 999]));
|
||||
$check('非法部门返回明确错误', $error_code($response) === 'aksrt_ticket_type');
|
||||
$check('非法部门不写入任何字段', \AKSRT\Ticket\TicketRepository::$updates === []);
|
||||
$check('非法部门返回明确错误', $error_code($response) === 'jio_ticket_type');
|
||||
$check('非法部门不写入任何字段', \Jio\Ticket\TicketRepository::$updates === []);
|
||||
|
||||
// Existing assignees may lose admin capability; retaining the same ID isn't a new assignment.
|
||||
$reset();
|
||||
\AKSRT\Ticket\TicketRepository::$tickets[1]['admin_id'] = 12;
|
||||
\Jio\Ticket\TicketRepository::$tickets[1]['admin_id'] = 12;
|
||||
$response = $admin->set_status(new \WP_REST_Request([
|
||||
'id' => 1,
|
||||
'status' => 'admin_replied',
|
||||
'ticket_type_id' => 4,
|
||||
'admin_id' => 12,
|
||||
]));
|
||||
$saved = \AKSRT\Ticket\TicketRepository::$tickets[1] ?? [];
|
||||
$saved = \Jio\Ticket\TicketRepository::$tickets[1] ?? [];
|
||||
$check('保留已失去管理员权限的原跟进人仍可更新状态和部门', !\is_wp_error($response)
|
||||
&& ($saved['status'] ?? null) === 'admin_replied'
|
||||
&& ($saved['ticket_type_id'] ?? null) === 4
|
||||
@@ -201,8 +201,8 @@ namespace {
|
||||
'ticket_type_id' => 4,
|
||||
'admin_id' => 12,
|
||||
]));
|
||||
$check('无 manage_options 的用户不能被指派', $error_code($response) === 'aksrt_ticket_admin');
|
||||
$check('管理员校验失败时部门也不被部分写入', \AKSRT\Ticket\TicketRepository::$updates === []);
|
||||
$check('无 manage_options 的用户不能被指派', $error_code($response) === 'jio_ticket_admin');
|
||||
$check('管理员校验失败时部门也不被部分写入', \Jio\Ticket\TicketRepository::$updates === []);
|
||||
$check('目标管理员必须通过 manage_options 校验', in_array([12, 'manage_options'], $GLOBALS['ticket_rest_user_can_calls'], true));
|
||||
|
||||
$reset();
|
||||
@@ -211,13 +211,13 @@ namespace {
|
||||
'status' => 'handling',
|
||||
'admin_id' => 777,
|
||||
]));
|
||||
$check('不存在的管理员返回明确错误', $error_code($response) === 'aksrt_ticket_admin');
|
||||
$check('不存在的管理员返回明确错误', $error_code($response) === 'jio_ticket_admin');
|
||||
|
||||
|
||||
$check('不存在的管理员不会触发写入', \AKSRT\Ticket\TicketRepository::$updates === []);
|
||||
$check('不存在的管理员不会触发写入', \Jio\Ticket\TicketRepository::$updates === []);
|
||||
|
||||
$reset();
|
||||
\AKSRT\Ticket\TicketRepository::$tickets[1]['admin_id'] = 12;
|
||||
\Jio\Ticket\TicketRepository::$tickets[1]['admin_id'] = 12;
|
||||
$response = $admin->set_status(new \WP_REST_Request([
|
||||
'id' => 1,
|
||||
'status' => 'handling',
|
||||
@@ -225,18 +225,18 @@ namespace {
|
||||
]));
|
||||
$check('具备 manage_options 的管理员可被指派', !\is_wp_error($response)
|
||||
&& in_array([11, 'manage_options'], $GLOBALS['ticket_rest_user_can_calls'], true)
|
||||
&& (\AKSRT\Ticket\TicketRepository::$tickets[1]['admin_id'] ?? null) === 11);
|
||||
&& (\Jio\Ticket\TicketRepository::$tickets[1]['admin_id'] ?? null) === 11);
|
||||
|
||||
// Only the first open -> closed transition sends a close notification.
|
||||
$reset();
|
||||
$first_close = $admin->set_status(new \WP_REST_Request(['id' => 3, 'status' => 'closed']));
|
||||
$second_close = $admin->set_status(new \WP_REST_Request(['id' => 3, 'status' => 'closed']));
|
||||
$check('首次关闭成功', !\is_wp_error($first_close));
|
||||
$check('同状态再次提交不重发关闭通知', count(\AKSRT\Ticket\TicketNotifier::$closed) === 1);
|
||||
$check('同状态再次提交不重发关闭通知', count(\Jio\Ticket\TicketNotifier::$closed) === 1);
|
||||
|
||||
// Order association follows the feature switch.
|
||||
$reset();
|
||||
\AKSRT\Ticket\TicketSettings::$order_link_enabled = false;
|
||||
\Jio\Ticket\TicketSettings::$order_link_enabled = false;
|
||||
$admin->create_ticket(new \WP_REST_Request([
|
||||
'user_id' => 10,
|
||||
'title' => '代客提交标题',
|
||||
@@ -244,9 +244,9 @@ namespace {
|
||||
'content' => '这是问题描述内容',
|
||||
'order_number' => 'ORD-1',
|
||||
]));
|
||||
$check('关闭订单关联时忽略订单号', (\AKSRT\Ticket\TicketRepository::$creates[0]['order_number'] ?? null) === '');
|
||||
$check('关闭订单关联时忽略订单号', (\Jio\Ticket\TicketRepository::$creates[0]['order_number'] ?? null) === '');
|
||||
|
||||
\AKSRT\Ticket\TicketSettings::$order_link_enabled = true;
|
||||
\Jio\Ticket\TicketSettings::$order_link_enabled = true;
|
||||
$admin->create_ticket(new \WP_REST_Request([
|
||||
'user_id' => 10,
|
||||
'title' => '代客提交标题',
|
||||
@@ -254,7 +254,7 @@ namespace {
|
||||
'content' => '这是问题描述内容',
|
||||
'order_number' => '<b>ORD-2</b>',
|
||||
]));
|
||||
$check('开启订单关联时保存已消毒订单号', (\AKSRT\Ticket\TicketRepository::$creates[1]['order_number'] ?? null) === 'ORD-2');
|
||||
$check('开启订单关联时保存已消毒订单号', (\Jio\Ticket\TicketRepository::$creates[1]['order_number'] ?? null) === 'ORD-2');
|
||||
|
||||
// Internal note writes enforce existence, trim, non-empty and configured maximum length.
|
||||
$reset();
|
||||
@@ -262,10 +262,10 @@ namespace {
|
||||
$empty = $admin->create_note(new \WP_REST_Request(['id' => 1, 'content' => " \n\t "]));
|
||||
$long = $admin->create_note(new \WP_REST_Request(['id' => 1, 'content' => '123456']));
|
||||
$valid = $admin->create_note(new \WP_REST_Request(['id' => 1, 'content' => ' memo ']));
|
||||
$created = \AKSRT\Ticket\TicketNoteService::$created;
|
||||
$check('备注工单不存在时返回 404', $error_code($missing) === 'aksrt_ticket_missing');
|
||||
$check('备注拒绝空内容', $error_code($empty) === 'aksrt_ticket_note_content');
|
||||
$check('备注拒绝超长内容', $error_code($long) === 'aksrt_ticket_note_content');
|
||||
$created = \Jio\Ticket\TicketNoteService::$created;
|
||||
$check('备注工单不存在时返回 404', $error_code($missing) === 'jio_ticket_missing');
|
||||
$check('备注拒绝空内容', $error_code($empty) === 'jio_ticket_note_content');
|
||||
$check('备注拒绝超长内容', $error_code($long) === 'jio_ticket_note_content');
|
||||
$check('备注 trim 后保存', !\is_wp_error($valid) && ($created[0]['content'] ?? null) === 'memo');
|
||||
$check('无效备注未调用创建服务', count($created) === 1);
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace {
|
||||
function wp_get_current_user() { return (object) ['ID' => 7, 'display_name' => 'Operator']; }
|
||||
function get_users($args) { return [(object) ['ID' => 7, 'display_name' => 'Operator'], (object) ['ID' => 8, 'display_name' => 'Second']]; }
|
||||
function get_edit_user_link($id) { return admin_url('user-edit.php?user_id=' . $id); }
|
||||
function aksrt_get_avatar_url($id, $size) { return 'https://example.test/avatar/' . $id; }
|
||||
function jio_get_avatar_url($id, $size) { return 'https://example.test/avatar/' . $id; }
|
||||
function add_query_arg($args, $url, $base = null) {
|
||||
if (!is_array($args)) { $args = [$args => $url]; $url = $base; }
|
||||
$parts = parse_url($url);
|
||||
@@ -30,7 +30,7 @@ namespace {
|
||||
return $parts['scheme'] . '://' . $parts['host'] . ($parts['path'] ?? '') . '?' . http_build_query(array_merge($query, $args));
|
||||
}
|
||||
}
|
||||
namespace AKSRT\Ticket {
|
||||
namespace Jio\Ticket {
|
||||
class TicketSettings {
|
||||
public static bool $orders = true;
|
||||
public static function title_max() { return 100; }
|
||||
@@ -94,8 +94,8 @@ namespace AKSRT\Ticket {
|
||||
}
|
||||
}
|
||||
}
|
||||
namespace AKSRT\Core {
|
||||
class DBMigrator { public static function table($name) { return 'wp_aksrt_' . $name; } }
|
||||
namespace Jio\Core {
|
||||
class DBMigrator { public static function table($name) { return 'wp_jio_' . $name; } }
|
||||
}
|
||||
namespace {
|
||||
$root = dirname(__DIR__, 2);
|
||||
@@ -104,12 +104,12 @@ namespace {
|
||||
}
|
||||
require $root . '/src/Ticket/TicketQuery.php';
|
||||
class TicketPage {
|
||||
use \AKSRT\Admin\Native\UsersMenusTicketsCenter;
|
||||
use \Jio\Admin\Native\UsersMenusTicketsCenter;
|
||||
public const CAPABILITY = 'manage_options';
|
||||
private function ensure_cap() {}
|
||||
}
|
||||
class QueryProbe {
|
||||
use \AKSRT\Ticket\TicketQuery;
|
||||
use \Jio\Ticket\TicketQuery;
|
||||
public function where($args) { return $this->ticket_where($args, true); }
|
||||
public function counts($args) { return $this->ticket_statistic($args, true); }
|
||||
}
|
||||
@@ -126,20 +126,20 @@ namespace {
|
||||
$page->render_tickets_page();
|
||||
return (string) ob_get_clean();
|
||||
}
|
||||
$repo = \AKSRT\Ticket\TicketRepository::class;
|
||||
$repo = \Jio\Ticket\TicketRepository::class;
|
||||
$page = new TicketPage();
|
||||
$list = render_page($page, ['status' => 'handling', 'ticket_type_id' => 1, 's' => 'needle', 'paged' => 99]);
|
||||
$initial = ['queries' => $repo::$queries, 'counts' => $repo::$counts, 'detail_reads' => $repo::$reads, 'reply_reads' => $repo::$replies_read];
|
||||
$list_queries = count($repo::$queries);
|
||||
$open = render_page($page, ['id' => 21, 'status' => 'pending', 's' => 'not in list', 'paged' => 3, 'aksrt_ticket_msg' => 'reply']);
|
||||
$open = render_page($page, ['id' => 21, 'status' => 'pending', 's' => 'not in list', 'paged' => 3, 'jio_ticket_msg' => 'reply']);
|
||||
$closed = render_page($page, ['id' => 99]);
|
||||
$missing = render_page($page, ['id' => 404]);
|
||||
$detail_list_queries = count($repo::$queries) - $list_queries;
|
||||
$bogus_notice = render_page($page, ['id' => 21, 'aksrt_ticket_msg' => '<script>']);
|
||||
\AKSRT\Ticket\TicketTypeService::$empty = true;
|
||||
$bogus_notice = render_page($page, ['id' => 21, 'jio_ticket_msg' => '<script>']);
|
||||
\Jio\Ticket\TicketTypeService::$empty = true;
|
||||
$no_types = render_page($page, []);
|
||||
\AKSRT\Ticket\TicketTypeService::$empty = false;
|
||||
\AKSRT\Ticket\TicketSettings::$orders = false;
|
||||
\Jio\Ticket\TicketTypeService::$empty = false;
|
||||
\Jio\Ticket\TicketSettings::$orders = false;
|
||||
$no_orders = render_page($page, []);
|
||||
$GLOBALS['wpdb'] = new FakeDb();
|
||||
$query = new QueryProbe();
|
||||
|
||||
@@ -16,10 +16,10 @@ function rendered() {
|
||||
test('list view links rows to the workspace and offers creation only as a dialog', () => {
|
||||
const { list, initial } = rendered();
|
||||
assert.equal((list.match(/<dialog /g) || []).length, 1, 'only the create dialog');
|
||||
assert.match(list, /aksrt-native-header__actions[^]*data-aksrt-dialog-open="aksrt-ticket-create-dialog"/);
|
||||
assert.match(list, /jio-native-header__actions[^]*data-jio-dialog-open="jio-ticket-create-dialog"/);
|
||||
assert.doesNotMatch(list, /view=new/);
|
||||
assert.match(list, /<a class="row-title" href="[^"]*page=aksrt_tickets&id=21&status=handling&ticket_type_id=1&s=needle&paged=2"/);
|
||||
assert.doesNotMatch(list, /data-aksrt-ticket-detail=|data-aksrt-ticket-form="(?:reply|status|note)"/);
|
||||
assert.match(list, /<a class="row-title" href="[^"]*page=jio_tickets&id=21&status=handling&ticket_type_id=1&s=needle&paged=2"/);
|
||||
assert.doesNotMatch(list, /data-jio-ticket-detail=|data-jio-ticket-form="(?:reply|status|note)"/);
|
||||
assert.equal(initial.detail_reads, 0);
|
||||
assert.equal(initial.reply_reads, 0);
|
||||
assert.equal(initial.queries.at(-1).offset, 20);
|
||||
@@ -31,31 +31,31 @@ test('list view links rows to the workspace and offers creation only as a dialog
|
||||
test('workspace loads by ID independent of list filters and keeps the list context for going back', () => {
|
||||
const { open, closed, detail_list_queries: listQueries } = rendered();
|
||||
assert.equal(listQueries, 0, 'workspace must not query the list');
|
||||
assert.match(open, /<h1 class="aksrt-native-header__title">[^]*Question <svg onload=alert\(1\)><\/h1>/);
|
||||
assert.match(open, /href="[^"]*page=aksrt_tickets&status=pending&s=not\+in\+list&paged=3"[^>]*>[^]*返回工单列表/);
|
||||
assert.match(open, /data-aksrt-ticket-detail="21"/);
|
||||
for (const action of ['reply', 'status', 'note']) assert.ok(open.includes(`data-aksrt-ticket-form="${action}"`));
|
||||
assert.match(open, /action="https:\/\/example.test\/wp-json\/aksrt\/v1\/admin\/tickets\/21\/notes"/);
|
||||
assert.match(open, /data-aksrt-ticket-close-confirm/);
|
||||
assert.match(open, /<h1 class="jio-native-header__title">[^]*Question <svg onload=alert\(1\)><\/h1>/);
|
||||
assert.match(open, /href="[^"]*page=jio_tickets&status=pending&s=not\+in\+list&paged=3"[^>]*>[^]*返回工单列表/);
|
||||
assert.match(open, /data-jio-ticket-detail="21"/);
|
||||
for (const action of ['reply', 'status', 'note']) assert.ok(open.includes(`data-jio-ticket-form="${action}"`));
|
||||
assert.match(open, /action="https:\/\/example.test\/wp-json\/jio\/v1\/admin\/tickets\/21\/notes"/);
|
||||
assert.match(open, /data-jio-ticket-close-confirm/);
|
||||
assert.match(open, /value="closed" data-closed="1"/);
|
||||
assert.match(open, /<dt>工单号<\/dt><dd>TK-00021<\/dd>/);
|
||||
assert.match(open, /data-aksrt-ticket-feedback/);
|
||||
assert.match(closed, /data-aksrt-ticket-detail="99"/);
|
||||
assert.match(closed, /aksrt-ticket-detail__closed/);
|
||||
assert.match(closed, /data-aksrt-ticket-form="note"/);
|
||||
assert.doesNotMatch(closed, /data-aksrt-ticket-form="(?:reply|status)"/);
|
||||
assert.match(open, /data-jio-ticket-feedback/);
|
||||
assert.match(closed, /data-jio-ticket-detail="99"/);
|
||||
assert.match(closed, /jio-ticket-detail__closed/);
|
||||
assert.match(closed, /data-jio-ticket-form="note"/);
|
||||
assert.doesNotMatch(closed, /data-jio-ticket-form="(?:reply|status)"/);
|
||||
// 回复框是会话卡片的底部,不是独立卡片;工作区唯一的弹窗是内部备注。
|
||||
const conversation = open.match(/<section class="aksrt-ticket-conversation"[^]*?<\/section>/)?.[0] || '';
|
||||
assert.match(conversation, /aksrt-ticket-conversation__scroll[^]*data-aksrt-ticket-form="reply"/);
|
||||
assert.match(conversation, /data-aksrt-ticket-send-shortcut/);
|
||||
const conversation = open.match(/<section class="jio-ticket-conversation"[^]*?<\/section>/)?.[0] || '';
|
||||
assert.match(conversation, /jio-ticket-conversation__scroll[^]*data-jio-ticket-form="reply"/);
|
||||
assert.match(conversation, /data-jio-ticket-send-shortcut/);
|
||||
assert.match(conversation, /<button type="submit" class="button button-primary">[^]*发送回复<\/button>/);
|
||||
for (const html of [open, closed]) {
|
||||
assert.equal((html.match(/<dialog /g) || []).length, 1);
|
||||
assert.match(html, /<dialog id="aksrt-ticket-note-dialog"[^]*data-aksrt-ticket-form="note"[^]*<\/dialog>/);
|
||||
assert.match(html, /data-aksrt-dialog-open="aksrt-ticket-note-dialog"/);
|
||||
assert.match(html, /<dialog id="jio-ticket-note-dialog"[^]*data-jio-ticket-form="note"[^]*<\/dialog>/);
|
||||
assert.match(html, /data-jio-dialog-open="jio-ticket-note-dialog"/);
|
||||
}
|
||||
const sidebar = open.match(/<aside\b[^]*?<\/aside>/)?.[0] || '';
|
||||
assert.doesNotMatch(sidebar, /<textarea|data-aksrt-ticket-form="note"/, 'note input lives only in the dialog');
|
||||
assert.doesNotMatch(sidebar, /<textarea|data-jio-ticket-form="note"/, 'note input lives only in the dialog');
|
||||
});
|
||||
|
||||
test('result codes render as one native notice and unknown codes are ignored', () => {
|
||||
@@ -70,18 +70,18 @@ test('ticket information owns the only status editor and closed tickets stay rea
|
||||
const { open, closed } = rendered();
|
||||
const sidebarCards = html => {
|
||||
const sidebar = html.match(/<aside\b[^>]*>([\s\S]*?)<\/aside>/)?.[1] || '';
|
||||
return [...sidebar.matchAll(/<section class="aksrt-ticket-detail__card(?: [^"]+)?">([\s\S]*?)<\/section>/g)].map(match => match[1]);
|
||||
return [...sidebar.matchAll(/<section class="jio-ticket-detail__card(?: [^"]+)?">([\s\S]*?)<\/section>/g)].map(match => match[1]);
|
||||
};
|
||||
const cards = sidebarCards(open);
|
||||
assert.equal(cards.length, 2, 'only ticket information and internal notes remain');
|
||||
const info = cards[0];
|
||||
assert.match(info, /<h3>工单信息<\/h3>/);
|
||||
assert.match(info, /data-aksrt-ticket-form="status"/);
|
||||
assert.match(info, /data-aksrt-ticket-assign/);
|
||||
assert.match(info, /data-jio-ticket-form="status"/);
|
||||
assert.match(info, /data-jio-ticket-assign/);
|
||||
assert.match(info, /保存工单信息/);
|
||||
assert.doesNotMatch(info, /aksrt-ticket-badge/);
|
||||
assert.doesNotMatch(info, /jio-ticket-badge/);
|
||||
for (const [name, label] of [['status', '状态'], ['ticket_type_id', '部门'], ['admin_id', '跟进人']]) {
|
||||
const id = `aksrt-ticket-${name}-21`;
|
||||
const id = `jio-ticket-${name}-21`;
|
||||
assert.ok(info.includes(`<label for="${id}">${label}</label>`));
|
||||
assert.ok(info.includes(`<select id="${id}" name="${name}"`));
|
||||
assert.equal((open.match(new RegExp(`name="${name}"`, 'g')) || []).length, 1);
|
||||
@@ -89,25 +89,25 @@ test('ticket information owns the only status editor and closed tickets stay rea
|
||||
assert.match(cards[1], /内部备注/);
|
||||
const closedInfo = sidebarCards(closed)[0];
|
||||
assert.match(closedInfo, /<h3>工单信息<\/h3>/);
|
||||
assert.match(closedInfo, /aksrt-ticket-badge/);
|
||||
assert.doesNotMatch(closedInfo, /<form|<select|data-aksrt-ticket-assign|保存工单信息/);
|
||||
assert.match(closedInfo, /jio-ticket-badge/);
|
||||
assert.doesNotMatch(closedInfo, /<form|<select|data-jio-ticket-assign|保存工单信息/);
|
||||
});
|
||||
|
||||
test('missing ticket renders an empty state with a way back and no forms', () => {
|
||||
const { missing } = rendered();
|
||||
assert.match(missing, /工单不存在/);
|
||||
assert.match(missing, /返回工单列表/);
|
||||
assert.doesNotMatch(missing, /data-aksrt-ticket-form|data-aksrt-ticket-detail/);
|
||||
assert.doesNotMatch(missing, /data-jio-ticket-form|data-jio-ticket-detail/);
|
||||
});
|
||||
|
||||
test('create dialog is a labelled REST form with its own feedback and close controls', () => {
|
||||
const { list } = rendered();
|
||||
const dialog = list.match(/<dialog id="aksrt-ticket-create-dialog"[^]*?<\/dialog>/)?.[0] || '';
|
||||
assert.match(dialog, /aria-labelledby="aksrt-ticket-create-title"/);
|
||||
assert.match(dialog, /<form method="post" action="https:\/\/example.test\/wp-json\/aksrt\/v1\/admin\/tickets" class="aksrt-ticket-dialog__frame" data-aksrt-ticket-form="create">/);
|
||||
const dialog = list.match(/<dialog id="jio-ticket-create-dialog"[^]*?<\/dialog>/)?.[0] || '';
|
||||
assert.match(dialog, /aria-labelledby="jio-ticket-create-title"/);
|
||||
assert.match(dialog, /<form method="post" action="https:\/\/example.test\/wp-json\/jio\/v1\/admin\/tickets" class="jio-ticket-dialog__frame" data-jio-ticket-form="create">/);
|
||||
for (const name of ['user_id', 'ticket_type_id', 'title', 'order_number', 'content']) assert.ok(dialog.includes(`name="${name}"`), name);
|
||||
assert.match(dialog, /data-aksrt-ticket-feedback/);
|
||||
assert.equal((dialog.match(/data-aksrt-dialog-close/g) || []).length, 2, 'header X and footer cancel');
|
||||
assert.match(dialog, /data-jio-ticket-feedback/);
|
||||
assert.equal((dialog.match(/data-jio-dialog-close/g) || []).length, 2, 'header X and footer cancel');
|
||||
});
|
||||
|
||||
test('real rendering escapes user content, quotes and metadata', () => {
|
||||
@@ -125,9 +125,9 @@ test('real rendering escapes user content, quotes and metadata', () => {
|
||||
test('missing departments and disabled order links have explicit creation states', () => {
|
||||
const { no_types: noTypes, no_orders: noOrders } = rendered();
|
||||
assert.match(noTypes, /尚未配置工单部门/);
|
||||
assert.doesNotMatch(noTypes, /data-aksrt-ticket-form="create"/);
|
||||
assert.doesNotMatch(noTypes, /data-jio-ticket-form="create"/);
|
||||
assert.match(noTypes, /前往工单配置/);
|
||||
assert.match(noOrders, /data-aksrt-ticket-form="create"/);
|
||||
assert.match(noOrders, /data-jio-ticket-form="create"/);
|
||||
assert.doesNotMatch(noOrders, /name="order_number"/);
|
||||
});
|
||||
|
||||
|
||||
@@ -8,9 +8,9 @@ const vm = require('node:vm');
|
||||
|
||||
const scriptPath = path.resolve(__dirname, '../../assets/js/admin-tickets.js');
|
||||
const strings = { saving: 'Saving', saveFailed: 'Save failed', uncertain: 'Unknown result', required: 'Required', tooLong: 'Too long', discard: 'Discard?' };
|
||||
const REST = 'https://site.test/wp-json/aksrt/v1/admin/tickets';
|
||||
const REST = 'https://site.test/wp-json/jio/v1/admin/tickets';
|
||||
|
||||
function makeRuntime({ href = 'https://site.test/wp-admin/users.php?page=aksrt_tickets&id=41', page = 'detail', storage = {} } = {}) {
|
||||
function makeRuntime({ href = 'https://site.test/wp-admin/users.php?page=jio_tickets&id=41', page = 'detail', storage = {} } = {}) {
|
||||
const ids = new Map();
|
||||
const document = { activeElement: null };
|
||||
|
||||
@@ -134,69 +134,69 @@ function makeRuntime({ href = 'https://site.test/wp-admin/users.php?page=aksrt_t
|
||||
};
|
||||
|
||||
function makeDialog(id) {
|
||||
const dialog = el('dialog', { id, class: 'aksrt-ticket-dialog' }, root);
|
||||
const dialog = el('dialog', { id, class: 'jio-ticket-dialog' }, root);
|
||||
dialog.open = false;
|
||||
dialog.showModal = () => { dialog.open = true; };
|
||||
dialog.close = () => { if (!dialog.open) return; dialog.open = false; dialog.fire('close'); };
|
||||
return dialog;
|
||||
}
|
||||
|
||||
const root = new Element('div', { class: 'aksrt-tickets-admin' });
|
||||
const feedback = el('div', { 'data-aksrt-ticket-feedback': '', hidden: '' }, root);
|
||||
const root = new Element('div', { class: 'jio-tickets-admin' });
|
||||
const feedback = el('div', { 'data-jio-ticket-feedback': '', hidden: '' }, root);
|
||||
el('p', {}, feedback);
|
||||
el('button', { type: 'button', 'data-aksrt-ticket-reload': '', hidden: '' }, feedback);
|
||||
el('button', { type: 'button', 'data-jio-ticket-reload': '', hidden: '' }, feedback);
|
||||
const nodes = { root, feedback };
|
||||
|
||||
if (page === 'detail') {
|
||||
const detail = el('div', { 'data-aksrt-ticket-detail': '41' }, root);
|
||||
nodes.latest = el('button', { type: 'button', 'data-aksrt-ticket-latest': '', hidden: '' }, detail);
|
||||
nodes.conversation = el('div', { class: 'aksrt-ticket-conversation__scroll' }, detail);
|
||||
const reply = nodes.reply = el('form', { action: `${REST}/41/reply`, 'data-aksrt-ticket-form': 'reply' }, detail);
|
||||
nodes.replyText = el('textarea', { id: 'aksrt-ticket-reply-41', name: 'content', required: '', maxlength: '24', 'data-aksrt-ticket-editor': '' }, reply);
|
||||
nodes.replyCount = el('span', { 'data-aksrt-ticket-counter': 'aksrt-ticket-reply-41' }, reply);
|
||||
nodes.prereply = select(reply, { 'data-aksrt-ticket-prereply': 'aksrt-ticket-reply-41' }, [[''], ['short'], ['01234567890123456789012345']]);
|
||||
const detail = el('div', { 'data-jio-ticket-detail': '41' }, root);
|
||||
nodes.latest = el('button', { type: 'button', 'data-jio-ticket-latest': '', hidden: '' }, detail);
|
||||
nodes.conversation = el('div', { class: 'jio-ticket-conversation__scroll' }, detail);
|
||||
const reply = nodes.reply = el('form', { action: `${REST}/41/reply`, 'data-jio-ticket-form': 'reply' }, detail);
|
||||
nodes.replyText = el('textarea', { id: 'jio-ticket-reply-41', name: 'content', required: '', maxlength: '24', 'data-jio-ticket-editor': '' }, reply);
|
||||
nodes.replyCount = el('span', { 'data-jio-ticket-counter': 'jio-ticket-reply-41' }, reply);
|
||||
nodes.prereply = select(reply, { 'data-jio-ticket-prereply': 'jio-ticket-reply-41' }, [[''], ['short'], ['01234567890123456789012345']]);
|
||||
el('button', { type: 'submit' }, reply);
|
||||
const section = el('section', {}, detail);
|
||||
nodes.assign = el('button', { type: 'button', 'data-aksrt-ticket-assign': '' }, section);
|
||||
const status = nodes.status = el('form', { action: `${REST}/41/status`, 'data-aksrt-ticket-form': 'status' }, section);
|
||||
nodes.statusSelect = select(status, { name: 'status', 'data-aksrt-ticket-status': '' }, [['pending', { 'data-closed': '0' }], ['handling', { 'data-closed': '0' }], ['closed', { 'data-closed': '1' }]], 'pending');
|
||||
nodes.assign = el('button', { type: 'button', 'data-jio-ticket-assign': '' }, section);
|
||||
const status = nodes.status = el('form', { action: `${REST}/41/status`, 'data-jio-ticket-form': 'status' }, section);
|
||||
nodes.statusSelect = select(status, { name: 'status', 'data-jio-ticket-status': '' }, [['pending', { 'data-closed': '0' }], ['handling', { 'data-closed': '0' }], ['closed', { 'data-closed': '1' }]], 'pending');
|
||||
select(status, { name: 'ticket_type_id', required: '' }, [['3'], ['6']], '3');
|
||||
nodes.admin = select(status, { name: 'admin_id' }, [['0'], ['7'], ['44']], '7');
|
||||
nodes.warning = el('div', { 'data-aksrt-ticket-close-warning': '', hidden: '' }, status);
|
||||
nodes.confirm = el('input', { type: 'checkbox', 'data-aksrt-ticket-close-confirm': '' }, nodes.warning);
|
||||
nodes.warning = el('div', { 'data-jio-ticket-close-warning': '', hidden: '' }, status);
|
||||
nodes.confirm = el('input', { type: 'checkbox', 'data-jio-ticket-close-confirm': '' }, nodes.warning);
|
||||
nodes.statusSubmit = el('button', { type: 'submit' }, status);
|
||||
nodes.noteOpener = el('button', { type: 'button', 'data-aksrt-dialog-open': 'aksrt-ticket-note-dialog' }, detail);
|
||||
const noteDialog = nodes.noteDialog = makeDialog('aksrt-ticket-note-dialog');
|
||||
const note = nodes.note = el('form', { action: `${REST}/41/notes`, 'data-aksrt-ticket-form': 'note' }, noteDialog);
|
||||
nodes.noteClose = el('button', { type: 'button', 'data-aksrt-dialog-close': '' }, note);
|
||||
nodes.noteFeedback = el('div', { 'data-aksrt-ticket-feedback': '', hidden: '' }, note);
|
||||
nodes.noteOpener = el('button', { type: 'button', 'data-jio-dialog-open': 'jio-ticket-note-dialog' }, detail);
|
||||
const noteDialog = nodes.noteDialog = makeDialog('jio-ticket-note-dialog');
|
||||
const note = nodes.note = el('form', { action: `${REST}/41/notes`, 'data-jio-ticket-form': 'note' }, noteDialog);
|
||||
nodes.noteClose = el('button', { type: 'button', 'data-jio-dialog-close': '' }, note);
|
||||
nodes.noteFeedback = el('div', { 'data-jio-ticket-feedback': '', hidden: '' }, note);
|
||||
el('p', {}, nodes.noteFeedback);
|
||||
el('button', { type: 'button', 'data-aksrt-ticket-reload': '', hidden: '' }, nodes.noteFeedback);
|
||||
nodes.noteText = el('textarea', { id: 'aksrt-ticket-note-41', name: 'content', required: '', autofocus: '', maxlength: '24', 'data-aksrt-ticket-editor': '' }, note);
|
||||
el('button', { type: 'button', 'data-jio-ticket-reload': '', hidden: '' }, nodes.noteFeedback);
|
||||
nodes.noteText = el('textarea', { id: 'jio-ticket-note-41', name: 'content', required: '', autofocus: '', maxlength: '24', 'data-jio-ticket-editor': '' }, note);
|
||||
el('button', { type: 'submit' }, note);
|
||||
note.reset = () => { nodes.noteText.value = ''; };
|
||||
nodes.replyText.attrs['data-aksrt-ticket-send-shortcut'] = '';
|
||||
nodes.replyText.attrs['data-jio-ticket-send-shortcut'] = '';
|
||||
reply.requestSubmit = () => reply.fire('submit') && root.fire('submit', { target: reply });
|
||||
} else {
|
||||
nodes.opener = el('button', { type: 'button', 'data-aksrt-dialog-open': 'aksrt-ticket-create-dialog' }, root);
|
||||
const dialog = nodes.dialog = makeDialog('aksrt-ticket-create-dialog');
|
||||
const create = nodes.create = el('form', { action: REST, 'data-aksrt-ticket-form': 'create' }, dialog);
|
||||
nodes.closeButton = el('button', { type: 'button', 'data-aksrt-dialog-close': '' }, create);
|
||||
nodes.opener = el('button', { type: 'button', 'data-jio-dialog-open': 'jio-ticket-create-dialog' }, root);
|
||||
const dialog = nodes.dialog = makeDialog('jio-ticket-create-dialog');
|
||||
const create = nodes.create = el('form', { action: REST, 'data-jio-ticket-form': 'create' }, dialog);
|
||||
nodes.closeButton = el('button', { type: 'button', 'data-jio-dialog-close': '' }, create);
|
||||
el('input', { type: 'number', name: 'user_id', required: '' }, create);
|
||||
select(create, { name: 'ticket_type_id', required: '' }, [[''], ['3']], '');
|
||||
el('input', { type: 'text', name: 'title', required: '' }, create);
|
||||
el('textarea', { id: 'aksrt-ticket-create-content', name: 'content', required: '', maxlength: '500', 'data-aksrt-ticket-editor': '' }, create);
|
||||
el('textarea', { id: 'jio-ticket-create-content', name: 'content', required: '', maxlength: '500', 'data-jio-ticket-editor': '' }, create);
|
||||
el('button', { type: 'submit' }, create);
|
||||
create.reset = () => create.querySelectorAll('input, select, textarea').forEach((control) => { control.value = ''; });
|
||||
}
|
||||
|
||||
document.querySelector = (selector) => (selector === '.aksrt-tickets-admin' ? root : null);
|
||||
document.querySelector = (selector) => (selector === '.jio-tickets-admin' ? root : null);
|
||||
document.getElementById = (id) => ids.get(id) || null;
|
||||
|
||||
const store = new Map(Object.entries(storage));
|
||||
const window = new Element('window');
|
||||
Object.assign(window, {
|
||||
AKSRTAdminTickets: { restNonce: 'rest-nonce', currentUser: 44, strings },
|
||||
JioAdminTickets: { restNonce: 'rest-nonce', currentUser: 44, strings },
|
||||
location: { href, assigned: null, reloads: 0, assign(url) { this.assigned = url; }, reload() { this.reloads += 1; } },
|
||||
history: { state: null, replaceState(_state, _title, url) { window.location.href = url; } },
|
||||
sessionStorage: { getItem: (key) => store.get(key) ?? null, setItem: (key, value) => store.set(key, String(value)), removeItem: (key) => store.delete(key) },
|
||||
@@ -218,7 +218,7 @@ const submit = (rt, form) => rt.root.fire('submit', { target: form });
|
||||
const unload = (rt) => rt.window.fire('beforeunload', { returnValue: undefined });
|
||||
|
||||
test('a successful reply posts JSON to REST, then reloads the workspace with a result code and stashes other drafts', async () => {
|
||||
const rt = makeRuntime({ href: 'https://site.test/wp-admin/users.php?page=aksrt_tickets&id=41&status=pending&paged=3' });
|
||||
const rt = makeRuntime({ href: 'https://site.test/wp-admin/users.php?page=jio_tickets&id=41&status=pending&paged=3' });
|
||||
type(rt, rt.noteText, 'pending note');
|
||||
type(rt, rt.replyText, 'hello');
|
||||
const event = submit(rt, rt.reply);
|
||||
@@ -237,27 +237,27 @@ test('a successful reply posts JSON to REST, then reloads the workspace with a r
|
||||
await tick();
|
||||
const next = new URL(rt.window.location.assigned);
|
||||
assert.equal(next.searchParams.get('id'), '41');
|
||||
assert.equal(next.searchParams.get('aksrt_ticket_msg'), 'reply');
|
||||
assert.equal(next.searchParams.get('jio_ticket_msg'), 'reply');
|
||||
assert.equal(next.searchParams.get('status'), 'pending');
|
||||
assert.equal(next.searchParams.get('paged'), '3');
|
||||
assert.deepEqual(JSON.parse(rt.store.get('aksrt-ticket-drafts-41')), { note: { content: 'pending note' } });
|
||||
assert.deepEqual(JSON.parse(rt.store.get('jio-ticket-drafts-41')), { note: { content: 'pending note' } });
|
||||
assert.equal(unload(rt).defaultPrevented, false, 'navigation after save is not blocked');
|
||||
});
|
||||
|
||||
test('after the reload, stashed drafts are restored once and the result code is stripped from the URL', () => {
|
||||
const rt = makeRuntime({
|
||||
href: 'https://site.test/wp-admin/users.php?page=aksrt_tickets&id=41&aksrt_ticket_msg=reply',
|
||||
storage: { 'aksrt-ticket-drafts-41': JSON.stringify({ note: { content: 'keep me' } }) },
|
||||
href: 'https://site.test/wp-admin/users.php?page=jio_tickets&id=41&jio_ticket_msg=reply',
|
||||
storage: { 'jio-ticket-drafts-41': JSON.stringify({ note: { content: 'keep me' } }) },
|
||||
});
|
||||
assert.equal(rt.noteText.value, 'keep me');
|
||||
assert.equal(rt.store.has('aksrt-ticket-drafts-41'), false);
|
||||
assert.equal(new URL(rt.window.location.href).searchParams.has('aksrt_ticket_msg'), false);
|
||||
assert.equal(rt.store.has('jio-ticket-drafts-41'), false);
|
||||
assert.equal(new URL(rt.window.location.href).searchParams.has('jio_ticket_msg'), false);
|
||||
assert.equal(new URL(rt.window.location.href).searchParams.get('id'), '41');
|
||||
assert.equal(unload(rt).defaultPrevented, true, 'a restored draft still counts as unsaved');
|
||||
});
|
||||
|
||||
test('create dialog opens from the header button, guards dirty close, resets and returns focus', () => {
|
||||
const rt = makeRuntime({ page: 'create', href: 'https://site.test/wp-admin/users.php?page=aksrt_tickets' });
|
||||
const rt = makeRuntime({ page: 'create', href: 'https://site.test/wp-admin/users.php?page=jio_tickets' });
|
||||
rt.opener.isConnected = true;
|
||||
rt.root.fire('click', { target: rt.opener });
|
||||
assert.equal(rt.dialog.open, true);
|
||||
@@ -286,7 +286,7 @@ test('create dialog opens from the header button, guards dirty close, resets and
|
||||
});
|
||||
|
||||
test('create posts to the collection route and opens the new ticket workspace with the list context kept', async () => {
|
||||
const rt = makeRuntime({ page: 'create', href: 'https://site.test/wp-admin/users.php?page=aksrt_tickets&status=pending&paged=2' });
|
||||
const rt = makeRuntime({ page: 'create', href: 'https://site.test/wp-admin/users.php?page=jio_tickets&status=pending&paged=2' });
|
||||
rt.root.fire('click', { target: rt.opener });
|
||||
const form = rt.create;
|
||||
form.querySelector('[name="user_id"]').value = '12';
|
||||
@@ -301,7 +301,7 @@ test('create posts to the collection route and opens the new ticket workspace wi
|
||||
const next = new URL(rt.window.location.assigned);
|
||||
assert.equal(next.searchParams.has('view'), false);
|
||||
assert.equal(next.searchParams.get('id'), '77');
|
||||
assert.equal(next.searchParams.get('aksrt_ticket_msg'), 'created');
|
||||
assert.equal(next.searchParams.get('jio_ticket_msg'), 'created');
|
||||
assert.equal(next.searchParams.get('status'), 'pending');
|
||||
assert.equal(next.searchParams.get('paged'), '2');
|
||||
});
|
||||
@@ -318,12 +318,12 @@ test('a confirmed validation error keeps the form editable and shows the server
|
||||
const rt = makeRuntime();
|
||||
type(rt, rt.replyText, 'hello');
|
||||
submit(rt, rt.reply);
|
||||
rt.fetchCalls[0].resolve(reply({ code: 'aksrt_ticket_reply_content', message: 'Bad content', data: { status: 400 } }, 400));
|
||||
rt.fetchCalls[0].resolve(reply({ code: 'jio_ticket_reply_content', message: 'Bad content', data: { status: 400 } }, 400));
|
||||
await tick();
|
||||
assert.equal(rt.window.location.assigned, null);
|
||||
assert.equal(rt.feedback.hidden, false);
|
||||
assert.equal(rt.feedback.querySelector('p').textContent, 'Bad content');
|
||||
assert.equal(rt.feedback.querySelector('[data-aksrt-ticket-reload]').hidden, true);
|
||||
assert.equal(rt.feedback.querySelector('[data-jio-ticket-reload]').hidden, true);
|
||||
assert.equal(rt.replyText.disabled, false);
|
||||
assert.equal(rt.replyText.value, 'hello');
|
||||
submit(rt, rt.reply);
|
||||
@@ -332,8 +332,8 @@ test('a confirmed validation error keeps the form editable and shows the server
|
||||
|
||||
for (const [label, settle] of [
|
||||
['an unknown network result', (call) => call.reject(new TypeError('network'))],
|
||||
['a 409 state conflict', (call) => call.resolve(reply({ code: 'aksrt_ticket_closed', message: 'Closed', data: { status: 409 } }, 409))],
|
||||
['a 404 missing ticket', (call) => call.resolve(reply({ code: 'aksrt_ticket_missing', message: 'Missing', data: { status: 404 } }, 404))],
|
||||
['a 409 state conflict', (call) => call.resolve(reply({ code: 'jio_ticket_closed', message: 'Closed', data: { status: 409 } }, 409))],
|
||||
['a 404 missing ticket', (call) => call.resolve(reply({ code: 'jio_ticket_missing', message: 'Missing', data: { status: 404 } }, 404))],
|
||||
]) {
|
||||
test(`${label} locks every write form and only offers a page reload`, async () => {
|
||||
const rt = makeRuntime();
|
||||
@@ -341,7 +341,7 @@ for (const [label, settle] of [
|
||||
submit(rt, rt.reply);
|
||||
settle(rt.fetchCalls[0]);
|
||||
await tick();
|
||||
const reload = rt.feedback.querySelector('[data-aksrt-ticket-reload]');
|
||||
const reload = rt.feedback.querySelector('[data-jio-ticket-reload]');
|
||||
assert.equal(reload.hidden, false);
|
||||
for (const control of [rt.replyText, rt.noteText, rt.statusSelect, rt.statusSubmit, rt.assign]) assert.equal(control.disabled, true);
|
||||
submit(rt, rt.note);
|
||||
|
||||
@@ -42,7 +42,7 @@ namespace {
|
||||
function get_option($k, $default = false) { return $GLOBALS['wechat_options'][$k] ?? $default; }
|
||||
function update_option($k, $v) { $GLOBALS['wechat_options'][$k] = $v; return true; }
|
||||
|
||||
$GLOBALS['wechat_options'] = ['aksrt_wechat_settings' => [
|
||||
$GLOBALS['wechat_options'] = ['jio_wechat_settings' => [
|
||||
'enabled' => true,
|
||||
'app_id' => 'wxAPPID',
|
||||
'app_secret' => 'SECRET123',
|
||||
@@ -56,7 +56,7 @@ namespace {
|
||||
};
|
||||
}
|
||||
|
||||
namespace AKSRT\Settings {
|
||||
namespace Jio\Settings {
|
||||
// Settings 层仅为薄委托,harness 直接对接真实 Integration。
|
||||
class Settings {
|
||||
public static function get_wechat_settings(): array { return Integration::get_wechat_settings(); }
|
||||
@@ -83,11 +83,11 @@ namespace {
|
||||
}
|
||||
};
|
||||
$stored = static function (): array {
|
||||
$v = get_option('aksrt_wechat_settings', []);
|
||||
$v = get_option('jio_wechat_settings', []);
|
||||
return is_array($v) ? $v : [];
|
||||
};
|
||||
|
||||
$controller = \AKSRT\Admin\UserController::get_instance();
|
||||
$controller = \Jio\Admin\UserController::get_instance();
|
||||
|
||||
// 1) GET /wechat/status 返回完整状态形状(密钥掩码)。
|
||||
$response = $controller->get_wechat_status(new WP_REST_Request());
|
||||
@@ -135,7 +135,7 @@ namespace {
|
||||
$check('未知键被忽略', !array_key_exists('evil', $stored()));
|
||||
|
||||
// 6) 未配置时空密钥可显式清空。
|
||||
update_option('aksrt_wechat_settings', ['enabled' => true, 'app_id' => 'a', 'app_secret' => '', 'template_id' => '']);
|
||||
update_option('jio_wechat_settings', ['enabled' => true, 'app_id' => 'a', 'app_secret' => '', 'template_id' => '']);
|
||||
$controller->update_wechat_settings(new WP_REST_Request(['app_secret' => '']));
|
||||
$check('空密钥可清存', ($stored()['app_secret'] ?? '') === '');
|
||||
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
* 2) 状态读取委托 WeChatNotify::get_status(),写入委托 Settings::update_wechat_settings();
|
||||
* 3) app_secret 掩码 *** 不覆盖已存密钥,输入经 sanitize_text_field 消毒;
|
||||
* 4) PHP harness 驱动真实控制器验证上述行为;
|
||||
* 5) aksrt_settings 上的微信通知死键(wechat_notify_* 等)已彻底移除,
|
||||
* 活配置面仅剩 aksrt_wechat_settings(/users/wechat-template 自定义页)。
|
||||
* 5) jio_settings 上的微信通知死键(wechat_notify_* 等)已彻底移除,
|
||||
* 活配置面仅剩 jio_wechat_settings(/users/wechat-template 自定义页)。
|
||||
*/
|
||||
|
||||
const assert = require('node:assert/strict');
|
||||
@@ -22,7 +22,7 @@ const schemaUsers = fs.readFileSync(path.join(root, 'src/Admin/Schema/SchemaUser
|
||||
const usersSchemaIndex = fs.readFileSync(path.join(root, 'assets/admin/src/schema/sections/users/index.js'), 'utf8');
|
||||
const usersSections = fs.readFileSync(path.join(root, 'assets/admin/src/constants/sections/users.js'), 'utf8');
|
||||
|
||||
// 死双路面:写进 aksrt_settings、全仓无消费方的微信通知键。
|
||||
// 死双路面:写进 jio_settings、全仓无消费方的微信通知键。
|
||||
const DEAD_WECHAT_KEYS = [
|
||||
'wechat_notify_enabled',
|
||||
'wechat_app_id',
|
||||
@@ -66,7 +66,7 @@ test('微信设置行为 harness 通过', () => {
|
||||
assert.match(output, /WeChat settings harness passed/);
|
||||
});
|
||||
|
||||
test('死双路面(aksrt_settings 微信通知键)已彻底移除', () => {
|
||||
test('死双路面(jio_settings 微信通知键)已彻底移除', () => {
|
||||
for (const key of DEAD_WECHAT_KEYS) {
|
||||
assert.ok(!schemaUsers.includes(key), `SchemaUsers 残留: ${key}`);
|
||||
assert.ok(!usersSections.includes(key), `users 菜单常量残留: ${key}`);
|
||||
@@ -76,7 +76,7 @@ test('死双路面(aksrt_settings 微信通知键)已彻底移除', () => {
|
||||
assert.ok(!fs.existsSync(path.join(root, 'assets/admin/src/schema/sections/users/wechat.js')), 'wechat.js 未删除');
|
||||
});
|
||||
|
||||
test('活配置面保持唯一(aksrt_wechat_settings + 自定义页)', () => {
|
||||
test('活配置面保持唯一(jio_wechat_settings + 自定义页)', () => {
|
||||
assert.match(usersSections, /key: 'users-wechat-template'/);
|
||||
assert.match(usersSections, /route: '\/users\/wechat-template'/);
|
||||
assert.match(controller, /WeChatNotify::get_instance\(\)->get_status\(\)/);
|
||||
|
||||
Reference in new issue
Block a user