Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nchaulet committed Aug 29, 2024
1 parent 8451059 commit 1fec585
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,14 @@ jest.mock('../../../hooks', () => ({
},
useFleetStatus: jest.fn().mockReturnValue({}),
sendGetAgentStatus: jest.fn(),
sendBulkGetAgentPolicies: jest.fn().mockResolvedValue({
data: {
items: [
{ id: 'policy1', is_managed: false },
{ id: 'managed_policy', is_managed: true },
],
},
}),
sendGetAgentPolicies: jest.fn().mockResolvedValue({ data: { items: [] } }),
sendGetAgentTags: jest.fn().mockReturnValue({ data: { items: ['tag1', 'tag2'] } }),
useAuthz: jest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import {
useAuthz,
} from '../../hooks';
import { FLEET_SERVER_PACKAGE, MAX_FLYOUT_WIDTH } from '../../constants';
import type { PackagePolicy, AgentPolicy } from '../../types';
import type { PackagePolicy } from '../../types';

import { Loading } from '..';

Expand All @@ -57,11 +57,6 @@ export const AgentEnrollmentFlyout: React.FunctionComponent<FlyOutProps> = ({
isIntegrationFlow,
installedPackagePolicy,
}) => {
const findPolicyById = (policies: AgentPolicy[], id: string | undefined) => {
if (!id) return undefined;
return policies.find((p) => p.id === id);
};

const authz = useAuthz();

const fleetStatus = useFleetStatus();
Expand All @@ -87,7 +82,7 @@ export const AgentEnrollmentFlyout: React.FunctionComponent<FlyOutProps> = ({

const selectedPolicy = agentPolicyWithPackagePolicies
? agentPolicyWithPackagePolicies
: findPolicyById(agentPolicies, selectedPolicyId);
: undefined;

const hasNoFleetServerHost = fleetStatus.isReady && !fleetServerHost;

Expand Down

0 comments on commit 1fec585

Please sign in to comment.