26 lines
1.2 KiB
JavaScript
26 lines
1.2 KiB
JavaScript
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');
|
|
|
|
test('front submit enqueues the WordPress editor before wp_head is rendered', () => {
|
|
const source = read('templates/pages/page-submit.php');
|
|
const enqueueAt = source.indexOf('wp_enqueue_editor();');
|
|
const headerAt = source.indexOf('\nget_header();');
|
|
|
|
assert.notEqual(enqueueAt, -1, 'front submit must explicitly enqueue the editor runtime');
|
|
assert.notEqual(headerAt, -1, 'front submit must render the theme header');
|
|
assert.ok(enqueueAt < headerAt, 'editor assets must be queued before get_header()/wp_head');
|
|
});
|
|
|
|
test('published post content reaches the front submit editor unchanged', () => {
|
|
const context = read('templates/parts/submit/context.php');
|
|
const editor = read('templates/parts/submit/editor-main.php');
|
|
|
|
assert.match(context, /\$current_content\s*=\s*\$edit_post\s*\?\s*\$edit_post->post_content\s*:\s*'';/);
|
|
assert.match(editor, /wp_editor\(\(string\) \$ctx\['current_content'\], 'post_content', \$editor_settings\);/);
|
|
});
|