Skip to content

Commit

Permalink
feat(settings): enable sample documents setting COMPASS-7931 (#5857)
Browse files Browse the repository at this point in the history
  • Loading branch information
Anemy authored Jun 4, 2024
1 parent b319a42 commit 6a236ec
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 55 deletions.
14 changes: 0 additions & 14 deletions packages/compass-preferences-model/src/feature-flags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ export type FeatureFlags = {
showInsights: boolean;
enableRenameCollectionModal: boolean;
enableNewMultipleConnectionSystem: boolean;
showGenAIPassSampleDocumentsSetting: boolean;
};

export const featureFlags: Required<{
Expand Down Expand Up @@ -74,17 +73,4 @@ export const featureFlags: Required<{
long: 'Allows users to open multiple connections in the same window.',
},
},

/**
* Feature flag for showing the option to pass sample documents with our query and aggregation generation requests.
* Enables showing the `enableGenAISampleDocumentPassing` setting in the settings UI so folks can turn it on.
* Epic: COMPASS-7584
*/
showGenAIPassSampleDocumentsSetting: {
stage: 'development',
description: {
short: 'Enable showing the sample document gen ai setting.',
long: 'Allows users to show a setting to enable the passing of sample field values with our query and aggregation generation requests.',
},
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,7 @@ function renderGenAiSettings({
}) {
return render(
<Provider store={store}>
<GenAISettings
isAIFeatureEnabled
showGenAIPassSampleDocumentsSetting={false}
{...props}
/>
<GenAISettings isAIFeatureEnabled {...props} />
</Provider>
);
}
Expand Down Expand Up @@ -55,43 +51,18 @@ describe('GenAISettings', function () {
beforeEach(async function () {
store = configureStore();
await store.dispatch(fetchSettings());
});

it('shows the atlas login setting', function () {
renderGenAiSettings({
store,
});
container = screen.getByTestId('gen-ai-settings');
expect(container).to.include.text(atlasLoginSettingText);
});

describe('when the showGenAIPassSampleDocumentsSetting feature flag is disabled', function () {
beforeEach(function () {
renderGenAiSettings({
store,
});
container = screen.getByTestId('gen-ai-settings');
});

it('does not show the enableGenAISampleDocumentPassing setting', function () {
expect(container).to.not.include.text(sampleDocsSettingText);
});
it('shows the atlas login setting', function () {
expect(container).to.include.text(atlasLoginSettingText);
});

describe('when the showGenAIPassSampleDocumentsSetting feature flag is enabled', function () {
beforeEach(function () {
renderGenAiSettings({
store,
props: {
showGenAIPassSampleDocumentsSetting: true,
},
});
container = screen.getByTestId('gen-ai-settings');
});

it('does not show the enableGenAISampleDocumentPassing setting', function () {
expect(container).to.include.text(sampleDocsSettingText);
});
it('shows the enableGenAISampleDocumentPassing setting', function () {
expect(container).to.include.text(sampleDocsSettingText);
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ const atlasSettingsContainerStyles = css({

export const GenAISettings: React.FunctionComponent<{
isAIFeatureEnabled: boolean;
showGenAIPassSampleDocumentsSetting: boolean;
}> = ({ isAIFeatureEnabled, showGenAIPassSampleDocumentsSetting }) => {
}> = ({ isAIFeatureEnabled }) => {
return (
<div data-testid="gen-ai-settings">
<div>
Expand All @@ -28,9 +27,7 @@ export const GenAISettings: React.FunctionComponent<{
<div className={atlasSettingsContainerStyles}>
<ConnectedAtlasLoginSettings></ConnectedAtlasLoginSettings>
</div>
{showGenAIPassSampleDocumentsSetting && (
<SettingsList fields={['enableGenAISampleDocumentPassing']} />
)}
<SettingsList fields={['enableGenAISampleDocumentPassing']} />
</>
)}
</div>
Expand All @@ -39,8 +36,6 @@ export const GenAISettings: React.FunctionComponent<{

const mapState = (state: RootState) => ({
isAIFeatureEnabled: !!state.settings.settings.enableGenAIFeatures,
showGenAIPassSampleDocumentsSetting:
!!state.settings.settings.showGenAIPassSampleDocumentsSetting,
});

export default connect(mapState, null)(GenAISettings);

0 comments on commit 6a236ec

Please sign in to comment.