Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions packages/compass-assistant/src/compass-assistant-drawer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ import {
AssistantActionsContext,
AssistantContext,
} from './compass-assistant-provider';
import { usePreference } from 'compass-preferences-model/provider';
import {
useIsAIFeatureEnabled,
usePreference,
} from 'compass-preferences-model/provider';

const assistantTitleStyles = css({
display: 'flex',
Expand All @@ -39,6 +42,7 @@ export const CompassAssistantDrawer: React.FunctionComponent<{
const { clearChat } = useContext(AssistantActionsContext);

const enableAIAssistant = usePreference('enableAIAssistant');
const isAiFeatureEnabled = useIsAIFeatureEnabled();

const handleClearChat = useCallback(async () => {
const confirmed = await showConfirmation({
Expand All @@ -54,7 +58,7 @@ export const CompassAssistantDrawer: React.FunctionComponent<{
}
}, [clearChat]);

if (!enableAIAssistant) {
if (!enableAIAssistant || !isAiFeatureEnabled) {
return null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,19 +234,67 @@ describe('CompassAssistantProvider', function () {
expect(screen.getByTestId('provider-children')).to.exist;
});

it('does not render assistant drawer when AI assistant is disabled', function () {
render(<TestComponent chat={createMockChat({ messages: [] })} />, {
preferences: {
enableAIAssistant: false,
enableGenAIFeatures: true,
enableGenAIFeaturesAtlasOrg: true,
cloudFeatureRolloutAccess: { GEN_AI_COMPASS: true },
},
describe('disabling the Assistant', function () {
it('does not render assistant drawer when AI assistant is disabled', function () {
render(<TestComponent chat={createMockChat({ messages: [] })} />, {
preferences: {
enableAIAssistant: false,
enableGenAIFeatures: true,
enableGenAIFeaturesAtlasOrg: true,
cloudFeatureRolloutAccess: { GEN_AI_COMPASS: true },
},
});

expect(screen.getByTestId('provider-children')).to.exist;
// The drawer toolbar button should not exist when disabled
expect(screen.queryByLabelText('MongoDB Assistant')).to.not.exist;
});

expect(screen.getByTestId('provider-children')).to.exist;
// The drawer toolbar button should not exist when disabled
expect(screen.queryByLabelText('MongoDB Assistant')).to.not.exist;
it('does not render assistant drawer when AI features are disabled via isAIFeatureEnabled', function () {
render(<TestComponent chat={createMockChat({ messages: [] })} />, {
preferences: {
enableAIAssistant: true,
// These control isAIFeatureEnabled
enableGenAIFeatures: false,
enableGenAIFeaturesAtlasOrg: true,
cloudFeatureRolloutAccess: { GEN_AI_COMPASS: true },
},
});

expect(screen.getByTestId('provider-children')).to.exist;
// The drawer toolbar button should not exist when AI features are disabled
expect(screen.queryByLabelText('MongoDB Assistant')).to.not.exist;
});

it('does not render assistant drawer when Atlas org AI features are disabled', function () {
render(<TestComponent chat={createMockChat({ messages: [] })} />, {
preferences: {
enableAIAssistant: true,
enableGenAIFeatures: true,
enableGenAIFeaturesAtlasOrg: false,
cloudFeatureRolloutAccess: { GEN_AI_COMPASS: true },
},
});

expect(screen.getByTestId('provider-children')).to.exist;
// The drawer toolbar button should not exist when Atlas org AI features are disabled
expect(screen.queryByLabelText('MongoDB Assistant')).to.not.exist;
});

it('does not render assistant drawer when cloud feature rollout access is disabled', function () {
render(<TestComponent chat={createMockChat({ messages: [] })} />, {
preferences: {
enableAIAssistant: true,
enableGenAIFeatures: true,
enableGenAIFeaturesAtlasOrg: true,
cloudFeatureRolloutAccess: { GEN_AI_COMPASS: false },
},
});

expect(screen.getByTestId('provider-children')).to.exist;
// The drawer toolbar button should not exist when cloud feature rollout access is disabled
expect(screen.queryByLabelText('MongoDB Assistant')).to.not.exist;
});
});

it('renders the assistant drawer as the first drawer item when AI assistant is enabled', function () {
Expand Down
Loading