mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
[Cloud Security] Fix auto increment issue on the integrations page (#161046)
This commit is contained in:
parent
8a170249fa
commit
2c01f7e290
2 changed files with 19 additions and 9 deletions
|
@ -42,13 +42,22 @@ jest.mock('../../common/api/use_package_policy_list');
|
|||
|
||||
const onChange = jest.fn();
|
||||
|
||||
const createReactQueryResponseWithRefetch = (
|
||||
data: Parameters<typeof createReactQueryResponse>[0]
|
||||
) => {
|
||||
return {
|
||||
...createReactQueryResponse(data),
|
||||
refetch: jest.fn(),
|
||||
};
|
||||
};
|
||||
|
||||
describe('<CspPolicyTemplateForm />', () => {
|
||||
beforeEach(() => {
|
||||
(useParams as jest.Mock).mockReturnValue({
|
||||
integration: undefined,
|
||||
});
|
||||
(usePackagePolicyList as jest.Mock).mockImplementation((packageName) =>
|
||||
createReactQueryResponse({
|
||||
createReactQueryResponseWithRefetch({
|
||||
status: 'success',
|
||||
data: {
|
||||
items: [],
|
||||
|
@ -57,7 +66,7 @@ describe('<CspPolicyTemplateForm />', () => {
|
|||
);
|
||||
onChange.mockClear();
|
||||
(useCspSetupStatusApi as jest.Mock).mockImplementation(() =>
|
||||
createReactQueryResponse({
|
||||
createReactQueryResponseWithRefetch({
|
||||
status: 'success',
|
||||
data: { status: 'indexed', installedPackageVersion: '1.2.13' },
|
||||
})
|
||||
|
@ -240,7 +249,7 @@ describe('<CspPolicyTemplateForm />', () => {
|
|||
});
|
||||
|
||||
(useCspSetupStatusApi as jest.Mock).mockImplementation(() =>
|
||||
createReactQueryResponse({
|
||||
createReactQueryResponseWithRefetch({
|
||||
status: 'success',
|
||||
data: {
|
||||
kspm: { status: 'not-deployed', healthyAgents: 0, installedPackagePolicies: 1 },
|
||||
|
@ -249,7 +258,7 @@ describe('<CspPolicyTemplateForm />', () => {
|
|||
);
|
||||
|
||||
(usePackagePolicyList as jest.Mock).mockImplementation(() =>
|
||||
createReactQueryResponse({
|
||||
createReactQueryResponseWithRefetch({
|
||||
status: 'success',
|
||||
data: {
|
||||
items: [
|
||||
|
@ -329,7 +338,7 @@ describe('<CspPolicyTemplateForm />', () => {
|
|||
integration: 'vuln_mgmt',
|
||||
});
|
||||
(useCspSetupStatusApi as jest.Mock).mockImplementation(() =>
|
||||
createReactQueryResponse({
|
||||
createReactQueryResponseWithRefetch({
|
||||
status: 'success',
|
||||
data: {
|
||||
vuln_mgmt: { status: 'not-deployed', healthyAgents: 0, installedPackagePolicies: 1 },
|
||||
|
@ -337,7 +346,7 @@ describe('<CspPolicyTemplateForm />', () => {
|
|||
})
|
||||
);
|
||||
(usePackagePolicyList as jest.Mock).mockImplementation(() =>
|
||||
createReactQueryResponse({
|
||||
createReactQueryResponseWithRefetch({
|
||||
status: 'success',
|
||||
data: {
|
||||
items: [
|
||||
|
@ -419,7 +428,7 @@ describe('<CspPolicyTemplateForm />', () => {
|
|||
});
|
||||
|
||||
(useCspSetupStatusApi as jest.Mock).mockImplementation(() =>
|
||||
createReactQueryResponse({
|
||||
createReactQueryResponseWithRefetch({
|
||||
status: 'success',
|
||||
data: {
|
||||
cspm: { status: 'not-deployed', healthyAgents: 0, installedPackagePolicies: 1 },
|
||||
|
@ -427,7 +436,7 @@ describe('<CspPolicyTemplateForm />', () => {
|
|||
})
|
||||
);
|
||||
(usePackagePolicyList as jest.Mock).mockImplementation(() =>
|
||||
createReactQueryResponse({
|
||||
createReactQueryResponseWithRefetch({
|
||||
status: 'success',
|
||||
data: {
|
||||
items: [
|
||||
|
|
|
@ -136,7 +136,7 @@ export const CspPolicyTemplateForm = memo<PackagePolicyReplaceDefineStepExtensio
|
|||
setTimeout(() => setIsLoading(false), 200);
|
||||
}, [validationResultsNonNullFields]);
|
||||
|
||||
const { data: packagePolicyList } = usePackagePolicyList(packageInfo.name, {
|
||||
const { data: packagePolicyList, refetch } = usePackagePolicyList(packageInfo.name, {
|
||||
enabled: canFetchIntegration,
|
||||
});
|
||||
|
||||
|
@ -148,6 +148,7 @@ export const CspPolicyTemplateForm = memo<PackagePolicyReplaceDefineStepExtensio
|
|||
// Required for mount only to ensure a single input type is selected
|
||||
// This will remove errors in validationResults.vars
|
||||
setEnabledPolicyInput(DEFAULT_INPUT_TYPE[input.policy_template]);
|
||||
refetch();
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [isLoading, input.policy_template, isEditPage]);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue