43 lines
1.3 KiB
TypeScript
43 lines
1.3 KiB
TypeScript
/**
|
|
* @license
|
|
* Copyright 2025 AionUi (aionui.com)
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*/
|
|
|
|
import { describe, expect, it } from 'vitest';
|
|
import { getSidebarStreamGuardDecision } from '@/renderer/pages/conversation/GroupedHistory/hooks/useConversationListSync';
|
|
|
|
describe('getSidebarStreamGuardDecision', () => {
|
|
it('marks normal generating stream messages', () => {
|
|
expect(getSidebarStreamGuardDecision({ type: 'content', completed: false })).toEqual({
|
|
markGenerating: true,
|
|
clearCompleted: false,
|
|
lateIgnored: false,
|
|
});
|
|
});
|
|
|
|
it('ignores late stream messages after turn completion', () => {
|
|
expect(getSidebarStreamGuardDecision({ type: 'content', completed: true })).toEqual({
|
|
markGenerating: false,
|
|
clearCompleted: false,
|
|
lateIgnored: true,
|
|
});
|
|
});
|
|
|
|
it('allows a new start event to clear the completion guard', () => {
|
|
expect(getSidebarStreamGuardDecision({ type: 'start', completed: true })).toEqual({
|
|
markGenerating: true,
|
|
clearCompleted: true,
|
|
lateIgnored: false,
|
|
});
|
|
});
|
|
|
|
it('ignores non-generating messages', () => {
|
|
expect(getSidebarStreamGuardDecision({ type: 'slash_commands_updated', completed: true })).toEqual({
|
|
markGenerating: false,
|
|
clearCompleted: false,
|
|
lateIgnored: false,
|
|
});
|
|
});
|
|
});
|