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