fix: correct entry layout, light mode and editor parity
The single/page/404 templates set contentSize to 70ch, which resolves against each child's own font size: the display-size h1 asked for ~2660px and broke full bleed while the body stayed narrow. They now inherit the 720px from theme.json. Also drops the About facets that duplicated the portrait, adds the missing prefers-color-scheme branch for the character stage copy surface (dark text on a dark panel in System light), loads components.css in the editor, and replaces the unstyled index fallback with the journal stream. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
13 files changed
+221
-92
No files matched your search
@@ -1,5 +1,5 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import { access, readFile } from 'node:fs/promises';
|
||||
import { access, readFile, readdir } from 'node:fs/promises';
|
||||
import test from 'node:test';
|
||||
|
||||
const readProjectFile = (path) => readFile(new URL(`../../${path}`, import.meta.url), 'utf8');
|
||||
@@ -43,6 +43,56 @@ test('the stylesheet and PHP asset versions remain synchronized', async () => {
|
||||
assert.equal(phpVersion, stylesheetVersion);
|
||||
});
|
||||
|
||||
test('every block.json version matches CHRNX_VERSION so cached block assets bust', async () => {
|
||||
// Block viewScript/style URLs are versioned from block.json, not
|
||||
// CHRNX_VERSION. Letting them drift served stale JS from browser cache.
|
||||
const functions = await readProjectFile('functions.php');
|
||||
const phpVersion = functions.match(/define\( 'CHRNX_VERSION', '([^']+)' \);/)?.[1];
|
||||
assert.ok(phpVersion, 'functions.php must define the literal CHRNX_VERSION constant');
|
||||
|
||||
const blocksDir = new URL('../../blocks/', import.meta.url);
|
||||
const names = (await readdir(blocksDir, { withFileTypes: true }))
|
||||
.filter((entry) => entry.isDirectory())
|
||||
.map((entry) => entry.name)
|
||||
.sort();
|
||||
assert.ok(names.length > 0, 'blocks/ must contain block directories');
|
||||
|
||||
for (const name of names) {
|
||||
const block = JSON.parse(await readProjectFile(`blocks/${name}/block.json`));
|
||||
assert.equal(block.version, phpVersion, `blocks/${name}/block.json version`);
|
||||
}
|
||||
});
|
||||
|
||||
test('no shipped runtime file points at an unshipped design master', async () => {
|
||||
// The package excludes assets/images/*.png|jpeg because every image is served
|
||||
// from assets/images/generated. A direct reference would 404 once installed.
|
||||
const roots = ['inc', 'blocks', 'patterns', 'parts', 'templates', 'assets/css'];
|
||||
const offenders = [];
|
||||
const walk = async (dir) => {
|
||||
for (const entry of await readdir(new URL(`../../${dir}/`, import.meta.url), { withFileTypes: true })) {
|
||||
const path = `${dir}/${entry.name}`;
|
||||
if (entry.isDirectory()) {
|
||||
await walk(path);
|
||||
continue;
|
||||
}
|
||||
if (!/\.(php|css|html|json)$/.test(entry.name)) {
|
||||
continue;
|
||||
}
|
||||
const source = await readProjectFile(path);
|
||||
// Anything under generated/ is shipped; a bare master path is not.
|
||||
const matches = source.match(/assets\/images\/(?!generated\/)[A-Za-z0-9._-]+\.(?:png|jpe?g)/g);
|
||||
if (matches) {
|
||||
offenders.push(`${path}: ${[...new Set(matches)].join(', ')}`);
|
||||
}
|
||||
}
|
||||
};
|
||||
for (const root of roots) {
|
||||
await walk(root);
|
||||
}
|
||||
|
||||
assert.deepEqual(offenders, [], `runtime files reference unshipped masters:\n${offenders.join('\n')}`);
|
||||
});
|
||||
|
||||
test('theme.json declares the v3 schema and layout widths', async () => {
|
||||
const theme = JSON.parse(await readProjectFile('theme.json'));
|
||||
|
||||
@@ -89,8 +139,9 @@ test('the index template has header, semantic query content, and footer regions'
|
||||
|
||||
assert.match(template, /<!-- wp:template-part \{"slug":"header","tagName":"header"\} \/-->/);
|
||||
assert.match(template, /<!-- wp:group \{"tagName":"main"[^>]*-->/);
|
||||
assert.match(template, /<!-- wp:query\b/);
|
||||
assert.match(template, /<!-- wp:post-template -->/);
|
||||
assert.match(template, /<!-- wp:post-(?:content|excerpt)\b/);
|
||||
// index is the last-resort fallback; it lists posts through the same
|
||||
// stream every other archive uses, not an unstyled core query loop.
|
||||
assert.match(template, /<!-- wp:query-title\b/);
|
||||
assert.match(template, /<!-- wp:chrnx\/journal-stream \/-->/);
|
||||
assert.match(template, /<!-- wp:template-part \{"slug":"footer","tagName":"footer"\} \/-->/);
|
||||
});
|
||||
Reference in new issue
Block a user