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 @@ -3,6 +3,7 @@ import { BenchmarkWizardStepResponse } from '@openops/shared';
import { useMutation, useQueryClient } from '@tanstack/react-query';
import { act, renderHook } from '@testing-library/react';

import { QueryKeys } from '@/app/constants/query-keys';
import { benchmarkApi } from './benchmark-api';
import { useBenchmarkWizardNavigation } from './use-benchmark-wizard-navigation';

Expand Down Expand Up @@ -588,6 +589,11 @@ describe('useBenchmarkWizardNavigation', () => {
mockGetWizardStep.mockResolvedValue(lastStep);
mockCreateBenchmark.mockResolvedValue(benchmarkResult);

const mockInvalidateQueries = jest.fn();
mockUseQueryClient.mockReturnValue({
invalidateQueries: mockInvalidateQueries,
});

const { result } = renderHook(() =>
useBenchmarkWizardNavigation(connectedProviders),
);
Expand All @@ -603,6 +609,12 @@ describe('useBenchmarkWizardNavigation', () => {
});
expect(result.current.wizardPhase).toBe('benchmark-ready');
expect(result.current.benchmarkCreateResult).toEqual(benchmarkResult);
expect(mockInvalidateQueries).toHaveBeenCalledWith({
queryKey: [QueryKeys.foldersFlows],
});
expect(mockInvalidateQueries).toHaveBeenCalledWith({
queryKey: [QueryKeys.flags],
});
});

it('should call onBenchmarkCreated callback with the result', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ export const useBenchmarkWizardNavigation = (
queryClient.invalidateQueries({
queryKey: [QueryKeys.foldersFlows],
});
queryClient.invalidateQueries({
queryKey: [QueryKeys.flags],
});
Comment on lines 85 to +90
Copy link

Copilot AI Mar 31, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New behavior: after successful benchmark creation, the hook now invalidates the flags query. There are existing Jest tests for this hook, but none currently assert the cache invalidation side-effects; adding an assertion in the “creating benchmark (last step)” success test would prevent regressions (expect invalidateQueries to be called for both foldersFlows and flags).

Copilot uses AI. Check for mistakes.
},
onError: handleMutationError,
});
Expand Down
Loading