Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
59 lines
3.1 KiB
JavaScript
59 lines
3.1 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('category archives use the canonical stream and enforce category view rules', () => {
|
|
const archive = read('category.php')
|
|
const permissions = read('inc/helpers/jio-single-components.php')
|
|
const header = read('inc/helpers/jio-archive-filters.php')
|
|
|
|
assert.doesNotMatch(archive, /_jio_doc_category|page-documentnav|DocsPresenter/)
|
|
assert.match(archive, /TermMeta::resolve_archive_settings\(\$term\)/)
|
|
assert.match(archive, /jio_get_term_allow_view_data\(\(int\) \$term->term_id\)/)
|
|
assert.match(archive, /if \(!empty\(\$access\['allow'\]\)\) \{[\s\S]*?jio_archive_render_stream/)
|
|
assert.match(archive, /content-stream--category posts-row ajaxpager/)
|
|
assert.match(archive, /jio_archive_render_term_header\(/)
|
|
assert.match(archive, /cat_top_content/)
|
|
assert.match(archive, /cat_bottom_content/)
|
|
|
|
assert.match(permissions, /function jio_get_term_allow_view_data\(int \$term_id\)/)
|
|
assert.match(permissions, /jio_resolve_allow_view_rule\([\s\S]*?\$redirect_url/)
|
|
assert.match(permissions, /function jio_resolve_allow_view_rule\(string \$type, array \$roles, \?WP_Post \$post = null, string \$redirect_url = ''\)/)
|
|
assert.match(header, /current_user_can\('edit_term', \(int\) \$term->term_id\)/)
|
|
assert.match(header, /class="main-search-btn" search-type="post" search-trem=/)
|
|
})
|
|
|
|
test('category directory lists all terms recursively with archive links and page widget zones', () => {
|
|
const template = read('templates/pages/page-categories.php')
|
|
const css = read('assets/css/routes/categories.css')
|
|
const scripts = read('src/Core/ScriptsPart1b.php')
|
|
|
|
assert.match(template, /'taxonomy'\s*=>\s*'category'[\s\S]*?'hide_empty'\s*=>\s*false/)
|
|
assert.match(template, /'orderby'\s*=>\s*'term_group'/)
|
|
assert.match(template, /\$children_by_parent\[\$parent_id\]\[\]/)
|
|
assert.match(template, /\$render_children\(\$child_id, array_merge\(\$path, \[\$child_id\]\)\)/)
|
|
assert.match(template, /in_array\(\$child_id, \$path, true\)/)
|
|
assert.match(template, /get_category_link\(\$child_id\)/)
|
|
assert.match(template, /jio_widget_term_cover_url\(\$term_id, true\)/)
|
|
assert.match(template, /jio_get_lazy_attr\('lazy_other'/)
|
|
assert.doesNotMatch(template, /loading=["'](?:lazy|eager)["']/)
|
|
assert.match(template, /get_category_recommend_desc\(\$term_id\)/)
|
|
assert.match(template, /page_top_content_/)
|
|
assert.match(template, /page_bottom_content_/)
|
|
assert.match(template, /page_top_fluid_/)
|
|
assert.match(template, /page_bottom_fluid_/)
|
|
assert.match(template, /cat_top_fluid/)
|
|
assert.match(template, /cat_bottom_fluid/)
|
|
assert.match(scripts, /is_page_template\('templates\/pages\/page-categories\.php'\)/)
|
|
|
|
assert.match(css, /\.jio-category-directory-nav/)
|
|
assert.match(css, /\.jio-category-directory__section/)
|
|
assert.match(css, /\.jio-category-directory__children/)
|
|
assert.match(css, /@media \(max-width: 767px\)/)
|
|
assert.doesNotMatch(template + css, /jio-cats-grid|jio-cat-card/)
|
|
})
|