@@ -26,7 +26,7 @@ class WP_Codebox_Test_Browser_Contained_Site_Abilities {
2626 use WP_Codebox_Abilities_Execution;
2727}
2828
29- $cache_key = 'studio -proof';
29+ $cache_key = 'browser-site -proof';
3030$input_hash = str_repeat( 'c', 64 );
3131$transient_key = 'wp_codebox_browser_prepared_runtime_' . substr( hash( 'sha256', $cache_key . ':' . $input_hash ), 0, 24 );
3232$GLOBALS['wp_codebox_test_transients'][ $transient_key ] = array(
@@ -36,6 +36,14 @@ $GLOBALS['wp_codebox_test_transients'][ $transient_key ] = array(
3636 'created_at' => '2026-06-18T00:00:00+00:00',
3737 'blueprint' => array( 'steps' => array( array( 'step' => 'login' ) ) ),
3838);
39+ $bad_hash = str_repeat( 'e', 64 );
40+ $bad_transient_key = 'wp_codebox_browser_prepared_runtime_' . substr( hash( 'sha256', $cache_key . ':' . $bad_hash ), 0, 24 );
41+ $GLOBALS['wp_codebox_test_transients'][ $bad_transient_key ] = array(
42+ 'schema' => 'wp-codebox/browser-prepared-runtime-artifact/v1',
43+ 'cache_key' => $cache_key,
44+ 'input_hash' => $bad_hash,
45+ 'created_at' => '2026-06-18T00:00:00+00:00',
46+ );
3947
4048$hit = WP_Codebox_Test_Browser_Contained_Site_Abilities::get_browser_contained_site_status( array(
4149 'contained_site' => array(
@@ -48,12 +56,18 @@ $miss = WP_Codebox_Test_Browser_Contained_Site_Abilities::get_browser_contained_
4856 'site_id' => $cache_key,
4957 'input_hash' => str_repeat( 'd', 64 ),
5058) );
59+ $incompatible = WP_Codebox_Test_Browser_Contained_Site_Abilities::get_browser_contained_site_status( array(
60+ 'site_id' => $cache_key,
61+ 'input_hash' => $bad_hash,
62+ ) );
5163$open_hit = WP_Codebox_Test_Browser_Contained_Site_Abilities::open_browser_contained_site( array(
5264 'contained_site' => array(
5365 'schema' => 'wp-codebox/browser-contained-site/v1',
5466 'site_id' => $cache_key,
5567 'preview_id' => 'preview-proof',
5668 'session_id' => 'session-proof',
69+ 'artifact_seed' => 'seed-proof',
70+ 'artifact_revision' => 'revision-proof',
5771 'source_digest' => array( 'algorithm' => 'sha256', 'value' => $input_hash ),
5872 'preview' => array(
5973 'preview_public_url' => 'https://preview.example.test',
@@ -65,34 +79,49 @@ $open_hit = WP_Codebox_Test_Browser_Contained_Site_Abilities::open_browser_conta
6579 'recovery' => array( 'input' => array( 'cache_key' => $cache_key, 'input_hash' => $input_hash ) ),
6680 ),
6781 'preview_lease' => array( 'status' => 'active', 'expires_at' => '2099-01-01T00:00:00+00:00' ),
68- 'runtime_profile' => array( 'id' => 'studio-native -preview', 'env' => array( 'SECRET' => 'must-not-leak' ) ),
82+ 'runtime_profile' => array( 'id' => 'browser -preview', 'env' => array( 'SECRET' => 'must-not-leak' ) ),
6983) );
7084$open_miss = WP_Codebox_Test_Browser_Contained_Site_Abilities::open_browser_contained_site( array(
7185 'site_id' => $cache_key,
7286 'input_hash' => str_repeat( 'd', 64 ),
7387) );
7488
75- echo json_encode( array( 'hit' => $hit, 'miss' => $miss, 'open_hit' => $open_hit, 'open_miss' => $open_miss ), JSON_UNESCAPED_SLASHES );
89+ echo json_encode( array( 'hit' => $hit, 'miss' => $miss, 'incompatible' => $incompatible, ' open_hit' => $open_hit, 'open_miss' => $open_miss ), JSON_UNESCAPED_SLASHES );
7690` )
7791
7892assert . equal ( result . hit . schema , "wp-codebox/browser-contained-site-status/v1" )
7993assert . equal ( result . hit . success , true )
80- assert . equal ( result . hit . site_id , "studio -proof" )
94+ assert . equal ( result . hit . site_id , "browser-site -proof" )
8195assert . equal ( result . hit . status , "recoverable" )
96+ assert . equal ( result . hit . resolution . outcome , "recoverable" )
97+ assert . equal ( result . hit . resolution . reused , true )
98+ assert . equal ( result . hit . resolution . created , false )
99+ assert . equal ( result . hit . resolution . miss , false )
82100assert . equal ( result . hit . source_digest . value , "c" . repeat ( 64 ) )
83- assert . equal ( result . hit . blueprint_ref . ref , `prepared:studio -proof:${ "c" . repeat ( 64 ) } ` )
101+ assert . equal ( result . hit . blueprint_ref . ref , `prepared:browser-site -proof:${ "c" . repeat ( 64 ) } ` )
84102assert . equal ( result . miss . success , false )
85103assert . equal ( result . miss . status , "miss" )
104+ assert . equal ( result . miss . resolution . outcome , "miss" )
105+ assert . equal ( result . miss . resolution . miss , true )
106+ assert . equal ( result . miss . resolution . reason , "prepared-runtime-not-found-or-expired" )
107+ assert . equal ( result . incompatible . success , false )
108+ assert . equal ( result . incompatible . status , "incompatible" )
109+ assert . equal ( result . incompatible . resolution . incompatible , true )
110+ assert . equal ( result . incompatible . resolution . reason , "source-digest-mismatch" )
86111assert . equal ( result . open_hit . schema , "wp-codebox/browser-contained-site-open/v1" )
87112assert . equal ( result . open_hit . success , true )
88113assert . equal ( result . open_hit . status , "recoverable" )
114+ assert . equal ( result . open_hit . resolution . reused , true )
89115assert . equal ( result . open_hit . contained_site . schema , "wp-codebox/browser-contained-site/v1" )
90116assert . equal ( result . open_hit . contained_site . status , "recoverable" )
91- assert . equal ( result . open_hit . blueprint_ref . ref , `prepared:studio-proof:${ "c" . repeat ( 64 ) } ` )
117+ assert . equal ( result . open_hit . contained_site . resolution . outcome , "recoverable" )
118+ assert . equal ( result . open_hit . contained_site . artifact_seed , "seed-proof" )
119+ assert . equal ( result . open_hit . contained_site . artifact_revision , "revision-proof" )
120+ assert . equal ( result . open_hit . blueprint_ref . ref , `prepared:browser-site-proof:${ "c" . repeat ( 64 ) } ` )
92121assert . equal ( result . open_hit . blueprint_ref . hydrator_ability , "wp-codebox/hydrate-browser-blueprint-ref" )
93122assert . equal ( result . open_hit . blueprint_ref . hydration_endpoint . includes ( "/wp-codebox/v1/browser-blueprint-ref" ) , true )
94123assert . equal ( result . open_hit . preview_boot . schema , "wp-codebox/browser-preview-boot-config/v1" )
95- assert . equal ( result . open_hit . preview_boot . blueprint_ref , `prepared:studio -proof:${ "c" . repeat ( 64 ) } ` )
124+ assert . equal ( result . open_hit . preview_boot . blueprint_ref , `prepared:browser-site -proof:${ "c" . repeat ( 64 ) } ` )
96125assert . equal ( result . open_hit . preview_boot . preview . preview_public_url , "https://preview.example.test" )
97126assert . equal ( result . open_hit . preview_lease . schema , "wp-codebox/preview-lease/v1" )
98127assert . equal ( result . open_hit . preview_lease . lease . status , "active" )
@@ -103,6 +132,7 @@ assert.equal(JSON.stringify(result.open_hit).includes('"blueprint"'), false)
103132assert . equal ( JSON . stringify ( result . open_hit ) . includes ( "must-not-leak" ) , false )
104133assert . equal ( result . open_miss . success , false )
105134assert . equal ( result . open_miss . status , "miss" )
135+ assert . equal ( result . open_miss . resolution . miss , true )
106136assert . equal ( result . open_miss . blueprint_ref , undefined )
107137
108138console . log ( "browser contained site status ok" )
0 commit comments