Files
chrnx-dev-wp/tests/smoke/project-config.test.mjs
chrnxandClaude Opus 5 a4c68e3c56 chore: run the local environment on WordPress 7.0.4
Production upgraded to 7.0.4, so the development and test containers now
match it instead of trailing on 6.9.6. The full suite passes unchanged
against the new core, and the pinned assertion moves with it.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-14 19:05:48 -05:00

57 lines
2.4 KiB
JavaScript

import assert from 'node:assert/strict';
import { readFile } from 'node:fs/promises';
import test from 'node:test';
test('tooling is pinned and wp-env maps this repo as chrnx', async () => {
const pkg = JSON.parse(await readFile('package.json', 'utf8'));
const env = JSON.parse(await readFile('.wp-env.json', 'utf8'));
assert.equal(pkg.engines.node, '>=22 <27');
assert.equal(pkg.packageManager, 'npm@11.17.0');
assert.equal(pkg.devDependencies['@wordpress/env'], '11.12.0');
assert.equal(pkg.devDependencies['@wordpress/scripts'], '34.0.0');
assert.equal(pkg.devDependencies['@playwright/test'], '1.62.1');
assert.equal(pkg.devDependencies.lighthouse, '13.4.1');
assert.equal(env.core, 'https://wordpress.org/wordpress-7.0.4.zip');
assert.equal(env.phpVersion, '8.3');
assert.equal(env.autoPort, false);
assert.equal(env.port, 8888);
assert.equal(env.config.WP_DEBUG, true);
assert.equal(env.config.SCRIPT_DEBUG, true);
assert.equal(env.mappings['wp-content/themes/chrnx'], '.');
});
test('scripts activate chrnx and run Composer from the mapped theme', async () => {
const pkg = JSON.parse(await readFile('package.json', 'utf8'));
assert.equal(pkg.scripts['env:activate'], 'wp-env run cli wp theme activate chrnx');
assert.equal(
pkg.scripts.composer,
'wp-env run cli --env-cwd=wp-content/themes/chrnx composer',
);
});
test('Jest discovers JavaScript tests only from the active checkout', async () => {
const pkg = JSON.parse(await readFile('package.json', 'utf8'));
assert.match(
pkg.scripts['test:js'],
/--modulePathIgnorePatterns='<rootDir>\/\.worktrees\/'/,
);
assert.equal(pkg.jest, undefined);
});
test('PHP quality tools enforce the CHRNX conventions and cannot pass an empty suite', async () => {
const phpcs = await readFile('phpcs.xml.dist', 'utf8');
const phpunit = await readFile('phpunit.xml.dist', 'utf8');
assert.match(phpcs, /<rule ref="WordPress-Core"\/>/);
assert.match(phpcs, /<rule ref="WordPress-Extra"\/>/);
assert.match(phpcs, /name="text_domain"[^>]+value="chrnx"/);
assert.match(phpcs, /name="prefixes"[^>]+value="chrnx_"/);
assert.match(phpcs, /<exclude-pattern>\*\/\.worktrees\/\*<\/exclude-pattern>/);
assert.match(phpunit, /bootstrap="tests\/php\/bootstrap\.php"/);
assert.match(phpunit, /failOnEmptyTestSuite="true"/);
assert.match(phpunit, /<directory suffix="Test\.php">tests\/php<\/directory>/);
});