Files
wordpress-theme-aksrt/tests/widget-system/user-assets-layout-contract.test.cjs
T
kate522 3481620ed0 feat(payment): 通用卡密兑换弹窗并修正核销订单实付与订单名称
- /user/balance/ 余额卡片入口改为通用「卡密兑换」弹窗:请求不带类型,
  后端按卡密自动识别余额/会员/积分;卡号输入恒展示且选填
- 后台「余额充值 → 卡密充值」语义更新为「卡密兑换」,开关更名
  「启用卡密兑换功能」(设置键不变),双源 schema 同步并重建 SPA
- 删除死代码:credits-vip.php 死文件、credits-balance.php 内联积分
  兑换块、/pay/card-pass/options 路由与 rest_options、labels 数组、
  asset_points_card_description/password_only 死字段及内联块专属 CSS
- 卡密核销订单实付恒 0:create_redeem_order 源头写 0,UserOrders
  对 card_pass 订单视图层归零覆盖历史行(不迁移数据)
- 订单名称按 note.meta 生成:卡密兑换-余额充值X / 卡密兑换-积分充值X /
  购入[会员档位名]X天(永久)
- 新增契约 card-pass-universal-redeem.test.cjs,收紧 user-assets-layout
  契约(禁 .uc-card-pass 根类回潮)
2026-09-17 19:04:47 +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-aksrt-wallet-value[^>]*title="/)
assert.match(balance, /data-aksrt-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\.aksrt-panel/)
assert.doesNotMatch(source, /\.uc-asset-tabs\.aksrt-panel/)
assert.doesNotMatch(source, /\.uc-asset-card__foot\s+button/)
assert.doesNotMatch(source, /\.uc-card-pass(?:[\s:{])/)
})