Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 fix: fix create_session edit_agent feature flags and add more flags #3289

Merged
merged 11 commits into from
Jul 29, 2024
Prev Previous commit
Next Next commit
test: add test code
  • Loading branch information
Mingholy committed Jul 22, 2024
commit e505bea31c09007f74b04734c95ce845b3b1e9e1
22 changes: 22 additions & 0 deletions src/store/chat/slices/message/selectors.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { useAgentStore } from '@/store/agent';
import { ChatStore } from '@/store/chat';
import { initialState } from '@/store/chat/initialState';
import { messageMapKey } from '@/store/chat/slices/message/utils';
import { createServerConfigStore, initServerConfigStore } from '@/store/serverConfig/store';
import { LobeAgentConfig } from '@/types/agent';
import { ChatMessage } from '@/types/message';
import { MetaData } from '@/types/meta';
Expand Down Expand Up @@ -93,6 +94,14 @@ const mockChatStore = {
activeId: 'abc',
} as ChatStore;

beforeAll(() => {
createServerConfigStore();
});

afterEach(() => {
createServerConfigStore().setState({ featureFlags: { edit_agent: true } });
});

describe('chatSelectors', () => {
describe('getMessageById', () => {
it('should return undefined if the message with the given id does not exist', () => {
Expand Down Expand Up @@ -234,6 +243,19 @@ describe('chatSelectors', () => {

expect(chats[0].content).toMatch('agentDefaultMessage'); // Assuming translation returns a string containing this
});

it('should use agent default message without edit button for non-inbox sessions when agent is not editable', () => {
act(() => {
createServerConfigStore().setState({ featureFlags: { edit_agent: false } });
});

const state = merge(initialStore, { messages: [], activeId: 'someActiveId' });
const metaData = { title: 'Mock Agent' };

const chats = chatSelectors.currentChatsWithGuideMessage(metaData)(state);

expect(chats[0].content).toMatch('agentDefaultMessageWithoutEdit');
});
});

describe('chatsMessageString', () => {
Expand Down
2 changes: 2 additions & 0 deletions src/store/serverConfig/selectors.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ describe('featureFlagsSelectors', () => {
enableCheckUpdates: true,
showWelcomeSuggest: true,
enableClerkSignUp: true,
showMarket: true,
enableSTT: true,
});
});
});
Expand Down
Loading