import supertest from 'supertest' ; import { UnwrapPromise } from '@osd/utility-types' ; import { registerLogLegacyImportRoute } from '../log_legacy_import' ; import { loggingSystemMock } from '../../../logging/logging_system.mock' ; import { setupServer } from '../test_utils' ; type SetupServerReturn = UnwrapPromise < ReturnType < typeof setupServer > > ; describe ( 'POST /api/saved_objects/_log_legacy_import' , ( ) => { let server ; let httpSetup ; let logger ; beforeEach ( async ( ) => { ( { server , httpSetup } = await setupServer ( ) ) ; logger = loggingSystemMock . createLogger ( ) ; const router = httpSetup . createRouter ( '/api/saved_objects/' ) ; registerLogLegacyImportRoute ( router , logger ) ; await server . start ( ) ; } ) ; afterEach ( async ( ) => { await server . stop ( ) ; } ) ; it ( 'logs a warning when called' , async ( ) => { const result = await supertest ( httpSetup . server . listener ) . post ( '/api/saved_objects/_log_legacy_import' ) . expect ( 200 ) ; expect ( result . body ) . toEqual ( { success : true } ) ; expect ( loggingSystemMock . collect ( logger ) . warn ) . toMatchInlineSnapshot ( `
      Array [
        Array [
          "Importing saved objects from a .json file has been deprecated",
        ],
      ]
    ` ) ; } ) ; } ) ;