forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[APM] Fix missing apm indicies (elastic#53541)
* [APM] Fix missing apm indicies * Fix infinite loop in ui indices * Add test for empty settings
- Loading branch information
Showing
4 changed files
with
87 additions
and
3 deletions.
There are no files selected for viewing
35 changes: 35 additions & 0 deletions
35
x-pack/legacy/plugins/apm/public/components/app/Settings/ApmIndices/index.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { render, wait } from '@testing-library/react'; | ||
import React from 'react'; | ||
import { ApmIndices } from '.'; | ||
import { MockApmPluginContextWrapper } from '../../../../utils/testHelpers'; | ||
import * as hooks from '../../../../hooks/useFetcher'; | ||
|
||
describe('ApmIndices', () => { | ||
it('should not get stuck in infinite loop', async () => { | ||
spyOn(hooks, 'useFetcher').and.returnValue({ | ||
data: undefined, | ||
status: 'loading' | ||
}); | ||
const { getByText } = render( | ||
<MockApmPluginContextWrapper> | ||
<ApmIndices /> | ||
</MockApmPluginContextWrapper> | ||
); | ||
|
||
expect(getByText('Indices')).toMatchInlineSnapshot(` | ||
<h2 | ||
class="euiTitle euiTitle--medium" | ||
> | ||
Indices | ||
</h2> | ||
`); | ||
|
||
await wait(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
x-pack/legacy/plugins/apm/server/lib/settings/apm_indices/save_apm_indices.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { saveApmIndices } from './save_apm_indices'; | ||
|
||
describe('saveApmIndices', () => { | ||
it('should trim and strip empty settings', async () => { | ||
const context = { | ||
core: { | ||
savedObjects: { | ||
client: { | ||
create: jest.fn() | ||
} | ||
} | ||
} | ||
} as any; | ||
|
||
const apmIndices = { | ||
settingA: 'aa', | ||
settingB: '', | ||
settingC: undefined, | ||
settingD: null, | ||
settingE: ' ', | ||
settingF: 'ff', | ||
settingG: ' gg ' | ||
} as any; | ||
await saveApmIndices(context, apmIndices); | ||
expect(context.core.savedObjects.client.create).toHaveBeenCalledWith( | ||
expect.any(String), | ||
{ settingA: 'aa', settingF: 'ff', settingG: 'gg' }, | ||
expect.any(Object) | ||
); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters