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
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
Loading