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>
140 lines
6.5 KiB
JavaScript
140 lines
6.5 KiB
JavaScript
const test = require('node:test')
|
||
const assert = require('node:assert/strict')
|
||
const fs = require('node:fs')
|
||
const path = require('node:path')
|
||
|
||
const root = path.resolve(__dirname, '../..')
|
||
const read = file => fs.readFileSync(path.join(root, file), 'utf8')
|
||
|
||
const list = read('src/Admin/Native/PostListEnhance.php')
|
||
const tags = read('inc/helpers/jio-frontend-tags.php')
|
||
const pay = read('inc/helpers/jio-pay.php')
|
||
|
||
test('admin post list has the interaction stats column', () => {
|
||
assert.match(list, /manage_post_posts_columns/)
|
||
assert.match(list, /互动数据/)
|
||
assert.match(list, /manage_post_posts_custom_column/)
|
||
assert.match(list, /COLUMN_STATS/)
|
||
})
|
||
|
||
test('admin post list has the sales data column with a sortable header', () => {
|
||
// 表头「销售数据」必须是可点击排序链接,排序键为 sales_volume。
|
||
assert.match(list, /销售数据/)
|
||
assert.match(list, /'jio_sales'/)
|
||
assert.match(list, /orderby.*sales_volume/)
|
||
|
||
// 排序靠表头 label 里的链接 + pre_get_posts 落地,不注册 sortable_columns:
|
||
// 注册后 WordPress 会套自己的排序指示器与 <a>,与 label 里的 <a> 嵌套,
|
||
// 箭头会被解析到文字前面。
|
||
assert.doesNotMatch(list, /manage_edit-post_sortable_columns/)
|
||
assert.match(list, /pre_get_posts/)
|
||
assert.match(list, /'sales_volume'/)
|
||
assert.match(list, /RESOURCE_SALES_VOLUME_KEY/)
|
||
})
|
||
|
||
test('sales column renders pay type, price and both sales counts', () => {
|
||
// 未开启付费 → 提示;已开启 → 类型链接 + 价格 + 销量。
|
||
assert.match(list, /未开启付费/)
|
||
assert.match(list, /pay_type_labels\(\)/)
|
||
assert.match(list, /真实销量/)
|
||
assert.match(list, /get_content_sales_map/)
|
||
// 第一行取自 _jio_pay,第二行的销量取自 _jio_sales_volume。
|
||
assert.match(list, /jio_get_pay_meta/)
|
||
assert.match(list, /DomainModel::RESOURCE_SALES_VOLUME_KEY/)
|
||
// 真实销量链接必须跳到订单页(jio_orders)并按商品 ID 过滤。
|
||
assert.match(list, /'jio_orders'/)
|
||
assert.match(list, /'product_id'/)
|
||
})
|
||
|
||
test('interaction counts are read from the keys the theme actually writes', () => {
|
||
// 计数一律落在这几个 meta key 上:jio_post_views / _jio_like_count /
|
||
// _jio_favorite_count。列回调只能用同一套键,否则全列恒为 0。
|
||
// 互动数据不做下载量统计,因此不再读取任何 download 键。
|
||
assert.match(tags, /'_jio_like_count'/)
|
||
assert.match(tags, /'_jio_favorite_count'/)
|
||
assert.match(tags, /'jio_post_views'/)
|
||
|
||
assert.match(list, /jio_get_post_views\(\$post_id\)/)
|
||
assert.match(list, /jio_get_post_likes\(\$post_id\)/)
|
||
assert.match(list, /jio_get_post_favorites\(\$post_id\)/)
|
||
|
||
// 不得再直接读这些不存在的键。
|
||
const column = list.slice(list.indexOf('private function render_stats_column'), list.indexOf('private function render_sales_column'))
|
||
assert.doesNotMatch(column, /get_post_meta\(\$post_id, 'views'/)
|
||
assert.doesNotMatch(column, /get_post_meta\(\$post_id, 'like'/)
|
||
assert.doesNotMatch(column, /get_post_meta\(\$post_id, 'favorite'/)
|
||
|
||
// 下载量统计已移除:不得再读下载键,也不得再渲染下载项。
|
||
assert.doesNotMatch(column, /RESOURCE_DOWNLOAD_COUNT_KEY/)
|
||
assert.doesNotMatch(column, /'download_count'/)
|
||
assert.doesNotMatch(column, /fa-download/)
|
||
assert.doesNotMatch(column, /下载/)
|
||
})
|
||
|
||
test('admin stats column shares the jio_format_number abbreviation', () => {
|
||
// 后台列与前台必须同一套缩写口径(≥10000 → 1.2W+,≥1000 → 1.5K)。
|
||
assert.match(list, /jio_format_number\(\$n\)/)
|
||
const column = list.slice(list.indexOf('private function render_stats_column'), list.indexOf('private function render_sales_column'))
|
||
assert.doesNotMatch(column, /'万'/)
|
||
})
|
||
|
||
test('sortable meta maps the public orderby keys to the stored keys', () => {
|
||
assert.match(list, /'views'\s*=>\s*\\Jio\\Core\\DomainModel::POST_VIEW_COUNT_KEY/)
|
||
assert.match(list, /'like'\s*=>\s*'_jio_like_count'/)
|
||
assert.match(list, /'favorite'\s*=>\s*'_jio_favorite_count'/)
|
||
// meta_key 必须是真实存储键,而不是用户可见的排序键。
|
||
assert.match(list, /\$query->set\('meta_key', \$this->stats_meta_key\(\$orderby\)\)/)
|
||
// 互动数据不统计下载量,排序映射里也不得再出现该维度。
|
||
assert.doesNotMatch(list, /'download_count'/)
|
||
})
|
||
|
||
test('every counter meta key the admin column renders has a writer', () => {
|
||
// 逐键核对:列里展示的每项计数都必须在某个 helper 里真正被写入过。
|
||
// _jio_sales_volume 的写入方是付费订单流水(PayOrders),不在这份清单里,
|
||
// 由下一个用例单独覆盖。
|
||
const sources = [
|
||
'src/Admin/Native/PostListEnhance.php',
|
||
'inc/helpers/jio-frontend-tags.php',
|
||
'src/Core/PostMetaBox.php',
|
||
'src/Frontend/PageAdminSet.php',
|
||
].map(read).join('\n')
|
||
|
||
for (const key of ['jio_post_views', '_jio_like_count', '_jio_favorite_count']) {
|
||
assert.ok(sources.includes(`'${key}'`), `${key} is written somewhere`)
|
||
}
|
||
// 资源帖的浏览有独立键,jio_get_post_views() 取两者较大值。
|
||
assert.match(tags, /_jio_res_view_count/)
|
||
assert.match(read('inc/helpers/jio-resource.php'), /RESOURCE_VIEW_COUNT_KEY|_jio_res_view_count/)
|
||
|
||
// 互动数据不统计下载量:列里不得再出现下载键的读取或回退逻辑。
|
||
assert.doesNotMatch(list, /RESOURCE_DOWNLOAD_COUNT_KEY/)
|
||
assert.doesNotMatch(list, /\$downloads/)
|
||
})
|
||
|
||
test('sales volume is written by the order pipeline', () => {
|
||
// _jio_sales_volume 的写入方在付费助手与订单处理器里,列本身只读。
|
||
assert.match(pay, /jio_bump_content_sales_volume/)
|
||
assert.match(pay, /RESOURCE_SALES_VOLUME_KEY/)
|
||
assert.match(read('src/Content/PayOrders.php'), /jio_bump_content_sales_volume/)
|
||
})
|
||
|
||
test('admin column icons stay behind the Font Awesome enqueue on edit.php', () => {
|
||
assert.match(list, /admin_enqueue_scripts[\s\S]*?edit\.php[\s\S]*?jio_enqueue_fontawesome\(\)/)
|
||
for (const klass of ['fa-eye', 'fa-thumbs-up', 'fa-star']) {
|
||
assert.match(list, new RegExp(klass))
|
||
}
|
||
})
|
||
|
||
test('the old closure-based column implementation is gone from core-hooks', () => {
|
||
// 列与排序逻辑统一收在 src/Admin/Native/PostListEnhance.php,inc/core-hooks.php
|
||
// 不再重复注册,否则同一列会被渲染两次。
|
||
const hooks = read('inc/core-hooks.php')
|
||
assert.doesNotMatch(hooks, /manage_post_posts_columns/)
|
||
assert.doesNotMatch(hooks, /manage_post_posts_custom_column/)
|
||
assert.doesNotMatch(hooks, /jio_stats/)
|
||
})
|
||
|
||
test('PostListEnhance is wired up from functions.php', () => {
|
||
assert.match(read('functions.php'), /PostListEnhance::get_instance\(\)->init\(\)/)
|
||
})
|