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, '..', '..') const read = (file) => fs.readFileSync(path.join(root, file), 'utf8') const runtimeFiles = [ 'assets/js/runtime/main.js', 'assets/js/runtime/main.min.js', ] test('legacy theme action endpoint stays removed from runtime bundles', () => { for (const file of runtimeFiles) { const source = read(file) assert.doesNotMatch(source, /_win\.bd\.on\(['"]click['"],\s*['"]\[data-action\]['"]/, file) assert.doesNotMatch(source, /\baction_ajax\s*\(/, file) assert.doesNotMatch(source, /\/action\/action\.php/, file) assert.doesNotMatch(source, /action=download_file/, `${file} must not restore the legacy download-file handler`) assert.doesNotMatch(source, /download-nonce/, `${file} must not restore the legacy download nonce attribute`) } }) test('WordPress ajax-action runtime remains available after the hard cut', () => { for (const file of runtimeFiles) { const source = read(file) const handlers = source.match(/_win\.bd\.on\(['"]click['"],\s*['"]\[ajax-action\]['"]/g) || [] assert.equal(handlers.length, 1, `${file} must preserve one ajax-action handler`) } }) test('unrelated data-action attributes remain available to runtime components', () => { const source = read('assets/js/runtime/main.js') assert.match(source, /\[data-toggle="RefreshModal"\][\s\S]*?attr\(['"]data-action['"]\)/) })