char-fork/llama.cpp

git clone https://git.t4t.associates/char-fork/llama.cpp

Aleksander Grygierui: Stores split refactor (#27240)521a64cd0

char/aliceai-t5-moe
2.2 KiB77 linesraw
1import { ChatActivityStore } from '$lib/stores/chat/activity.svelte';
2import { beforeEach, describe, expect, it } from 'vitest';
3
4describe('ChatActivityStore', () => {
5	let store: ChatActivityStore;
6
7	beforeEach(() => {
8		store = new ChatActivityStore();
9	});
10
11	it('starts with no local or remote activity', () => {
12		expect(store.loadingConvs).toEqual([]);
13		expect(store.isLocal('a')).toBe(false);
14		expect(store.isRemote('a')).toBe(false);
15	});
16
17	it('markLocal adds a conv to the local set and the loading union', () => {
18		store.markLocal('a');
19
20		expect(store.isLocal('a')).toBe(true);
21		expect(store.isRemote('a')).toBe(false);
22		expect(store.loadingConvs).toEqual(['a']);
23	});
24
25	it('localEnded removes a local conv', () => {
26		store.markLocal('a');
27		store.localEnded('a');
28
29		expect(store.isLocal('a')).toBe(false);
30		expect(store.loadingConvs).toEqual([]);
31	});
32
33	it('localEnded also drops a stale remote hint for the same conv', () => {
34		store.markLocal('a');
35		store.applyRemoteSnapshot(['a']);
36		expect(store.isRemote('a')).toBe(true);
37
38		store.localEnded('a');
39
40		expect(store.isLocal('a')).toBe(false);
41		expect(store.isRemote('a')).toBe(false);
42		expect(store.loadingConvs).toEqual([]);
43	});
44
45	it('applyRemoteSnapshot adds remote convs and unions them with local', () => {
46		store.markLocal('local');
47		store.applyRemoteSnapshot(['remote']);
48
49		expect(store.isRemote('remote')).toBe(true);
50		expect(store.loadingConvs).toEqual(['local', 'remote']);
51	});
52
53	it('applyRemoteSnapshot removes remote convs missing from the snapshot', () => {
54		store.applyRemoteSnapshot(['a', 'b']);
55		store.applyRemoteSnapshot(['a']);
56
57		expect(store.isRemote('a')).toBe(true);
58		expect(store.isRemote('b')).toBe(false);
59		expect(store.loadingConvs).toEqual(['a']);
60	});
61
62	it('applyRemoteSnapshot keeps local convs absent from the snapshot', () => {
63		store.markLocal('local');
64		store.applyRemoteSnapshot(['remote']);
65		store.applyRemoteSnapshot([]);
66
67		expect(store.isLocal('local')).toBe(true);
68		expect(store.loadingConvs).toEqual(['local']);
69	});
70
71	it('loadingConvs does not duplicate a conv that is both local and remote', () => {
72		store.markLocal('a');
73		store.applyRemoteSnapshot(['a']);
74
75		expect(store.loadingConvs).toEqual(['a']);
76	});
77});