feat(assistant): implement spec 021 chat assistant flow with semantic contracts

This commit is contained in:
2026-02-23 19:37:56 +03:00
parent 7e09ecde25
commit e432915ec3
27 changed files with 4029 additions and 20 deletions

View File

@@ -0,0 +1,59 @@
// [DEF:frontend.src.lib.stores.__tests__.assistantChat:Module]
// @TIER: STANDARD
// @SEMANTICS: test, store, assistant, toggle, conversation
// @PURPOSE: Validate assistant chat store visibility and conversation binding transitions.
// @LAYER: UI Tests
// @RELATION: DEPENDS_ON -> assistantChatStore
// @INVARIANT: Each test starts from default closed state.
import { describe, it, expect, beforeEach } from 'vitest';
import { get } from 'svelte/store';
import {
assistantChatStore,
toggleAssistantChat,
openAssistantChat,
closeAssistantChat,
setAssistantConversationId,
} from '../assistantChat.js';
// [DEF:assistantChatStore_tests:Function]
// @TIER: STANDARD
// @PURPOSE: Group store unit scenarios for assistant panel behavior.
// @PRE: Store can be reset to baseline state in beforeEach hook.
// @POST: Open/close/toggle/conversation transitions are validated.
describe('assistantChatStore', () => {
beforeEach(() => {
assistantChatStore.set({
isOpen: false,
conversationId: null,
});
});
it('should open assistant panel', () => {
openAssistantChat();
const state = get(assistantChatStore);
expect(state.isOpen).toBe(true);
});
it('should close assistant panel', () => {
openAssistantChat();
closeAssistantChat();
const state = get(assistantChatStore);
expect(state.isOpen).toBe(false);
});
it('should toggle assistant panel state', () => {
toggleAssistantChat();
expect(get(assistantChatStore).isOpen).toBe(true);
toggleAssistantChat();
expect(get(assistantChatStore).isOpen).toBe(false);
});
it('should set conversation id', () => {
setAssistantConversationId('conv-123');
const state = get(assistantChatStore);
expect(state.conversationId).toBe('conv-123');
});
});
// [/DEF:assistantChatStore_tests:Function]
// [/DEF:frontend.src.lib.stores.__tests__.assistantChat:Module]