Skip to content

Commit

Permalink
[ML] Transform: Fix <DefinePivotSummary /> jest test. (elastic#195998)
Browse files Browse the repository at this point in the history
## Summary

Fixes elastic#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)
  • Loading branch information
walterra authored and CAWilson94 committed Dec 12, 2024
1 parent 3fc2875 commit d16e2cc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit d16e2cc

Please sign in to comment.