diff --git a/src/views/domain-workflows/domain-workflows-header/__tests__/domain-workflows-header.test.tsx b/src/views/domain-workflows/domain-workflows-header/__tests__/domain-workflows-header.test.tsx
index fc587dcde..807b34adc 100644
--- a/src/views/domain-workflows/domain-workflows-header/__tests__/domain-workflows-header.test.tsx
+++ b/src/views/domain-workflows/domain-workflows-header/__tests__/domain-workflows-header.test.tsx
@@ -41,16 +41,26 @@ jest.mock('@/components/page-filters/hooks/use-page-filters', () =>
}))
);
+jest.mock('../../hooks/use-list-workflows', () =>
+ jest.fn(() => ({
+ refetch: jest.fn(),
+ }))
+);
+
describe(DomainWorkflowsHeader.name, () => {
it('renders segmented control', async () => {
- render();
+ render(
+
+ );
expect(await screen.findByText('Search')).toBeInTheDocument();
expect(await screen.findByText('Query')).toBeInTheDocument();
});
it('renders page search and filters button when input type is search', async () => {
- render();
+ render(
+
+ );
expect(await screen.findByText('Filter search')).toBeInTheDocument();
expect(await screen.findByText('Filter toggle')).toBeInTheDocument();
@@ -58,7 +68,9 @@ describe(DomainWorkflowsHeader.name, () => {
it('renders page filters when filter toggle is clicked', async () => {
const user = userEvent.setup();
- render();
+ render(
+
+ );
const filterToggle = await screen.findByText('Filter toggle');
await user.click(filterToggle);
@@ -77,14 +89,18 @@ describe(DomainWorkflowsHeader.name, () => {
setQueryParams: mockSetQueryParams,
});
- render();
+ render(
+
+ );
expect(await screen.findByText('Query')).toBeInTheDocument();
});
it('toggles input type when segmented control is used', async () => {
const user = userEvent.setup();
- render();
+ render(
+
+ );
const queryButton = await screen.findByText('Search');
await user.click(queryButton);
diff --git a/src/views/domain-workflows/domain-workflows-header/domain-workflows-header.tsx b/src/views/domain-workflows/domain-workflows-header/domain-workflows-header.tsx
index 847fe3b29..da3d9ae5d 100644
--- a/src/views/domain-workflows/domain-workflows-header/domain-workflows-header.tsx
+++ b/src/views/domain-workflows/domain-workflows-header/domain-workflows-header.tsx
@@ -11,10 +11,12 @@ import domainPageQueryParamsConfig from '@/views/domain-page/config/domain-page-
import domainWorkflowsFiltersConfig from '../config/domain-workflows-filters.config';
import DomainWorkflowsQueryInput from '../domain-workflows-query-input/domain-workflows-query-input';
+import useListWorkflows from '../hooks/use-list-workflows';
import { overrides, styled } from './domain-workflows-header.styles';
+import { type Props } from './domain-workflows-header.types';
-export default function DomainWorkflowsHeader() {
+export default function DomainWorkflowsHeader({ domain, cluster }: Props) {
const [areFiltersShown, setAreFiltersShown] = useState(false);
const { resetAllFilters, activeFiltersCount, queryParams, setQueryParams } =
@@ -23,6 +25,8 @@ export default function DomainWorkflowsHeader() {
pageQueryParamsConfig: domainPageQueryParamsConfig,
});
+ const { refetch } = useListWorkflows({ domain, cluster });
+
return (
@@ -54,6 +58,7 @@ export default function DomainWorkflowsHeader() {
setQueryParams({ query: v })}
+ refetchQuery={refetch}
/>
) : (
<>
diff --git a/src/views/domain-workflows/domain-workflows-header/domain-workflows-header.types.ts b/src/views/domain-workflows/domain-workflows-header/domain-workflows-header.types.ts
index 1caec1506..5ab04ad92 100644
--- a/src/views/domain-workflows/domain-workflows-header/domain-workflows-header.types.ts
+++ b/src/views/domain-workflows/domain-workflows-header/domain-workflows-header.types.ts
@@ -2,3 +2,8 @@ import { type ListWorkflowsRequestQueryParams } from '@/route-handlers/list-work
export type DomainWorkflowsHeaderInputType =
ListWorkflowsRequestQueryParams['inputType'];
+
+export type Props = {
+ domain: string;
+ cluster: string;
+};
diff --git a/src/views/domain-workflows/domain-workflows-query-input/__tests__/domain-workflows-query-input.test.tsx b/src/views/domain-workflows/domain-workflows-query-input/__tests__/domain-workflows-query-input.test.tsx
index 99bb0a7a7..0f614fd96 100644
--- a/src/views/domain-workflows/domain-workflows-query-input/__tests__/domain-workflows-query-input.test.tsx
+++ b/src/views/domain-workflows/domain-workflows-query-input/__tests__/domain-workflows-query-input.test.tsx
@@ -29,17 +29,27 @@ describe(DomainWorkflowsQueryInput.name, () => {
expect(mockSetValue).toHaveBeenCalledWith('mock_query');
});
+
+ it('calls refetchQuery when the Rerun Query button is clicked', async () => {
+ const { mockRefetch, user } = setup({ startValue: 'test_query' });
+
+ await user.click(await screen.findByText('Rerun Query'));
+
+ expect(mockRefetch).toHaveBeenCalled();
+ });
});
function setup({ startValue }: { startValue?: string }) {
const mockSetValue = jest.fn();
+ const mockRefetch = jest.fn();
const user = userEvent.setup();
render(
);
- return { mockSetValue, user };
+ return { mockSetValue, mockRefetch, user };
}
diff --git a/src/views/domain-workflows/domain-workflows-query-input/domain-workflows-query-input.tsx b/src/views/domain-workflows/domain-workflows-query-input/domain-workflows-query-input.tsx
index 3066aadd5..0827ce66a 100644
--- a/src/views/domain-workflows/domain-workflows-query-input/domain-workflows-query-input.tsx
+++ b/src/views/domain-workflows/domain-workflows-query-input/domain-workflows-query-input.tsx
@@ -7,7 +7,11 @@ import { MdPlayArrow, MdCode, MdRefresh } from 'react-icons/md';
import { overrides } from './domain-workflows-query-input.styles';
import { type Props } from './domain-workflows-query-input.types';
-export default function DomainWorkflowsQueryInput({ value, setValue }: Props) {
+export default function DomainWorkflowsQueryInput({
+ value,
+ setValue,
+ refetchQuery,
+}: Props) {
const [queryText, setQueryText] = useState('');
useEffect(() => {
@@ -30,7 +34,9 @@ export default function DomainWorkflowsQueryInput({ value, setValue }: Props) {
clearOnEscape
/>