@@ -80,6 +80,70 @@ function legacyInstallation(suffix = '0123456789ab') {
8080}
8181
8282describe ( 'platform installation planning' , ( ) => {
83+ it ( 'resumes the recorded namespaces using the real unfiltered KV API response' , async ( ) => {
84+ const initial = await createPlatformInstallPlan ( client ( ) , input , null ) ;
85+ let manifest = createPlatformInstallationManifest ( {
86+ account : initial . account ,
87+ deployment : initial . deployment ,
88+ id : initial . installationId ,
89+ ownershipNonce : '0123456789abcdef0123456789abcdef' ,
90+ platformVersion : '1.0.0' ,
91+ createdAt : '2026-09-17T00:00:00.000Z' ,
92+ } ) ;
93+ for ( const [ key , name ] of [
94+ [ 'routing-kv' , initial . deployment . resources . routingKv ] ,
95+ [ 'isr-cache-kv' , initial . deployment . resources . isrCacheKv ] ,
96+ [ 'legacy-assets-kv' , initial . deployment . resources . legacyAssetsKv ] ,
97+ ] ) {
98+ manifest = recordInstallationResource (
99+ manifest ,
100+ {
101+ key,
102+ id : `${ key } -id` ,
103+ name,
104+ kind : 'kv-namespace' ,
105+ ownership : 'created' ,
106+ state : 'ready' ,
107+ configHash : 'test' ,
108+ } ,
109+ '2026-09-17T00:00:00.000Z' ,
110+ ) ;
111+ }
112+ const entries = manifest . resources . map ( ( { id, name } ) => ( { id, title : name } ) ) ;
113+ const api = new PlatformCloudflareClient ( 'test-token' , {
114+ fetcher : async ( url , init ) => {
115+ expect ( String ( url ) ) . toContain ( '/storage/kv/namespaces?' ) ;
116+ expect ( init ?. method ?? 'GET' ) . toBe ( 'GET' ) ;
117+ return Response . json ( { success : true , result : entries } ) ;
118+ } ,
119+ } ) ;
120+ const inspected : Array < string > = [ ] ;
121+ const plannerClient = client ( {
122+ listKvNamespaces : api . listKvNamespaces . bind ( api ) ,
123+ getKvValue : async ( _account : string , id : string ) => {
124+ inspected . push ( id ) ;
125+ return id === 'routing-kv-id' ? JSON . stringify ( manifest ) : null ;
126+ } ,
127+ } ) ;
128+ const resumed = await createPlatformInstallPlan ( plannerClient , input , manifest ) ;
129+ expect ( inspected ) . toEqual ( [ 'routing-kv-id' ] ) ;
130+ expect ( resumed . actions . filter ( ( action ) => action . kind === 'kv-namespace' ) ) . toEqual (
131+ expect . arrayContaining (
132+ manifest . resources . map ( ( resource ) =>
133+ expect . objectContaining ( {
134+ action : 'reuse' ,
135+ id : resource . id ,
136+ name : resource . name ,
137+ } ) ,
138+ ) ,
139+ ) ,
140+ ) ;
141+ entries . push ( { id : 'unowned-duplicate' , title : initial . deployment . resources . routingKv } ) ;
142+ await expect ( createPlatformInstallPlan ( plannerClient , input , manifest ) ) . rejects . toThrow (
143+ 'More than one kv-namespace' ,
144+ ) ;
145+ } ) ;
146+
83147 it . each ( [ false , true ] ) (
84148 'bolds names and labels, not account IDs or URLs (workers.dev: %s)' ,
85149 async ( workersDev ) => {
0 commit comments