下载不做记录,支付中心下的“下载记录”页面及相关链路整体删除。 删除的内容: - src/Admin/Native/PayDownloadLogs.php(页面渲染、批量删除、 令牌查询)整文件移除。 - PayMenus 中的 download_logs 子菜单注册(概览页快捷入口由同一 份 pages() 数组生成,随之消失)。 - functions.php 中的 PayDownloadLogs::init() 接线。 - 各入口跳转链接:付费文章列表的操作按钮、用户列表“积分分成” 列的操作链接、用户列表行操作。 - “保存用户下载记录(条) / 保存文章下载记录(条)”两个设置项及其 消费链:SchemaPayment.php、assets/admin 侧 knowledge.js 的字段 与默认值、PaymentRuntime.php 的 user_log / post_log。 - 前台下载中心登录提示里的“管理下载记录”文案(该处本就没有 可跳转的管理页面)。 未改动内容: - aksrt_dl_token 数据表仍由 DBMigrator 创建、uninstall.php 仍会 删除:存量站点可能留有历史令牌行,属数据而非功能,迁移风险 高于收益。 - 独立下载页面开关(down_alone_page)与远程文件转本地等下载 行为配置保留。 - 资源下载量(_aksrt_res_download_count)仍是只读口径:下载走 普通外链,主题内没有写入方,本次不新增下载统计。 download-direct-contract.test.cjs 中原有“下载记录页面展示历史 令牌”用例反向改写为三项断言:页面与接线已删除、记录数设置项 已注销、下载仍不做记录。 验证:node --test "tests/*/*.test.cjs" 517 项全部通过; php -l 全部改动文件无语法错误;重新构建 admin SPA,确认产物 中不含被移除的字段与菜单。
144 lines
6.9 KiB
JavaScript
144 lines
6.9 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');
|
|
const exists = (file) => fs.existsSync(path.join(root, file));
|
|
|
|
test('the token relay is fully retired', () => {
|
|
// The relay class itself is gone.
|
|
assert.equal(exists('src/Content/Download.php'), false);
|
|
|
|
// No init wiring remains (DownloadState is a different class and stays).
|
|
assert.doesNotMatch(read('functions.php'), /Content\\Download'/);
|
|
|
|
// The orphaned cleanup cron is still unscheduled on theme switch.
|
|
assert.match(read('functions.php'), /aksrt_dl_token_cleanup/);
|
|
|
|
// Header query-var branch and SEO noindex branch are gone with the route.
|
|
assert.doesNotMatch(read('inc/helpers/homepage/header-components.php'), /aksrt_dl_token/);
|
|
assert.doesNotMatch(read('src/Core/SEOHead.php'), /render_robots/);
|
|
assert.doesNotMatch(read('src/Core/SEOHead.php'), /aksrt_dl_token/);
|
|
});
|
|
|
|
test('the download box renders direct anchors with inline extract codes', () => {
|
|
const box = read('templates/parts/resource-download-box.php');
|
|
|
|
// No relay button, captcha surface or low-credit data attributes.
|
|
assert.doesNotMatch(box, /data-action="aksrt-download"/);
|
|
assert.doesNotMatch(box, /data-captcha/);
|
|
assert.doesNotMatch(box, /data-aksrt-download-captcha/);
|
|
assert.doesNotMatch(box, /captcha_active/);
|
|
assert.doesNotMatch(box, /data-balance|data-cost/);
|
|
|
|
// Sources without a raw URL are skipped; the button is a direct anchor.
|
|
assert.match(box, /if \(\$url === ''\) \{[\s\S]*?continue;/);
|
|
assert.match(box, /\$btn_href = \$url;/);
|
|
assert.match(box, /\$btn_target = ' target="_blank"'/);
|
|
assert.match(box, /\$btn_rel = ' rel="nofollow noopener"'/);
|
|
|
|
// Extract codes surface inline next to the anchor, no popup involved.
|
|
assert.match(box, /if \(\$has_extract \|\| \$has_copy\) : \?>/);
|
|
assert.match(box, /\$has_copy = \$copy_val !== '';/);
|
|
assert.match(box, /data-clipboard-text="<\?php echo esc_attr\(\$has_copy \? \$copy_val : \$extract_code\); \?>/);
|
|
assert.match(box, /data-clipboard-tag="<\?php echo esc_attr\(\$has_copy \?/);
|
|
|
|
// Custom icon / label / color from the pay meta feed the anchor.
|
|
assert.match(box, /aksrt_icon_markup\(\$icon\)/);
|
|
assert.match(box, /\$btn_text = \$label;/);
|
|
assert.match(box, /resource-download-box__btn--custom/);
|
|
|
|
// The copy button must sit beside the anchor (not stacked full-width below it)
|
|
// and must carry live clipboard attributes the delegated runtime can act on.
|
|
assert.match(box, /<div class="resource-download-box__row">/);
|
|
assert.match(box, /resource-download-box__btn--extract/);
|
|
const css = read('assets/css/frontend/resource-meta/part.css');
|
|
assert.match(css, /\.resource-download-box__row \{[\s\S]*?display:\s*flex;/);
|
|
assert.match(css, /\.resource-download-box__btn--extract \{/);
|
|
// Mobile download bar scopes its own copy-button rule.
|
|
assert.match(css, /\.resource-mobile-download-bar \.resource-download-box__btn--extract \{/);
|
|
|
|
// Hovering the remark shows 点击复制{copy name}, matching the reference theme,
|
|
// and only when a copy name exists.
|
|
assert.match(box, /\$has_copy && \$copy_key !== ''\) : \?>/);
|
|
assert.match(box, /sprintf\(__\('点击复制%s', 'aksrt'\), \$copy_key\)/);
|
|
assert.match(box, /data-toggle="tooltip"/);
|
|
const pay = read('inc/helpers/aksrt-pay.php');
|
|
assert.match(pay, /sprintf\(__\('点击复制%s', 'aksrt'\), \$copy_key\)/);
|
|
// Bootstrap tooltips must be initialized for the attribute to do anything.
|
|
const main = read('assets/js/runtime/main.js');
|
|
assert.match(main, /jQuery\("\[data-toggle='tooltip'\]"\)\.tooltip\(/);
|
|
assert.match(main, /^auto_fun\(\);/m);
|
|
|
|
// The login gate keeps its own anchor.
|
|
assert.match(box, /\$btn_href = \$login_url;/);
|
|
});
|
|
|
|
test('the paid card download actions render direct anchors', () => {
|
|
const pay = read('inc/helpers/aksrt-pay.php');
|
|
|
|
assert.doesNotMatch(pay, /data-action="aksrt-download"/);
|
|
assert.doesNotMatch(pay, /data-captcha/);
|
|
assert.doesNotMatch(pay, /data-aksrt-download-captcha/);
|
|
assert.doesNotMatch(pay, /captcha_active/);
|
|
|
|
// Direct anchor to the raw source URL, empty sources skipped.
|
|
assert.match(pay, /if \(\$url === ''\) \{[\s\S]*?continue;/);
|
|
assert.match(pay, /<a class="mr10 but ' \. esc_attr\(\$button_class\) \. '" href="' \. esc_url\(\$url\) \. '" target="_blank" rel="nofollow noopener">/);
|
|
|
|
// The extract-code badge next to the anchor stays.
|
|
assert.match(pay, /<span class="badg">' \. esc_html\(\$extract_code\)/);
|
|
});
|
|
|
|
test('cms-download.js only serves the cashier now', () => {
|
|
const js = read('assets/js/cms-download.js');
|
|
|
|
// The download request flow is gone.
|
|
assert.doesNotMatch(js, /download\/request/);
|
|
assert.doesNotMatch(js, /data-action="aksrt-download"/);
|
|
assert.doesNotMatch(js, /renderSuccess|startDownload|performDownloadRequest|requestDownload/);
|
|
assert.doesNotMatch(js, /AKSRTCaptcha/);
|
|
|
|
// Cashier, scan-pay and error views remain.
|
|
assert.match(js, /data-aksrt-pay-content/);
|
|
assert.match(js, /window\.aksrtOpenCashier = function/);
|
|
assert.match(js, /function renderCashier/);
|
|
assert.match(js, /function renderScanPay/);
|
|
assert.match(js, /function renderError/);
|
|
|
|
// The script is still enqueued for resource / paid singles.
|
|
assert.match(read('src/Core/ScriptsPart1b.php'), /'aksrt-cms-download'/);
|
|
});
|
|
|
|
test('the admin download-logs page and its wiring are gone', () => {
|
|
// 下载记录菜单页面:类文件、菜单注册、init 接线、各入口链接全部移除。
|
|
assert.equal(exists('src/Admin/Native/PayDownloadLogs.php'), false);
|
|
assert.doesNotMatch(read('src/Admin/Native/PayMenus.php'), /download_logs|aksrt_download_logs|PayDownloadLogs/)
|
|
assert.doesNotMatch(read('functions.php'), /PayDownloadLogs/)
|
|
assert.doesNotMatch(read('src/Admin/Native/PayProducts.php'), /aksrt_download_logs/)
|
|
assert.doesNotMatch(read('src/User/CreditsAdmin.php'), /aksrt_download_logs|下载记录/)
|
|
})
|
|
|
|
test('download log retention settings no longer exist', () => {
|
|
// 「保存用户下载记录/保存文章下载记录」两个设置项及其消费链一并注销。
|
|
assert.doesNotMatch(read('src/Admin/Schema/SchemaPayment.php'), /down_user_log|down_post_log/)
|
|
assert.doesNotMatch(read('assets/admin/src/schema/sections/payment/knowledge.js'), /down_user_log|down_post_log/)
|
|
assert.doesNotMatch(read('src/Settings/PaymentRuntime.php'), /down_user_log|down_post_log|'user_log'|'post_log'/)
|
|
})
|
|
|
|
test('downloads stay unrecorded', () => {
|
|
// 下载不做记录:没有任何 PHP 写入下载计数或下载令牌。
|
|
const php = [
|
|
'inc/helpers/aksrt-pay.php',
|
|
'inc/helpers/aksrt-resource.php',
|
|
'src/Content/PayRest.php',
|
|
'src/Content/Visibility.php',
|
|
].map(read).join('\n')
|
|
assert.doesNotMatch(php, /update_post_meta\([^)]*download_count/)
|
|
assert.doesNotMatch(php, /aksrt_update_post_counter\([^)]*download/)
|
|
});
|