@@ -7,13 +7,10 @@ import {
77 runFailure ,
88 runSuccess ,
99} from '../src/test-utils/index.js' ;
10- import { createTelemetryHelper } from '../src/test-utils/telemetry-helper.js' ;
1110import { writeFile } from 'node:fs/promises' ;
1211import { join } from 'node:path' ;
1312import { afterAll , beforeAll , describe , expect , it } from 'vitest' ;
1413
15- const telemetry = createTelemetryHelper ( ) ;
16-
1714describe ( 'integration: add and remove config-bundle' , ( ) => {
1815 let project : TestProject ;
1916
@@ -23,7 +20,6 @@ describe('integration: add and remove config-bundle', () => {
2320
2421 afterAll ( async ( ) => {
2522 await project . cleanup ( ) ;
26- telemetry . destroy ( ) ;
2723 } ) ;
2824
2925 // ── Add lifecycle ─────────────────────────────────────────────────────
@@ -44,7 +40,7 @@ describe('integration: add and remove config-bundle', () => {
4440 expect ( json . bundleName ) . toBe ( 'InlineBundle' ) ;
4541
4642 const config = await readProjectConfig ( project . projectPath ) ;
47- const bundle = config . configBundles . find ( b => b . name === 'InlineBundle' ) ;
43+ const bundle = config . configBundles ! . find ( b => b . name === 'InlineBundle' ) ;
4844 expect ( bundle ) . toBeDefined ( ) ;
4945 expect ( bundle ! . type ) . toBe ( 'ConfigurationBundle' ) ;
5046 expect ( bundle ! . branchName ) . toBe ( 'mainline' ) ;
@@ -72,7 +68,7 @@ describe('integration: add and remove config-bundle', () => {
7268 expect ( json . bundleName ) . toBe ( 'FileBundle' ) ;
7369
7470 const config = await readProjectConfig ( project . projectPath ) ;
75- const bundle = config . configBundles . find ( b => b . name === 'FileBundle' ) ;
71+ const bundle = config . configBundles ! . find ( b => b . name === 'FileBundle' ) ;
7672 expect ( bundle ) . toBeDefined ( ) ;
7773 expect ( Object . keys ( bundle ! . components ) ) . toHaveLength ( 2 ) ;
7874 } ) ;
@@ -106,7 +102,7 @@ describe('integration: add and remove config-bundle', () => {
106102 expect ( json . bundleName ) . toBe ( 'FullOptsBundle' ) ;
107103
108104 const config = await readProjectConfig ( project . projectPath ) ;
109- const bundle = config . configBundles . find ( b => b . name === 'FullOptsBundle' ) ;
105+ const bundle = config . configBundles ! . find ( b => b . name === 'FullOptsBundle' ) ;
110106 expect ( bundle ) . toBeDefined ( ) ;
111107 expect ( bundle ! . description ) . toBe ( 'A bundle with all optional fields' ) ;
112108 expect ( bundle ! . branchName ) . toBe ( 'feature-branch' ) ;
@@ -131,7 +127,7 @@ describe('integration: add and remove config-bundle', () => {
131127 expect ( json . bundleName ) . toBe ( 'PlaceholderBundle' ) ;
132128
133129 const config = await readProjectConfig ( project . projectPath ) ;
134- const bundle = config . configBundles . find ( b => b . name === 'PlaceholderBundle' ) ;
130+ const bundle = config . configBundles ! . find ( b => b . name === 'PlaceholderBundle' ) ;
135131 expect ( bundle ) . toBeDefined ( ) ;
136132 const keys = Object . keys ( bundle ! . components ) ;
137133 expect ( keys ) . toContain ( '{{runtime:AgentA}}' ) ;
@@ -232,45 +228,37 @@ describe('integration: add and remove config-bundle', () => {
232228
233229 describe ( 'remove config-bundle' , ( ) => {
234230 it ( 'removes an existing config bundle' , async ( ) => {
235- const result = await runCLI (
231+ const json = await runSuccess (
236232 [ 'remove' , 'config-bundle' , '--name' , 'InlineBundle' , '--json' ] ,
237- project . projectPath ,
238- { env : telemetry . env }
233+ project . projectPath
239234 ) ;
240235
241- expect ( result . exitCode ) . toBe ( 0 ) ;
242- const json = JSON . parse ( result . stdout ) ;
243236 expect ( json . success ) . toBe ( true ) ;
244237
245238 const config = await readProjectConfig ( project . projectPath ) ;
246- const bundle = config . configBundles . find ( b => b . name === 'InlineBundle' ) ;
239+ const bundle = config . configBundles ! . find ( b => b . name === 'InlineBundle' ) ;
247240 expect ( bundle ) . toBeUndefined ( ) ;
248- telemetry . assertMetricEmitted ( { command : 'remove.config-bundle' , exit_reason : 'success' } ) ;
249241 } ) ;
250242
251243 it ( 'returns error for non-existent bundle' , async ( ) => {
252- const result = await runCLI (
244+ const json = await runFailure (
253245 [ 'remove' , 'config-bundle' , '--name' , 'DoesNotExist' , '--json' ] ,
254- project . projectPath ,
255- { env : telemetry . env }
246+ project . projectPath
256247 ) ;
257248
258- expect ( result . exitCode ) . toBe ( 1 ) ;
259- const json = JSON . parse ( result . stdout ) ;
260249 expect ( json . error ) . toContain ( 'not found' ) ;
261- telemetry . assertMetricEmitted ( { command : 'remove.config-bundle' , exit_reason : 'failure' } ) ;
262250 } ) ;
263251
264252 it ( 'removes all remaining config bundles one by one' , async ( ) => {
265253 const configBefore = await readProjectConfig ( project . projectPath ) ;
266- const remaining = configBefore . configBundles . map ( b => b . name ) ;
254+ const remaining = configBefore . configBundles ! . map ( b => b . name ) ;
267255
268256 for ( const name of remaining ) {
269257 await runSuccess ( [ 'remove' , 'config-bundle' , '--name' , name , '--json' ] , project . projectPath ) ;
270258 }
271259
272260 const configAfter = await readProjectConfig ( project . projectPath ) ;
273- expect ( configAfter . configBundles ) . toHaveLength ( 0 ) ;
261+ expect ( configAfter . configBundles ! ) . toHaveLength ( 0 ) ;
274262 } ) ;
275263 } ) ;
276264
@@ -294,21 +282,21 @@ describe('integration: add and remove config-bundle', () => {
294282 }
295283
296284 const config = await readProjectConfig ( project . projectPath ) ;
297- expect ( config . configBundles ) . toHaveLength ( bundleNames . length ) ;
285+ expect ( config . configBundles ! ) . toHaveLength ( bundleNames . length ) ;
298286
299287 for ( const name of bundleNames ) {
300- expect ( config . configBundles . find ( b => b . name === name ) ) . toBeDefined ( ) ;
288+ expect ( config . configBundles ! . find ( b => b . name === name ) ) . toBeDefined ( ) ;
301289 }
302290 } ) ;
303291
304292 it ( 'removing one bundle does not affect others' , async ( ) => {
305293 await runSuccess ( [ 'remove' , 'config-bundle' , '--name' , 'BundleBeta' , '--json' ] , project . projectPath ) ;
306294
307295 const config = await readProjectConfig ( project . projectPath ) ;
308- expect ( config . configBundles ) . toHaveLength ( 2 ) ;
309- expect ( config . configBundles . find ( b => b . name === 'BundleAlpha' ) ) . toBeDefined ( ) ;
310- expect ( config . configBundles . find ( b => b . name === 'BundleGamma' ) ) . toBeDefined ( ) ;
311- expect ( config . configBundles . find ( b => b . name === 'BundleBeta' ) ) . toBeUndefined ( ) ;
296+ expect ( config . configBundles ! ) . toHaveLength ( 2 ) ;
297+ expect ( config . configBundles ! . find ( b => b . name === 'BundleAlpha' ) ) . toBeDefined ( ) ;
298+ expect ( config . configBundles ! . find ( b => b . name === 'BundleGamma' ) ) . toBeDefined ( ) ;
299+ expect ( config . configBundles ! . find ( b => b . name === 'BundleBeta' ) ) . toBeUndefined ( ) ;
312300 } ) ;
313301
314302 afterAll ( async ( ) => {
0 commit comments