1- import {
2- errorHandler ,
3- cleanStackFrameFilePath ,
4- addBugsnagMetadata ,
5- sendErrorToBugsnag ,
6- computeAllowedSliceNames ,
7- registerCleanBugsnagErrorsFromWithinPlugins ,
8- } from './error-handler.js'
1+ import { errorHandler , cleanStackFrameFilePath , addBugsnagMetadata , sendErrorToBugsnag } from './error-handler.js'
92import * as metadata from './metadata.js'
103import { ciPlatform , cloudEnvironment , isUnitTest , macAddress } from './context/local.js'
114import { mockAndCaptureOutput } from './testing/output.js'
@@ -224,33 +217,7 @@ describe('sends errors to Bugsnag', () => {
224217 expect ( mockOutput . debug ( ) ) . toMatch ( 'Error reporting to Bugsnag: Error: Bugsnag is down' )
225218 } )
226219
227- test ( 'logs and suppresses when allowed slice names not initialized' , async ( ) => {
228- // Reset module state to ensure ALLOWED_SLICE_NAMES is undefined
229- vi . resetModules ( )
230-
231- await metadata . addSensitiveMetadata ( ( ) => ( {
232- commandStartOptions : { startTime : Date . now ( ) , startCommand : 'app dev' , startArgs : [ ] } ,
233- } ) )
234-
235- const mockOutput = mockAndCaptureOutput ( )
236-
237- const res = await sendErrorToBugsnag ( new Error ( 'boom' ) , 'unexpected_error' )
238- expect ( res . reported ) . toEqual ( false )
239- expect ( mockOutput . debug ( ) ) . toMatch (
240- 'Error reporting to Bugsnag: Error: Internal error: allowed slice names not initialized.' ,
241- )
242- } )
243-
244220 test ( 'attaches custom metadata with allowed slice_name when startCommand is present' , async ( ) => {
245- // Initialize allowed slice names to include 'app' using a mock config
246- await registerCleanBugsnagErrorsFromWithinPlugins ( {
247- // Minimal shape required by the function
248- // eslint-disable-next-line @typescript-eslint/no-explicit-any
249- commands : [ { id : 'app:dev' } ] as any ,
250- // eslint-disable-next-line @typescript-eslint/no-explicit-any
251- plugins : new Map ( ) as any ,
252- } as unknown as any )
253-
254221 await metadata . addSensitiveMetadata ( ( ) => ( {
255222 commandStartOptions : { startTime : Date . now ( ) , startCommand : 'app dev' , startArgs : [ ] } ,
256223 } ) )
@@ -275,14 +242,6 @@ describe('sends errors to Bugsnag', () => {
275242 } )
276243
277244 test ( 'defaults slice_name to cli when first word not allowed' , async ( ) => {
278- // Initialize allowed slice names to known set that does not include 'version'
279- await registerCleanBugsnagErrorsFromWithinPlugins ( {
280- // eslint-disable-next-line @typescript-eslint/no-explicit-any
281- commands : [ { id : 'app:dev' } ] as any ,
282- // eslint-disable-next-line @typescript-eslint/no-explicit-any
283- plugins : new Map ( ) as any ,
284- } as unknown as any )
285-
286245 await metadata . addSensitiveMetadata ( ( ) => ( {
287246 commandStartOptions : { startTime : Date . now ( ) , startCommand : 'version' , startArgs : [ ] } ,
288247 } ) )
@@ -293,16 +252,3 @@ describe('sends errors to Bugsnag', () => {
293252 expect ( lastBugsnagEvent ! . addMetadata ) . toHaveBeenCalledWith ( 'custom' , { slice_name : 'cli' } )
294253 } )
295254} )
296-
297- describe ( 'computeAllowedSliceNames' , ( ) => {
298- test ( 'derives first tokens from command IDs' , ( ) => {
299- const names = computeAllowedSliceNames ( {
300- // eslint-disable-next-line @typescript-eslint/no-explicit-any
301- commands : [ { id : 'app:build' } , { id : 'theme:pull' } , { id : 'version' } , { id : undefined as any } ] as any ,
302- } as unknown as any )
303- expect ( names . has ( 'app' ) ) . toBe ( true )
304- expect ( names . has ( 'theme' ) ) . toBe ( true )
305- expect ( names . has ( 'version' ) ) . toBe ( true )
306- expect ( names . has ( 'store' ) ) . toBe ( false )
307- } )
308- } )
0 commit comments