fix: finalize CHRNX fixture and landmark contracts
This commit is contained in:
6 files changed
+77
-65
No files matched your search
@@ -98,10 +98,35 @@ function chrnx_seed_upsert_post( array $fixture, string $post_type, int $offset
|
||||
}
|
||||
|
||||
chrnx_seed_editorial_terms();
|
||||
$chrnx_seed_pages = chrnx_seed_read_fixture( 'pages.json' );
|
||||
$chrnx_seed_posts = chrnx_seed_read_fixture( 'posts.json' );
|
||||
$chrnx_seed_page_ids = array();
|
||||
$chrnx_seed_post_ids = array();
|
||||
$chrnx_seed_pages = chrnx_seed_read_fixture( 'pages.json' );
|
||||
$chrnx_seed_posts = chrnx_seed_read_fixture( 'posts.json' );
|
||||
$chrnx_seed_page_ids = array();
|
||||
$chrnx_seed_post_ids = array();
|
||||
$chrnx_seed_keys = array_map(
|
||||
'sanitize_key',
|
||||
array_merge(
|
||||
array_column( $chrnx_seed_pages, 'fixtureKey' ),
|
||||
array_column( $chrnx_seed_posts, 'fixtureKey' )
|
||||
)
|
||||
);
|
||||
$chrnx_seed_removed = 0;
|
||||
$chrnx_seed_owned_ids = get_posts(
|
||||
array(
|
||||
'post_type' => array( 'page', 'post' ),
|
||||
'post_status' => 'any',
|
||||
'posts_per_page' => -1,
|
||||
'fields' => 'ids',
|
||||
'no_found_rows' => true,
|
||||
'meta_key' => '_chrnx_fixture_key',
|
||||
)
|
||||
);
|
||||
foreach ( $chrnx_seed_owned_ids as $chrnx_seed_owned_id ) {
|
||||
$chrnx_seed_owned_key = sanitize_key( get_post_meta( $chrnx_seed_owned_id, '_chrnx_fixture_key', true ) );
|
||||
if ( preg_match( '/^(?:page|post)-[a-z0-9-]+$/', $chrnx_seed_owned_key ) && ! in_array( $chrnx_seed_owned_key, $chrnx_seed_keys, true ) ) {
|
||||
wp_delete_post( $chrnx_seed_owned_id, true );
|
||||
++$chrnx_seed_removed;
|
||||
}
|
||||
}
|
||||
|
||||
foreach ( $chrnx_seed_pages as $chrnx_seed_index => $chrnx_seed_page ) {
|
||||
$chrnx_seed_page_id = chrnx_seed_upsert_post( $chrnx_seed_page, 'page', $chrnx_seed_index );
|
||||
@@ -165,9 +190,10 @@ flush_rewrite_rules( false );
|
||||
|
||||
WP_CLI::log(
|
||||
sprintf(
|
||||
'CHRNX_FIXTURES pages=%d posts=%d front=%d scenario=%s',
|
||||
'CHRNX_FIXTURES pages=%d posts=%d removed=%d front=%d scenario=%s',
|
||||
count( $chrnx_seed_page_ids ),
|
||||
count( $chrnx_seed_post_ids ),
|
||||
$chrnx_seed_removed,
|
||||
$chrnx_seed_page_ids['home'],
|
||||
$chrnx_seed_scenario
|
||||
)
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
<!-- wp:heading {"level":1} --><h1 class="wp-block-heading">Page not found</h1><!-- /wp:heading -->
|
||||
<!-- wp:paragraph --><p>This address does not lead to a published page. Search the site or return to a known starting point.</p><!-- /wp:paragraph -->
|
||||
<!-- wp:search {"label":"Search","showLabel":true,"buttonText":"Search"} /-->
|
||||
<!-- wp:navigation {"overlayMenu":"never","className":"chrnx-not-found__recovery"} -->
|
||||
<!-- wp:navigation {"overlayMenu":"never","ariaLabel":"Page not found recovery navigation","className":"chrnx-not-found__recovery"} -->
|
||||
<!-- wp:home-link {"label":"Home"} /-->
|
||||
<!-- /wp:navigation -->
|
||||
<!-- wp:chrnx/journal-link /-->
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<!-- wp:query-title {"type":"search","level":1} /-->
|
||||
<!-- wp:search {"label":"Search","showLabel":true,"buttonText":"Search"} /-->
|
||||
<!-- wp:chrnx/journal-stream /-->
|
||||
<!-- wp:navigation {"overlayMenu":"never","className":"chrnx-search-results__recovery"} -->
|
||||
<!-- wp:navigation {"overlayMenu":"never","ariaLabel":"Search recovery navigation","className":"chrnx-search-results__recovery"} -->
|
||||
<!-- wp:home-link {"label":"Home"} /-->
|
||||
<!-- /wp:navigation -->
|
||||
</main>
|
||||
|
||||
@@ -96,9 +96,16 @@ test( 'long, incomplete, empty, and missing states stay usable', async ( { page
|
||||
} ),
|
||||
).toBeVisible();
|
||||
await expect( page.locator( '.chrnx-podcast-meta' ) ).toHaveCount( 0 );
|
||||
await expect( page.locator( '.taxonomy-chrnx_topic, .taxonomy-chrnx_language' ) ).toHaveCount(
|
||||
0,
|
||||
);
|
||||
await expect( page.getByText( 'Estado de prueba para un episodio sin show' ) ).toHaveCount( 0 );
|
||||
|
||||
await page.goto( '/emotion-is-not-a-slider-designing-expressive-systems-that-can-hesitate/' );
|
||||
await expect( page.locator( 'pre code' ) ).toContainText( 'const state' );
|
||||
await expect( page.locator( 'pre code' ) ).toContainText(
|
||||
'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789',
|
||||
);
|
||||
await expectNoHorizontalOverflow( page );
|
||||
|
||||
for ( const [ path, title ] of [
|
||||
@@ -110,9 +117,6 @@ test( 'long, incomplete, empty, and missing states stay usable', async ( { page
|
||||
'/una-cuerda-rota-tambien-puede-decidir-el-arreglo/',
|
||||
'Una cuerda rota también puede decidir el arreglo',
|
||||
],
|
||||
[ '/nota-local-sin-extracto/', 'Nota local sin extracto' ],
|
||||
[ '/note-without-topic/', 'Note without a topic' ],
|
||||
[ '/nota-sin-idioma-asignado/', 'Nota sin idioma asignado' ],
|
||||
] ) {
|
||||
await page.goto( path );
|
||||
await expect( page.getByRole( 'heading', { level: 1 } ) ).toContainText( title );
|
||||
@@ -120,12 +124,6 @@ test( 'long, incomplete, empty, and missing states stay usable', async ( { page
|
||||
}
|
||||
await expect( page.locator( '.chrnx-entry__meta a', { hasText: 'English' } ) ).toHaveCount( 0 );
|
||||
|
||||
await page.goto( '/unbroken-token-overflow-test/' );
|
||||
await expect( page.locator( 'pre code' ) ).toContainText(
|
||||
'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789',
|
||||
);
|
||||
await expectNoHorizontalOverflow( page );
|
||||
|
||||
await page.goto( '/journal/?chrnx_topic=..%2F..%2Fcode&chrnx_language%5B%5D=en&s%5B%5D=x' );
|
||||
await expect( page.locator( 'select[name="chrnx_topic"]' ) ).toHaveValue( '' );
|
||||
await expect( page.locator( 'select[name="chrnx_language"]' ) ).toHaveValue( '' );
|
||||
@@ -232,6 +230,23 @@ test( 'site routes preserve heading order, named landmarks, and skip-link keyboa
|
||||
}
|
||||
} );
|
||||
|
||||
test( 'search and not-found recovery navigation landmarks have unique names', async ( {
|
||||
page,
|
||||
} ) => {
|
||||
for ( const [ path, expected ] of [
|
||||
[ '/?s=fixture-that-cannot-exist', 'Search recovery navigation' ],
|
||||
[ '/this-route-does-not-exist/', 'Page not found recovery navigation' ],
|
||||
] ) {
|
||||
await page.goto( path );
|
||||
await expect( page.getByRole( 'navigation', { name: expected } ) ).toHaveCount( 1 );
|
||||
const names = await page
|
||||
.locator( 'nav' )
|
||||
.evaluateAll( ( nodes ) => nodes.map( ( node ) => node.getAttribute( 'aria-label' ) ) );
|
||||
expect( names.every( Boolean ) ).toBeTruthy();
|
||||
expect( new Set( names ).size ).toBe( names.length );
|
||||
}
|
||||
} );
|
||||
|
||||
test( 'reduced motion removes card transitions while theme preference remains user-controlled', async ( {
|
||||
page,
|
||||
} ) => {
|
||||
|
||||
Vendored
+4
-43
@@ -3,10 +3,11 @@
|
||||
"fixtureKey": "post-code-primary",
|
||||
"title": "Emotion is not a slider: designing expressive systems that can hesitate",
|
||||
"excerpt": "A working note on modeling emotional state without flattening behavior into a single number.",
|
||||
"content": "<!-- wp:paragraph --><p>Expressive software gets interesting when uncertainty is part of the model instead of an error to erase.</p><!-- /wp:paragraph --><!-- wp:code --><pre class=\"wp-block-code\"><code>const state = observe(world);\nconst choice = agent.respond(state, { uncertainty: true });</code></pre><!-- /wp:code -->",
|
||||
"content": "<!-- wp:paragraph --><p>Expressive software gets interesting when uncertainty is part of the model instead of an error to erase.</p><!-- /wp:paragraph --><!-- wp:code --><pre class=\"wp-block-code\"><code>const state = observe(world);\nconst choice = agent.respond(state, { uncertainty: true });\nABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789</code></pre><!-- /wp:code -->",
|
||||
"topic": "code",
|
||||
"language": "en",
|
||||
"featured": true
|
||||
"featured": true,
|
||||
"fixtureState": "unbroken-code"
|
||||
},
|
||||
{
|
||||
"fixtureKey": "post-research-primary",
|
||||
@@ -61,11 +62,8 @@
|
||||
{
|
||||
"fixtureKey": "post-podcast-missing-meta",
|
||||
"title": "Conversación pendiente de datos editoriales",
|
||||
"excerpt": "Estado de prueba para un episodio sin show ni duración asignados.",
|
||||
"content": "<!-- wp:paragraph --><p>El tema debe seguir siendo claro aunque la ficha editorial todavía esté incompleta.</p><!-- /wp:paragraph -->",
|
||||
"topic": "podcasts",
|
||||
"language": "es",
|
||||
"fixtureState": "missing-podcast-meta"
|
||||
"fixtureStates": [ "missing-podcast-meta", "missing-excerpt", "missing-topic", "missing-language" ]
|
||||
},
|
||||
{
|
||||
"fixtureKey": "post-life-fatherhood",
|
||||
@@ -106,42 +104,5 @@
|
||||
"content": "<!-- wp:quote --><blockquote class=\"wp-block-quote\"><p>La tinta sabía algo que el narrador todavía no.</p></blockquote><!-- /wp:quote -->",
|
||||
"topic": "literature",
|
||||
"language": "es"
|
||||
},
|
||||
{
|
||||
"fixtureKey": "post-missing-excerpt",
|
||||
"slug": "nota-local-sin-extracto",
|
||||
"title": "Nota local sin extracto",
|
||||
"content": "<!-- wp:paragraph --><p>Fixture local para comprobar el resumen ausente.</p><!-- /wp:paragraph -->",
|
||||
"topic": "life",
|
||||
"language": "es",
|
||||
"fixtureState": "missing-excerpt"
|
||||
},
|
||||
{
|
||||
"fixtureKey": "post-missing-topic",
|
||||
"slug": "note-without-topic",
|
||||
"title": "Note without a topic",
|
||||
"excerpt": "A local fixture with no editorial topic.",
|
||||
"content": "<!-- wp:paragraph --><p>The theme must not infer a private identity or category.</p><!-- /wp:paragraph -->",
|
||||
"language": "en",
|
||||
"fixtureState": "missing-topic"
|
||||
},
|
||||
{
|
||||
"fixtureKey": "post-missing-language",
|
||||
"slug": "nota-sin-idioma-asignado",
|
||||
"title": "Nota sin idioma asignado",
|
||||
"excerpt": "Fixture local sin taxonomía de idioma.",
|
||||
"content": "<!-- wp:paragraph --><p>El contenido permanece legible sin inventar metadatos.</p><!-- /wp:paragraph -->",
|
||||
"topic": "research",
|
||||
"fixtureState": "missing-language"
|
||||
},
|
||||
{
|
||||
"fixtureKey": "post-unbroken-code",
|
||||
"slug": "unbroken-token-overflow-test",
|
||||
"title": "Unbroken token overflow test",
|
||||
"excerpt": "A deliberately hostile local layout fixture.",
|
||||
"content": "<!-- wp:code --><pre class=\"wp-block-code\"><code>ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789</code></pre><!-- /wp:code -->",
|
||||
"topic": "code",
|
||||
"language": "en",
|
||||
"fixtureState": "unbroken-code"
|
||||
}
|
||||
]
|
||||
@@ -16,17 +16,18 @@ test( 'local visual fixtures define stable pages and representative editorial st
|
||||
[ 'home', 'journal', 'projects', 'music', 'podcasts', 'about', 'subscribe' ],
|
||||
);
|
||||
assert.ok( pages.every( ( page ) => page.fixtureKey && page.status === 'publish' ) );
|
||||
assert.ok( posts.length >= 10 );
|
||||
assert.equal( posts.length, 12 );
|
||||
assert.ok( posts.some( ( post ) => post.title.length > 100 ) );
|
||||
assert.ok( posts.some( ( post ) => post.content.includes( 'wp:code' ) ) );
|
||||
assert.ok( posts.some( ( post ) => post.fixtureState === 'missing-media' ) );
|
||||
assert.ok( posts.some( ( post ) => post.fixtureState === 'missing-podcast-meta' ) );
|
||||
assert.ok( posts.some( ( post ) => post.fixtureState === 'missing-excerpt' && !( 'excerpt' in post ) ) );
|
||||
assert.ok( posts.some( ( post ) => post.fixtureState === 'missing-topic' && !( 'topic' in post ) ) );
|
||||
assert.ok( posts.some( ( post ) => post.fixtureState === 'missing-language' && !( 'language' in post ) ) );
|
||||
const hasState = ( post, state ) => post.fixtureState === state || post.fixtureStates?.includes( state );
|
||||
assert.ok( posts.some( ( post ) => hasState( post, 'missing-podcast-meta' ) ) );
|
||||
assert.ok( posts.some( ( post ) => hasState( post, 'missing-excerpt' ) && !( 'excerpt' in post ) ) );
|
||||
assert.ok( posts.some( ( post ) => hasState( post, 'missing-topic' ) && !( 'topic' in post ) ) );
|
||||
assert.ok( posts.some( ( post ) => hasState( post, 'missing-language' ) && !( 'language' in post ) ) );
|
||||
assert.ok( posts.some( ( post ) => post.fixtureState === 'unbroken-code' && /[A-Z0-9]{256}/.test( post.content ) ) );
|
||||
assert.ok( posts.some( ( post ) => /^https:\/\//.test( post.canonicalEpisodeUrl ?? '' ) ) );
|
||||
assert.ok( posts.some( ( post ) => post.fixtureState === 'missing-podcast-meta' && !( 'canonicalEpisodeUrl' in post ) ) );
|
||||
assert.ok( posts.some( ( post ) => hasState( post, 'missing-podcast-meta' ) && !( 'canonicalEpisodeUrl' in post ) ) );
|
||||
assert.equal( new Set( posts.map( ( post ) => post.fixtureKey ) ).size, posts.length );
|
||||
for ( const topic of [ 'code', 'research', 'gaming', 'literature', 'music', 'podcasts', 'life' ] ) {
|
||||
assert.ok( posts.some( ( post ) => post.topic === topic ), `missing ${ topic } fixture` );
|
||||
@@ -42,12 +43,21 @@ test( 'the seed entrypoint is explicitly local-only and uses a stable fixture ke
|
||||
assert.match( shell, /featured-1/ );
|
||||
assert.match( shell, /subscribe-unavailable/ );
|
||||
assert.match( php, /_chrnx_fixture_key/ );
|
||||
assert.match( php, /wp_delete_post/ );
|
||||
assert.match( php, /canonical_episode_url/ );
|
||||
assert.match( php, /show_on_front/ );
|
||||
assert.match( php, /page_on_front/ );
|
||||
assert.match( php, /page_for_posts/ );
|
||||
} );
|
||||
|
||||
test( 'search and not-found recovery landmarks declare distinct accessible names', () => {
|
||||
const search = read( 'templates/search.html' );
|
||||
const missing = read( 'templates/404.html' );
|
||||
assert.match( search, /"ariaLabel":"Search recovery navigation"/ );
|
||||
assert.match( missing, /"ariaLabel":"Page not found recovery navigation"/ );
|
||||
assert.notEqual( search.match( /"ariaLabel":"([^"]+)"/ )?.[ 1 ], missing.match( /"ariaLabel":"([^"]+)"/ )?.[ 1 ] );
|
||||
} );
|
||||
|
||||
test( 'the visual layer is separately enqueued and covers responsive accessible states', () => {
|
||||
const assets = read( 'inc/assets.php' );
|
||||
const components = read( 'assets/css/components.css' );
|
||||
|
||||
Reference in new issue
Block a user