feat: Blend educative tips with witty phrases during loading times (fun, subtle learning...) (#10569)

Co-authored-by: Jacob Richman <jacob314@gmail.com>
This commit is contained in:
JAYADITYA
2025-10-16 22:38:43 +05:30
committed by GitHub
parent c96fd828df
commit 155242af34
3 changed files with 185 additions and 13 deletions

View File

@@ -21,9 +21,11 @@ describe('useLoadingIndicator', () => {
afterEach(() => {
vi.useRealTimers(); // Restore real timers after each test
act(() => vi.runOnlyPendingTimers);
vi.restoreAllMocks();
});
it('should initialize with default values when Idle', () => {
vi.spyOn(Math, 'random').mockImplementation(() => 0.5); // Always witty
const { result } = renderHook(() =>
useLoadingIndicator(StreamingState.Idle),
);
@@ -34,6 +36,7 @@ describe('useLoadingIndicator', () => {
});
it('should reflect values when Responding', async () => {
vi.spyOn(Math, 'random').mockImplementation(() => 0.5); // Always witty
const { result } = renderHook(() =>
useLoadingIndicator(StreamingState.Responding),
);
@@ -82,6 +85,7 @@ describe('useLoadingIndicator', () => {
});
it('should reset elapsedTime and use a witty phrase when transitioning from WaitingForConfirmation to Responding', async () => {
vi.spyOn(Math, 'random').mockImplementation(() => 0.5); // Always witty
const { result, rerender } = renderHook(
({ streamingState }) => useLoadingIndicator(streamingState),
{ initialProps: { streamingState: StreamingState.Responding } },
@@ -115,6 +119,7 @@ describe('useLoadingIndicator', () => {
});
it('should reset timer and phrase when streamingState changes from Responding to Idle', async () => {
vi.spyOn(Math, 'random').mockImplementation(() => 0.5); // Always witty
const { result, rerender } = renderHook(
({ streamingState }) => useLoadingIndicator(streamingState),
{ initialProps: { streamingState: StreamingState.Responding } },