Skip to content

Commit

Permalink
fix(generative-ai): when opted-in and the project setting is disabled…
Browse files Browse the repository at this point in the history
… show opt in COMPASS-8681 (#6564)
  • Loading branch information
Anemy authored Dec 13, 2024
1 parent 263fae0 commit b23c5dd
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,39 @@ describe('atlasOptInReducer', function () {
);
});

describe('when already opted in, and the project setting is set to false', function () {
beforeEach(async function () {
await mockPreferences.savePreferences({
enableGenAIFeaturesAtlasProject: false,
optInDataExplorerGenAIFeatures: true,
});
});

it('should start the opt in flow', async function () {
const mockAtlasAiService = {
optIntoGenAIFeaturesAtlas: sandbox.stub().resolves({ sub: '1234' }),
};
const store = configureStore({
atlasAuthService: {} as any,
atlasAiService: mockAtlasAiService as any,
preferences: mockPreferences,
});

expect(store.getState().optIn).to.have.nested.property(
'state',
'initial'
);
void store.dispatch(optIntoGenAIWithModalPrompt()).catch(() => {});
await store.dispatch(optIn());
expect(mockAtlasAiService.optIntoGenAIFeaturesAtlas).to.have.been
.calledOnce;
expect(store.getState().optIn).to.have.nested.property(
'state',
'optin-success'
);
});
});

it('should fail opt in if opt in failed', async function () {
const mockAtlasAiService = {
optIntoGenAIFeaturesAtlas: sandbox
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,8 +227,9 @@ export const optIntoGenAIWithModalPrompt = ({
// Nothing to do if we already opted in.
const { state } = getState().optIn;
if (
state === 'optin-success' ||
preferences.getPreferences().optInDataExplorerGenAIFeatures
(state === 'optin-success' ||
preferences.getPreferences().optInDataExplorerGenAIFeatures) &&
preferences.getPreferences().enableGenAIFeaturesAtlasProject
) {
return Promise.resolve();
}
Expand Down

0 comments on commit b23c5dd

Please sign in to comment.