Skip to content

Commit 5a818bb

Browse files
authored
chore(compass-assistant): hide connection error entry point when assistant is disabled (#7327)
1 parent d0cc085 commit 5a818bb

File tree

2 files changed

+34
-4
lines changed

2 files changed

+34
-4
lines changed

packages/compass-connections/src/components/connection-status-notifications.tsx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -207,10 +207,14 @@ const openConnectionFailedToast = ({
207207
}
208208
: undefined
209209
}
210-
onDebug={() => {
211-
closeToast(`connection-status--${failedToastId}`);
212-
onDebugClick?.();
213-
}}
210+
onDebug={
211+
onDebugClick
212+
? () => {
213+
closeToast(`connection-status--${failedToastId}`);
214+
onDebugClick();
215+
}
216+
: undefined
217+
}
214218
/>
215219
),
216220
variant: 'warning',

packages/compass-connections/src/stores/connections-store-redux.spec.tsx

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,32 @@ describe('CompassConnections store', function () {
176176
});
177177
});
178178

179+
it('should not show debug action when assistant is disabled', async function () {
180+
const { connectionsStore } = renderCompassConnections({
181+
preferences: {
182+
enableAIAssistant: false,
183+
enableGenAIFeatures: false,
184+
enableGenAIFeaturesAtlasOrg: false,
185+
cloudFeatureRolloutAccess: { GEN_AI_COMPASS: false },
186+
},
187+
connectFn: sinon
188+
.stub()
189+
.rejects(new Error('Failed to connect to cluster')),
190+
});
191+
192+
const connectionInfo = createDefaultConnectionInfo();
193+
194+
void connectionsStore.actions.connect(connectionInfo);
195+
196+
await waitFor(() => {
197+
expect(screen.getByText('Failed to connect to cluster')).to.exist;
198+
});
199+
200+
// The debug button should not be present when assistant is disabled
201+
expect(screen.queryByText('Debug for me')).to.not.exist;
202+
expect(screen.queryByTestId('connection-error-debug')).to.not.exist;
203+
});
204+
179205
it('should show non-genuine modal at the end of connection if non genuine mongodb detected', async function () {
180206
const { connectionsStore } = renderCompassConnections({});
181207

0 commit comments

Comments
 (0)