Skip to content

Commit

Permalink
tidy: PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
hop-dev committed Sep 13, 2021
1 parent fb12f1c commit 2d5334f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ function renderMenu({
agentPolicy,
packagePolicy,
showAddAgent = false,
isOpen = true,
defaultIsOpen = true,
}: {
agentPolicy: AgentPolicy;
packagePolicy: InMemoryPackagePolicy;
showAddAgent?: boolean;
isOpen?: boolean;
defaultIsOpen?: boolean;
}) {
const renderer = createIntegrationsTestRendererMock();

Expand All @@ -33,7 +33,7 @@ function renderMenu({
packagePolicy={packagePolicy}
showAddAgent={showAddAgent}
upgradePackagePolicyHref=""
isOpen={isOpen}
defaultIsOpen={defaultIsOpen}
key="test1"
/>
);
Expand Down Expand Up @@ -87,17 +87,17 @@ test('Should disable upgrade button if package does not have upgrade', async ()
const packagePolicy = createMockPackagePolicy({ hasUpgrade: false });
const { utils } = renderMenu({ agentPolicy, packagePolicy });
await act(async () => {
const upgradeButton = utils.getByText('Upgrade package policy').closest('button');
const upgradeButton = utils.getByText('Upgrade integration policy').closest('button');
expect(upgradeButton).toBeDisabled();
});
});

test('Should enable upgrade button if package does has upgrade', async () => {
test('Should enable upgrade button if package has upgrade', async () => {
const agentPolicy = createMockAgentPolicy();
const packagePolicy = createMockPackagePolicy({ hasUpgrade: true });
const { utils } = renderMenu({ agentPolicy, packagePolicy });
await act(async () => {
const upgradeButton = utils.getByText('Upgrade package policy').closest('button');
const upgradeButton = utils.getByText('Upgrade integration policy').closest('button');
expect(upgradeButton).not.toBeDisabled();
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,21 @@ export const PackagePolicyActionsMenu: React.FunctionComponent<{
packagePolicy: InMemoryPackagePolicy;
viewDataStep?: EuiStepProps;
showAddAgent?: boolean;
isOpen?: boolean;
defaultIsOpen?: boolean;
upgradePackagePolicyHref: string;
}> = ({
agentPolicy,
packagePolicy,
viewDataStep,
showAddAgent,
upgradePackagePolicyHref,
isOpen = false,
defaultIsOpen = false,
}) => {
const [isEnrollmentFlyoutOpen, setIsEnrollmentFlyoutOpen] = useState(false);
const { getHref } = useLink();
const hasWriteCapabilities = useCapabilities().write;
const refreshAgentPolicy = useAgentPolicyRefresh();
const [isActionsMenuOpen, setIsActionsMenuOpen] = useState(isOpen);
const [isActionsMenuOpen, setIsActionsMenuOpen] = useState(defaultIsOpen);

const onEnrollmentFlyoutClose = useMemo(() => {
return () => setIsEnrollmentFlyoutOpen(false);
Expand Down

0 comments on commit 2d5334f

Please sign in to comment.