'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, /