Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
changes to config value
Signed-off-by: Adhitya Mamallan <adhitya.mamallan@uber.com>
  • Loading branch information
adhityamamallan committed Jan 16, 2026
commit 0f43fec0191f3cb7a62fdf1b477cf3cbcedaa289
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
import React, { Suspense } from 'react';

import { renderHook, waitFor } from '@/test-utils/rtl';

import { type UseSuspenseConfigValueResult } from '@/hooks/use-config-value/use-config-value.types';
import useSuspenseConfigValue from '@/hooks/use-config-value/use-suspense-config-value';

import useSuspenseIsWorkflowHistoryV2Enabled from '../use-suspense-is-workflow-history-v2-enabled';

jest.mock('@/hooks/use-config-value/use-suspense-config-value');

const mockUseSuspenseConfigValue =
useSuspenseConfigValue as jest.MockedFunction<any>;

describe(useSuspenseIsWorkflowHistoryV2Enabled.name, () => {
it('should return true when config value is ENABLED', async () => {
const { result } = setup({ configValue: 'ENABLED' });

await waitFor(() => {
expect(result.current).toBe(true);
});
});

it('should return true when config value is OPT_OUT', async () => {
const { result } = setup({ configValue: 'OPT_OUT' });

await waitFor(() => {
expect(result.current).toBe(true);
});
});

it('should return false when config value is DISABLED', async () => {
const { result } = setup({ configValue: 'DISABLED' });

await waitFor(() => {
expect(result.current).toBe(false);
});
});

it('should return false when config value is OPT_IN', async () => {
const { result } = setup({ configValue: 'OPT_IN' });

await waitFor(() => {
expect(result.current).toBe(false);
});
});
});

function setup({
configValue,
}: {
configValue: 'DISABLED' | 'OPT_IN' | 'OPT_OUT' | 'ENABLED';
}) {
mockUseSuspenseConfigValue.mockReturnValue({
data: configValue,
} satisfies Pick<
UseSuspenseConfigValueResult<'HISTORY_PAGE_V2_ENABLED'>,
'data'
>);

const { result } = renderHook(
() => useSuspenseIsWorkflowHistoryV2Enabled(),
undefined,
{
wrapper: ({ children }: { children: React.ReactNode }) => (
<Suspense>{children}</Suspense>
),
}
);

return { result };
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import useSuspenseConfigValue from '@/hooks/use-config-value/use-suspense-config-value';

export default function useIsWorkflowHistoryV2Enabled(): boolean {
export default function useSuspenseIsWorkflowHistoryV2Enabled(): boolean {
const { data: historyPageV2Config } = useSuspenseConfigValue(
'HISTORY_PAGE_V2_ENABLED'
);

return historyPageV2Config === 'ENABLED' || historyPageV2Config === 'OPT-OUT';
// TODO @adhitya.mamallan - implement local-storage based behaviour for remembering opt-ins
return historyPageV2Config === 'ENABLED' || historyPageV2Config === 'OPT_OUT';
}