Files
wordpress-theme-aksrt/tests/widget-system/user-card-checkin-badge-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

101 lines
4.6 KiB
JavaScript

'use strict'
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')
// Reference theme (zibll css/main.css): .jb-yellow sets --this-bg-b: #f59f54 and
// --this-bg: linear-gradient(135deg, #f59f54 10%, #ff6922 100%). build/public.min.css
// is enqueued after main.min.css, so the legacy .jb-* compat layer in core/buttons.css
// overrides main.css there; the two must agree or every .jb-yellow surface (the
// user-card check-in badge first of all) paints the wrong gradient.
const referenceGradient = /--this-bg:\s*linear-gradient\(135deg,\s*#f59f54 10%,\s*#ff6922 100%\)/
const staleHexes = /#f99d4d|#f7631d/
test('buttons.css legacy .jb-yellow gradient matches the reference theme', () => {
const buttons = read('assets/css/core/buttons.css')
const start = buttons.indexOf('.jb-yellow {')
assert.notEqual(start, -1, 'missing the legacy .jb-yellow rule')
const block = buttons.slice(start, buttons.indexOf('}', start))
assert.match(block, referenceGradient)
assert.doesNotMatch(block, staleHexes)
})
test('the built public bundle carries the reference .jb-yellow gradient', () => {
const bundle = read('assets/css/build/public.min.css')
assert.match(
bundle,
/\.jb-yellow\{--this-bg: linear-gradient\(135deg, #f59f54 10%, #ff6922 100%\)\}/
)
assert.doesNotMatch(
bundle,
/\.jb-yellow\{--this-bg: linear-gradient\(135deg, #f99d4d 10%, #f7631d 100%\)\}/
)
})
test('main.css still owns the reference .jb-yellow gradient', () => {
const main = read('assets/css/main.css')
assert.match(main, referenceGradient)
assert.doesNotMatch(main, staleHexes)
})
test('the badge typography is pinned to the reference bootstrap body values', () => {
const main = read('assets/css/main.css')
const start = main.indexOf('.user-card .card-content .img-badge')
assert.notEqual(start, -1, 'missing the user-card img-badge adaptation rule')
const block = main.slice(start, main.indexOf('}', start))
assert.match(block, /line-height:\s*1\.42857143/)
// Reference body font stack (zibll bootstrap.min.css; zibll main.css does not
// override it), while Jio's reset imposes the modern --font-body stack.
assert.match(block, /font-family:\s*"Helvetica Neue", Helvetica, Arial, sans-serif/)
// The Jio html reset forces antialiased + optimizeLegibility; the badge
// restores the browser defaults the reference renders with.
assert.match(block, /-webkit-font-smoothing:\s*auto/)
assert.match(block, /text-rendering:\s*auto/)
const min = read('assets/css/main.min.css')
assert.match(
min,
/\.user-card \.card-content \.img-badge\{line-height:1\.42857143;font-family:Helvetica Neue,Helvetica,Arial,sans-serif;-webkit-font-smoothing:auto;text-rendering:auto\}/
)
})
test('the sidebar widget link color does not recolor the check-in badge', () => {
// .widget a (sidebar.css, shipped in the homepage bundle) out-specifies the
// .jb-* color group, so the badge would paint --color-ink-2 instead of the
// white --this-color; the established .but restoration must cover img-badge.
const sidebar = read('assets/css/frontend/sidebar.css')
const start = sidebar.indexOf('.widget a.but')
assert.notEqual(start, -1, 'missing the .widget a color restoration')
const block = sidebar.slice(start, sidebar.indexOf('}', start))
assert.match(block, /\.widget a\.but,/)
assert.match(block, /\.widget a\.img-badge/)
assert.match(block, /color:\s*var\(--this-color/)
const bundle = read('assets/css/build/homepage.min.css')
assert.match(bundle, /\.widget a\.but,\.widget a\.img-badge\{color:var\(--this-color, #fff\)\}/)
})
test('the user-card check-in badge renders without the dead is-done class and bare span', () => {
const userbox = read('inc/helpers/jio-header-userbox.php')
const fnStart = userbox.indexOf('function jio_header_user_checkin_btn')
assert.notEqual(fnStart, -1, 'missing jio_header_user_checkin_btn')
const fnEnd = userbox.indexOf('if (!function_exists', fnStart)
assert.notEqual(fnEnd, -1)
const fn = userbox.slice(fnStart, fnEnd)
// Signed card badge: the badge class passes through untouched and the done
// label is bare text after the icon, matching the reference markup.
assert.match(fn, /jio_get_user_checkin_details_link\(\s*\$class,/)
assert.doesNotMatch(fn, /\$class \. ' is-done'/)
assert.doesNotMatch(fn, /'<span>'/)
// The idle badge keeps the data-signin-label hook the sign-in controller
// uses to swap labels in place.
assert.match(fn, /<span data-signin-label>/)
})