Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

:white_check_mark: tests: fix tests

arvinxx7d65b51e0c09
diff --git a/package.json b/package.json
index c191101e291..6ac2be3fa61 100644
--- a/package.json
+++ b/package.json
@@ -392,8 +392,8 @@
"@types/oidc-provider": "^9.5.0",
"@types/pdfkit": "^0.17.4",
"@types/pg": "^8.16.0",
- "@types/react": "19.2.2",
- "@types/react-dom": "19.2.2",
+ "@types/react": "^19.2.7",
+ "@types/react-dom": "^19.2.3",
"@types/rtl-detect": "^1.0.3",
"@types/semver": "^7.7.1",
"@types/systemjs": "^6.15.4",
diff --git a/src/features/Conversation/store/slices/generation/action.test.ts b/src/features/Conversation/store/slices/generation/action.test.ts
index 8963a73a119..f3aee05acc8 100644
--- a/src/features/Conversation/store/slices/generation/action.test.ts
+++ b/src/features/Conversation/store/slices/generation/action.test.ts
@@ -446,10 +446,16 @@ describe('Generation Actions', () => {
const store = createStore({ context });
- // Set displayMessages after store creation
+ // Set displayMessages and dbMessages after store creation
+ // dbMessages is used to calculate children count for branch index
act(() => {
store.setState({
displayMessages: [{ id: 'msg-1', role: 'user', content: 'Hello', branch: { count: 2 } }],
+ dbMessages: [
+ { id: 'msg-1', role: 'user', content: 'Hello' },
+ { id: 'child-1', role: 'assistant', content: 'Response 1', parentId: 'msg-1' },
+ { id: 'child-2', role: 'assistant', content: 'Response 2', parentId: 'msg-1' },
+ ],
} as any);
});
@@ -464,6 +470,7 @@ describe('Generation Actions', () => {
});
// Should pass operationId to switchMessageBranch
+ // nextBranchIndex = childrenCount = 2 (two assistant messages with parentId: 'msg-1')
expect(mockSwitchMessageBranch).toHaveBeenCalledWith('msg-1', 2, {
operationId: 'test-op-id',
});
diff --git a/src/store/user/slices/auth/action.test.ts b/src/store/user/slices/auth/action.test.ts
index a195bcf7779..ff6c6072e34 100644
--- a/src/store/user/slices/auth/action.test.ts
+++ b/src/store/user/slices/auth/action.test.ts
@@ -210,7 +210,12 @@ describe('createAuthSlice', () => {
const originalLocation = window.location;
Object.defineProperty(window, 'location', {
configurable: true,
- value: { ...originalLocation, href: '', toString: () => 'http://localhost/chat' },
+ value: {
+ ...originalLocation,
+ href: '',
+ pathname: '/chat',
+ toString: () => 'http://localhost/chat',
+ },
writable: true,
});
@@ -234,6 +239,18 @@ describe('createAuthSlice', () => {
enableNextAuth.value = true;
useUserStore.setState({ oAuthSSOProviders: ['github'] });
+ const originalLocation = window.location;
+ Object.defineProperty(window, 'location', {
+ configurable: true,
+ value: {
+ ...originalLocation,
+ href: '',
+ pathname: '/chat',
+ toString: () => 'http://localhost/chat',
+ },
+ writable: true,
+ });
+
const { result } = renderHook(() => useUserStore());
await act(async () => {
@@ -243,6 +260,12 @@ describe('createAuthSlice', () => {
const { signIn } = await import('next-auth/react');
expect(signIn).toHaveBeenCalledWith('github');
+
+ Object.defineProperty(window, 'location', {
+ configurable: true,
+ value: originalLocation,
+ writable: true,
+ });
});
});