Skip to content

Commit 13e5784

Browse files
authored
Invalidate flags cache after benchmark creation to refresh dashboard registry (#2181)
Fixes OPS-4034.
1 parent b29c19b commit 13e5784

2 files changed

Lines changed: 15 additions & 0 deletions

File tree

packages/react-ui/src/app/features/benchmark/use-benchmark-wizard-navigation.test.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { BenchmarkWizardStepResponse } from '@openops/shared';
33
import { useMutation, useQueryClient } from '@tanstack/react-query';
44
import { act, renderHook } from '@testing-library/react';
55

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

@@ -588,6 +589,11 @@ describe('useBenchmarkWizardNavigation', () => {
588589
mockGetWizardStep.mockResolvedValue(lastStep);
589590
mockCreateBenchmark.mockResolvedValue(benchmarkResult);
590591

592+
const mockInvalidateQueries = jest.fn();
593+
mockUseQueryClient.mockReturnValue({
594+
invalidateQueries: mockInvalidateQueries,
595+
});
596+
591597
const { result } = renderHook(() =>
592598
useBenchmarkWizardNavigation(connectedProviders),
593599
);
@@ -603,6 +609,12 @@ describe('useBenchmarkWizardNavigation', () => {
603609
});
604610
expect(result.current.wizardPhase).toBe('benchmark-ready');
605611
expect(result.current.benchmarkCreateResult).toEqual(benchmarkResult);
612+
expect(mockInvalidateQueries).toHaveBeenCalledWith({
613+
queryKey: [QueryKeys.foldersFlows],
614+
});
615+
expect(mockInvalidateQueries).toHaveBeenCalledWith({
616+
queryKey: [QueryKeys.flags],
617+
});
606618
});
607619

608620
it('should call onBenchmarkCreated callback with the result', async () => {

packages/react-ui/src/app/features/benchmark/use-benchmark-wizard-navigation.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,9 @@ export const useBenchmarkWizardNavigation = (
8585
queryClient.invalidateQueries({
8686
queryKey: [QueryKeys.foldersFlows],
8787
});
88+
queryClient.invalidateQueries({
89+
queryKey: [QueryKeys.flags],
90+
});
8891
},
8992
onError: handleMutationError,
9093
});

0 commit comments

Comments
 (0)