Files
iofficeai--aionui/tests/unit/conversation/runtime/conversationCommandQueueGate.test.ts
T
2026-07-13 13:20:22 +08:00

93 lines
2.2 KiB
TypeScript

/**
* @license
* Copyright 2025 AionUi (aionui.com)
* SPDX-License-Identifier: Apache-2.0
*/
import { describe, expect, it } from 'vitest';
import { getCommandQueueExecutionGate } from '@/renderer/pages/conversation/platforms/useConversationCommandQueue';
describe('getCommandQueueExecutionGate', () => {
it('keeps the legacy path gated by hydration and busy state', () => {
expect(getCommandQueueExecutionGate({ isBusy: true, isHydrated: true })).toEqual({
hydrated: true,
canExecute: false,
isProcessing: true,
});
expect(getCommandQueueExecutionGate({ isBusy: false, isHydrated: false })).toEqual({
hydrated: false,
canExecute: true,
isProcessing: false,
});
});
it('does not execute runtime-gated commands before hydration', () => {
expect(
getCommandQueueExecutionGate({
isBusy: false,
runtimeGate: {
hydrated: false,
canSendMessage: true,
isProcessing: false,
},
})
).toEqual({
hydrated: false,
canExecute: true,
isProcessing: false,
});
});
it('does not execute when runtime cannot send', () => {
expect(
getCommandQueueExecutionGate({
isBusy: false,
runtimeGate: {
hydrated: true,
canSendMessage: false,
isProcessing: false,
},
})
).toEqual({
hydrated: true,
canExecute: false,
isProcessing: false,
});
});
it('does not execute while runtime is processing', () => {
expect(
getCommandQueueExecutionGate({
isBusy: false,
runtimeGate: {
hydrated: true,
canSendMessage: true,
isProcessing: true,
},
})
).toEqual({
hydrated: true,
canExecute: false,
isProcessing: true,
});
});
it('executes only when runtime is hydrated, sendable, and idle', () => {
expect(
getCommandQueueExecutionGate({
isBusy: true,
runtimeGate: {
hydrated: true,
canSendMessage: true,
isProcessing: false,
},
})
).toEqual({
hydrated: true,
canExecute: true,
isProcessing: false,
});
});
});