[ML] Transform: Fix <DefinePivotSummary /> jest test. (#195998)

## Summary

Fixes #195992 (failing test).

Updates the mock for the preview endpoint to make the test pass again.

### Checklist

- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
- [x] This was checked for breaking API changes and was [labeled
appropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#_add_your_labels)
This commit is contained in:
Walter Rafelsberger 2024-12-05 16:59:00 +01:00 committed by GitHub
parent 5262902a86
commit c4d64039b3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 9 additions and 4 deletions

View file

@ -67,7 +67,14 @@ dataStart.search.search = jest.fn(({ params }: IKibanaSearchRequest) => {
}) as ISearchGeneric;
// Replace mock to support tests for `use_index_data`.
coreSetup.http.post = jest.fn().mockResolvedValue([]);
coreSetup.http.post = jest.fn().mockImplementation((endpoint) => {
if (endpoint === '/internal/transform/transforms/_preview') {
return Promise.resolve({
generated_dest_index: { mappings: { properties: {} } },
preview: [],
});
}
});
const appDependencies: AppDependencies = {
analytics: coreStart.analytics,

View file

@ -20,9 +20,7 @@ import { StepDefineSummary } from './step_define_summary';
jest.mock('../../../../app_dependencies');
// Failing: https://github.com/elastic/kibana/issues/195992
describe.skip('Transform: <DefinePivotSummary />', () => {
// Using the async/await wait()/done() pattern to avoid act() errors.
describe('Transform: <DefinePivotSummary />', () => {
test('Minimal initialization', async () => {
// Arrange
const queryClient = new QueryClient();