Skip to content

Commit

Permalink
feat(boxai-sidebar): Add cache for Agent Selector
Browse files Browse the repository at this point in the history
Add missing Flow types and agents prop to mocked cache in tests. Remove unneeded type import.
  • Loading branch information
jankowiakdawid committed Feb 14, 2025
1 parent e824b98 commit dd84daa
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 2 deletions.
1 change: 0 additions & 1 deletion src/elements/content-sidebar/SidebarPanels.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import * as React from 'react';
import flow from 'lodash/flow';
import noop from 'lodash/noop';
import { matchPath, Redirect, Route, Switch, type Location } from 'react-router-dom';
import { type QuestionType } from '@box/box-ai-content-answers';
import SidebarUtils from './SidebarUtils';
import withSidebarAnnotations from './withSidebarAnnotations';
import { withAnnotatorContext } from '../common/annotator-context';
Expand Down
13 changes: 12 additions & 1 deletion src/elements/content-sidebar/__tests__/BoxAISidebar.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,19 @@ jest.mock('@box/box-ai-content-answers', () => ({
jest.mock('../BoxAISidebarTitle', () => () => <div data-testid="boxai-sidebar-title" />);

describe('elements/content-sidebar/BoxAISidebar', () => {
const mockAgents = {
agents: [],
requestState: 'success',
selectedAgent: null,
};

const mockProps = {
contentName: 'testName.txt',
cache: { encodedSession: '', questions: [] },
cache: {
encodedSession: '',
questions: [],
agents: mockAgents,
},
createSessionRequest: jest.fn(() => ({ encodedSession: '1234' })),
elementId: '123',
fetchTimeout: {},
Expand Down Expand Up @@ -200,6 +210,7 @@ describe('elements/content-sidebar/BoxAISidebar', () => {
prompt: 'not completed question',
},
],
agents: mockAgents,
},
});

Expand Down
18 changes: 18 additions & 0 deletions src/elements/content-sidebar/types/BoxAISidebarTypes.js.flow
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/**
* Flowtype definitions for BoxAISidebarTypes.ts
* Generated by Flowgen from a Typescript Definition
* Flowgen v1.21.0
*/

import { type, QuestionType } from "@box/box-ai-content-answers";
import { type, AgentState } from "@box/box-ai-agent-selector";
export type BoxAISidebarCache = {
agents: AgentState,
encodedSession: string | null,
questions: QuestionType[],
...
};
export type BoxAISidebarCacheSetter = (
key: "agents" | "encodedSession" | "questions",
value: AgentState | QuestionType[] | string | null
) => void;

0 comments on commit dd84daa

Please sign in to comment.