Files
wordpress-theme-aksrt/tests/widget-system/user-assets-layout-contract.test.cjs
T
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

80 lines
4.3 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, '..', '..')
function read(relative) {
return fs.readFileSync(path.join(root, relative), 'utf8')
}
test('dual asset cards use an independent equal-height grid row', () => {
const css = read('assets/css/routes/user-center/credits.css')
const profile = read('inc/helpers/user-center-renderers/profile-credits.php')
assert.match(css, /\.uc-assets-row--dual\s*\{[\s\S]*?grid-template-columns:\s*repeat\(2,\s*minmax\(0,\s*1fr\)\);[\s\S]*?grid-template-rows:\s*auto;/)
assert.match(css, /\.uc-assets-row\s*\{[\s\S]*?margin-bottom:\s*10px;/)
assert.match(css, /\.uc-assets-row--dual\s*\{[\s\S]*?gap:\s*10px;/)
assert.match(css, /\.uc-assets-row--dual\s*>\s*\.uc-assets-col\s*\{[\s\S]*?display:\s*contents;/)
assert.match(css, /\.uc-assets-row--dual\s*>\s*\.uc-assets-col:first-child\s*>\s*\.uc-asset-card[\s\S]*?grid-column:\s*1;/)
assert.match(css, /\.uc-assets-row--dual\s*>\s*\.uc-assets-col:last-child\s*>\s*\.uc-asset-card[\s\S]*?grid-column:\s*2;/)
assert.match(css, /\.uc-assets-row--dual\s*>\s*\.uc-assets-col\s*>\s*\.uc-asset-card\s*\{[\s\S]*?grid-row:\s*1;/)
// 内联 uc-card-pass 块已删除:双卡网格不再为它预留第二行(弹窗子元素样式除外)。
assert.doesNotMatch(css, /\.uc-card-pass(?:[\s:{])/)
assert.match(css, /\.uc-asset-card\s*\{[\s\S]*?display:\s*flex;[\s\S]*?flex-direction:\s*column;/)
assert.match(css, /\.uc-asset-card__link\s*\{[\s\S]*?margin-top:\s*auto;/)
assert.match(css, /\.uc-asset-card__foot\s*\{[\s\S]*?margin-top:\s*auto;/)
assert.match(profile, /<div class="uc-assets-col">[\s\S]*?credits-wallet\.php[\s\S]*?<\/div>/)
assert.match(profile, /<div class="uc-assets-col">[\s\S]*?credits-balance\.php[\s\S]*?<\/div>/)
})
test('dual asset layout returns to a single-column flex flow on mobile', () => {
const css = read('assets/css/routes/user-center/credits.css')
const mobile = css.match(/@media \(max-width: 767px\) \{([\s\S]*?)\n\}/)
assert.ok(mobile, 'credits CSS must define a mobile breakpoint')
assert.match(mobile[1], /grid-template-columns:\s*1fr;/)
assert.match(mobile[1], /grid-template-rows:\s*none;/)
assert.match(mobile[1], /\.uc-assets-row--dual\s*>\s*\.uc-assets-col\s*\{[\s\S]*?display:\s*flex;/)
assert.match(mobile[1], /grid-column:\s*auto;/)
assert.match(mobile[1], /grid-row:\s*auto;/)
assert.match(mobile[1], /\.uc-asset-card__body\s*\{[\s\S]*?flex-direction:\s*column;/)
})
test('asset card amounts stay on one line and actions wrap below as a whole', () => {
const css = read('assets/css/routes/user-center/credits.css')
assert.match(css, /\.uc-assets-row\s*\{[\s\S]*?grid-template-columns:\s*minmax\(0,\s*1fr\);/)
assert.match(css, /\.uc-asset-card\s*\{[\s\S]*?min-width:\s*0;/)
assert.match(css, /\.uc-asset-card__body\s*\{[\s\S]*?flex-wrap:\s*wrap;/)
assert.match(css, /\.uc-asset-card__amount\s*\{[\s\S]*?white-space:\s*nowrap;[\s\S]*?font-variant-numeric:\s*tabular-nums;[\s\S]*?text-overflow:\s*ellipsis;/)
})
test('asset card amounts expose the full value via title tooltips', () => {
const wallet = read('inc/helpers/user-center-renderers/credits-wallet.php')
const balance = read('inc/helpers/user-center-renderers/credits-balance.php')
const amount = read('src/Ledger/AssetAmount.php')
assert.match(wallet, /data-jio-wallet-value[^>]*title="/)
assert.match(balance, /data-jio-points-value[^>]*data-credits-value[^>]*title="/)
assert.match(amount, /number_format_i18n\(intdiv\(\$this->minor, 100\)\)/)
assert.doesNotMatch(wallet, /\$mark === '元' \? '¥'/)
})
test('removed asset card selectors do not return in loaded user-center styles', () => {
const cssFiles = [
'assets/css/routes/user-center/credits.css',
'assets/css/routes/user-center/responsive.css',
'assets/css/frontend/credits.css',
]
const source = cssFiles.map(read).join('\n')
assert.doesNotMatch(source, /\.uc-balance-card(?:[\s:{]|__)/)
assert.doesNotMatch(source, /\.credits-card(?:[\s:{]|__)/)
assert.doesNotMatch(source, /\.uc-assets-row\.uc-asset-card\.jio-panel/)
assert.doesNotMatch(source, /\.uc-asset-tabs\.jio-panel/)
assert.doesNotMatch(source, /\.uc-asset-card__foot\s+button/)
assert.doesNotMatch(source, /\.uc-card-pass(?:[\s:{])/)
})