[APM][Fleet] deprecation warning is not showing up (#119381)

* fixing deprecation warning

* fixing test
This commit is contained in:
Cauê Marcondes 2021-11-22 17:15:49 -05:00 committed by GitHub
parent 718f191099
commit 51f7986242
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 4 deletions

View file

@ -57,7 +57,13 @@ describe('getDeprecations', () => {
cloudSetup: { isCloudEnabled: true } as unknown as CloudSetup,
fleet: {
start: () => ({
agentPolicyService: { get: () => ({ id: 'foo' } as AgentPolicy) },
agentPolicyService: {
get: () =>
({
id: 'foo',
package_policies: [{ package: { name: 'apm' } }],
} as AgentPolicy),
},
}),
} as unknown as APMRouteHandlerResources['plugins']['fleet'],
});

View file

@ -9,7 +9,10 @@ import { GetDeprecationsContext, DeprecationsDetails } from 'src/core/server';
import { i18n } from '@kbn/i18n';
import { isEmpty } from 'lodash';
import { CloudSetup } from '../../../cloud/server';
import { getCloudAgentPolicy } from '../routes/fleet/get_cloud_apm_package_policy';
import {
getCloudAgentPolicy,
getApmPackagePolicy,
} from '../routes/fleet/get_cloud_apm_package_policy';
import { APMRouteHandlerResources } from '../';
export function getDeprecations({
@ -36,12 +39,12 @@ export function getDeprecations({
});
const isCloudEnabled = !!cloudSetup?.isCloudEnabled;
const hasAPMPackagePolicy = !isEmpty(getApmPackagePolicy(cloudAgentPolicy));
const hasCloudAgentPolicy = !isEmpty(cloudAgentPolicy);
// TODO: remove when docs support "main"
const docBranch = branch === 'main' ? 'master' : branch;
if (isCloudEnabled && !hasCloudAgentPolicy) {
if (isCloudEnabled && !hasAPMPackagePolicy) {
deprecations.push({
title: i18n.translate('xpack.apm.deprecations.legacyModeTitle', {
defaultMessage: 'APM Server running in legacy mode',