Skip to content

Commit 3df8f4a

Browse files
committed
fix: cleanup test
1 parent 1c3bcc3 commit 3df8f4a

File tree

1 file changed

+13
-23
lines changed

1 file changed

+13
-23
lines changed

packages/compass-generative-ai/src/atlas-ai-service.spec.ts

Lines changed: 13 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -330,13 +330,14 @@ describe('AtlasAiService', function () {
330330
});
331331
});
332332

333-
if (apiURLPreset === 'cloud') {
334-
it('should make a POST request to cloud endpoint and save preference when cloud preset', async function () {
335-
const fetchStub = sandbox.stub().resolves(makeResponse({}));
336-
global.fetch = fetchStub;
333+
it('should save preference when cloud preset', async function () {
334+
const fetchStub = sandbox.stub().resolves(makeResponse({}));
335+
global.fetch = fetchStub;
337336

338-
await atlasAiService.optIntoGenAIFeatures();
337+
await atlasAiService.optIntoGenAIFeatures();
339338

339+
// In Data Explorer, make a POST request to cloud endpoint and save preference
340+
if (apiURLPreset === 'cloud') {
340341
// Verify fetch was called with correct parameters
341342
expect(fetchStub).to.have.been.calledOnce;
342343

@@ -351,26 +352,15 @@ describe('AtlasAiService', function () {
351352
body: new URLSearchParams([['value', 'true']]),
352353
}
353354
);
354-
355-
// Verify preference was saved
356-
const currentPreferences = preferences.getPreferences();
357-
expect(currentPreferences.optInGenAIFeatures).to.equal(true);
358-
});
359-
} else {
360-
it('should not make any fetch request and only save preference when admin-api preset', async function () {
361-
const fetchStub = sandbox.stub().resolves(makeResponse({}));
362-
global.fetch = fetchStub;
363-
364-
await atlasAiService.optIntoGenAIFeatures();
365-
366-
// Verify no fetch was called
355+
} else {
356+
// In Compass, no fetch is made, only stored locally
367357
expect(fetchStub).to.not.have.been.called;
358+
}
368359

369-
// Verify preference was saved
370-
const currentPreferences = preferences.getPreferences();
371-
expect(currentPreferences.optInGenAIFeatures).to.equal(true);
372-
});
373-
}
360+
// Verify preference was saved
361+
const currentPreferences = preferences.getPreferences();
362+
expect(currentPreferences.optInGenAIFeatures).to.equal(true);
363+
});
374364
});
375365
});
376366
}

0 commit comments

Comments
 (0)