Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,8 @@ describe('esaggs expression function - public', () => {
});
});

test('calls agg.postFlightRequest if it exiests', async () => {
test('calls agg.postFlightRequest if it exiests and agg is enabled', async () => {
mockParams.aggs.aggs[0].enabled = true;
await handleRequest(mockParams);
expect(mockParams.aggs.aggs[0].type.postFlightRequest).toHaveBeenCalledTimes(1);

Expand All @@ -160,6 +161,12 @@ describe('esaggs expression function - public', () => {
expect(async () => await handleRequest(mockParams)).not.toThrowError();
});

test('should skip agg.postFlightRequest call if the agg is disabled', async () => {
mockParams.aggs.aggs[0].enabled = false;
await handleRequest(mockParams);
expect(mockParams.aggs.aggs[0].type.postFlightRequest).toHaveBeenCalledTimes(0);
});

test('tabifies response data', async () => {
await handleRequest(mockParams);
expect(tabifyAggResponse).toHaveBeenCalledWith(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ export const handleRequest = async ({
// response data incorrectly in the inspector.
let response = (searchSource as any).rawResponse;
for (const agg of aggs.aggs) {
if (typeof agg.type.postFlightRequest === 'function') {
if (agg.enabled && typeof agg.type.postFlightRequest === 'function') {
response = await agg.type.postFlightRequest(
response,
aggs,
Expand Down