diff --git a/x-pack/test/dataset_quality_api_integration/common/config.ts b/x-pack/test/dataset_quality_api_integration/common/config.ts index 4f76c5d2b2047..e297d8eaf0354 100644 --- a/x-pack/test/dataset_quality_api_integration/common/config.ts +++ b/x-pack/test/dataset_quality_api_integration/common/config.ts @@ -22,7 +22,7 @@ import { import { createDatasetQualityApiClient } from './dataset_quality_api_supertest'; import { RegistryProvider } from './registry'; import { DatasetQualityFtrConfigName } from '../configs'; -import { PackageService } from './integration_service'; +import { PackageService } from './package_service'; export interface DatasetQualityFtrConfig { name: DatasetQualityFtrConfigName; @@ -71,7 +71,7 @@ export interface CreateTest { context: InheritedFtrProviderContext ) => Promise; datasetQualityApiClient: (context: InheritedFtrProviderContext) => DatasetQualityApiClient; - packageService: PackageService; + packageService: ({ getService }: FtrProviderContext) => ReturnType; }; junit: { reportName: string }; esTestCluster: any; diff --git a/x-pack/test/dataset_quality_api_integration/common/integration_service.ts b/x-pack/test/dataset_quality_api_integration/common/integration_service.ts deleted file mode 100644 index a3c5916c43ff0..0000000000000 --- a/x-pack/test/dataset_quality_api_integration/common/integration_service.ts +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. - */ -import { FtrService } from './ftr_provider_context'; - -export interface IntegrationPackage { - name: string; - version: string; -} - -export class PackageService extends FtrService { - private readonly supertest = this.ctx.getService('supertest'); - - async uninstallPackage({ name, version }: IntegrationPackage) { - return this.supertest - .delete(`/api/fleet/epm/packages/${name}/${version}`) - .set('kbn-xsrf', 'xxxx'); - } - - async installPackage({ name, version }: IntegrationPackage) { - return this.supertest - .post(`/api/fleet/epm/packages/${name}/${version}`) - .set('kbn-xsrf', 'xxxx') - .send({ force: true }); - } -} diff --git a/x-pack/test/dataset_quality_api_integration/common/package_service.ts b/x-pack/test/dataset_quality_api_integration/common/package_service.ts new file mode 100644 index 0000000000000..0449fd9f921dd --- /dev/null +++ b/x-pack/test/dataset_quality_api_integration/common/package_service.ts @@ -0,0 +1,30 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import { FtrProviderContext } from './ftr_provider_context'; + +interface IntegrationPackage { + name: string; + version: string; +} + +export function PackageService({ getService }: FtrProviderContext) { + const supertest = getService('supertest'); + + function uninstallPackage({ name, version }: IntegrationPackage) { + return supertest.delete(`/api/fleet/epm/packages/${name}/${version}`).set('kbn-xsrf', 'xxxx'); + } + + function installPackage({ name, version }: IntegrationPackage) { + return supertest + .post(`/api/fleet/epm/packages/${name}/${version}`) + .set('kbn-xsrf', 'xxxx') + .send({ force: true }); + } + + return { uninstallPackage, installPackage }; +}