Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
64 lines
2.6 KiB
JavaScript
64 lines
2.6 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, '..', '..')
|
|
const read = (file) => fs.readFileSync(path.join(root, file), 'utf8')
|
|
|
|
test('native links are the only friend-link store', () => {
|
|
const setup = read('src/Core/Setup.php')
|
|
const submissions = read('src/Core/LinksSubmission.php')
|
|
const template = read('templates/pages/page-friends.php')
|
|
const helper = read('inc/helpers/jio-links.php')
|
|
|
|
assert.match(setup, /pre_option_link_manager_enabled/)
|
|
assert.match(submissions, /ACTION = 'jio_frontend_links_submit'/)
|
|
assert.match(submissions, /add_action\('wp_ajax_' \. self::ACTION/)
|
|
assert.match(submissions, /add_action\('wp_ajax_nopriv_' \. self::ACTION/)
|
|
assert.match(submissions, /wp_insert_link\(/)
|
|
assert.match(submissions, /jio_require_captcha\('friend_link'/)
|
|
assert.match(submissions, /jio_captcha_rate_limited\('friend-link-submit'/)
|
|
assert.match(template, /jio_page_links_html\(/)
|
|
assert.match(template, /jio_submit_links_modal\(/)
|
|
assert.match(helper, /get_bookmarks\(/)
|
|
assert.match(helper, /assets\/icons\/upload-add\.svg/)
|
|
})
|
|
|
|
test('the retired friend-link option and admin REST surface stay gone', () => {
|
|
for (const file of [
|
|
'src/Settings/DisplayRuntime.php',
|
|
'assets/css/routes/friends.css',
|
|
]) {
|
|
assert.equal(fs.existsSync(path.join(root, file)), false, file)
|
|
}
|
|
for (const file of [
|
|
'src/Admin/GlobalController.php',
|
|
'src/Settings/Settings.php',
|
|
'src/Settings/DisplayPageGroups.php',
|
|
'inc/helpers/template-tags/media-brand.php',
|
|
'assets/admin/src/api/modules/global.js',
|
|
]) {
|
|
const source = read(file)
|
|
assert.doesNotMatch(source, /jio_friend_links|friend-links|get_friend_links|save_friend_links/, file)
|
|
}
|
|
})
|
|
|
|
test('page options and submission wiring point at the links template', () => {
|
|
const metaBox = read('src/Admin/PageLinksMetaBox.php')
|
|
const scripts = read('src/Core/ScriptsPart1b.php')
|
|
const captcha = read('inc/modules/captcha.php')
|
|
const notifications = read('src/Settings/MailNotifications.php')
|
|
const templates = read('src/Settings/MailTemplates.php')
|
|
|
|
assert.match(metaBox, /templates\/pages\/page-friends\.php/)
|
|
assert.match(metaBox, /wp_verify_nonce/)
|
|
assert.match(metaBox, /current_user_can\('edit_page'/)
|
|
assert.match(metaBox, /page_links_submit_s/)
|
|
assert.match(scripts, /links-submit\.js/)
|
|
assert.match(captcha, /'friend_link'\s*=>/)
|
|
assert.match(notifications, /links_submit_admin/)
|
|
assert.match(notifications, /Message::get_instance\(\)->send/)
|
|
assert.match(templates, /review_url/)
|
|
})
|