Skip to content

Commit

Permalink
Set conversation store for Chat stories
Browse files Browse the repository at this point in the history
  • Loading branch information
amosjyng committed Apr 11, 2024
1 parent 0a684f9 commit 57b4038
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 12 deletions.
5 changes: 4 additions & 1 deletion src-svelte/src/lib/__mocks__/stores.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import {
animationSpeed,
} from "$lib/preferences";
import { systemInfo } from "$lib/system-info";
import type { SystemInfo } from "$lib/bindings";
import { conversation } from "../../routes/chat/Chat.svelte";
import type { SystemInfo, ChatMessage } from "$lib/bindings";
import { firstAppLoad, firstPageLoad } from "$lib/firstPageLoad";

interface Preferences {
Expand All @@ -16,6 +17,7 @@ interface Preferences {

interface Stores {
systemInfo?: SystemInfo;
conversation?: ChatMessage[];
}

interface StoreArgs {
Expand Down Expand Up @@ -52,6 +54,7 @@ const SvelteStoresDecorator: Decorator = (
}

systemInfo.set(stores?.systemInfo);
conversation.set(stores?.conversation || []);

return story(args, context);
};
Expand Down
32 changes: 21 additions & 11 deletions src-svelte/src/routes/chat/Chat.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,32 +90,33 @@ const conversation: ChatMessage[] = [
];

export const NotEmpty: StoryObj = Template.bind({}) as any;
NotEmpty.args = {
conversation,
};
NotEmpty.parameters = {
stores: {
conversation,
},
viewport: {
defaultViewport: "smallTablet",
},
};

export const MultilineChat: StoryObj = Template.bind({}) as any;
MultilineChat.args = {
conversation,
initialMessage:
"This is what happens when the user types in so much text, " +
"it wraps around and turns the text input area into a multiline input. " +
"The send button's height should grow in line with the overall text area height.",
};
MultilineChat.parameters = {
stores: {
conversation,
},
viewport: {
defaultViewport: "smallTablet",
},
};

export const ExtraLongInput: StoryObj = Template.bind({}) as any;
ExtraLongInput.args = {
conversation,
initialMessage: `Hey, I have this definition for a book object:
\`\`\`python
Expand All @@ -135,49 +136,58 @@ class Book:
Do you have any code comments for me?`,
};
ExtraLongInput.parameters = {
stores: {
conversation,
},
viewport: {
defaultViewport: "smallTablet",
},
};

export const BottomScrollIndicator: StoryObj = Template.bind({}) as any;
BottomScrollIndicator.args = {
conversation,
showMostRecentMessage: false,
};
BottomScrollIndicator.parameters = {
stores: {
conversation,
},
viewport: {
defaultViewport: "smallTablet",
},
};

export const FullMessageWidth: StoryObj = Template.bind({}) as any;
FullMessageWidth.args = {
conversation,
};
FullMessageWidth.parameters = {
stores: {
conversation,
},
viewport: {
defaultViewport: "mobile1",
},
};

export const TypingIndicator: StoryObj = Template.bind({}) as any;
TypingIndicator.args = {
conversation: shortConversation,
expectingResponse: true,
};
TypingIndicator.parameters = {
stores: {
conversation: shortConversation,
},
viewport: {
defaultViewport: "smallTablet",
},
};

export const TypingIndicatorStatic: StoryObj = Template.bind({}) as any;
TypingIndicatorStatic.args = {
conversation: shortConversation,
expectingResponse: true,
};
TypingIndicatorStatic.parameters = {
stores: {
conversation: shortConversation,
},
preferences: {
animationsOn: false,
},
Expand Down

0 comments on commit 57b4038

Please sign in to comment.