Skip to content

Commit 2e1ca5c

Browse files
committed
address feedback
1 parent 01372f5 commit 2e1ca5c

File tree

2 files changed

+8
-131
lines changed

2 files changed

+8
-131
lines changed

packages/compass-collection/src/modules/collection-tab.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -573,7 +573,7 @@ export const generateFakerMappings = (
573573
) => {
574574
const { schemaAnalysis, fakerSchemaGeneration, namespace } = getState();
575575
if (schemaAnalysis.status !== SCHEMA_ANALYSIS_STATE_COMPLETE) {
576-
logger.log.error(
576+
logger.log.warn(
577577
mongoLogId(1_001_000_305),
578578
'Collection',
579579
'Cannot call `generateFakeMappings` unless schema analysis is complete'
@@ -588,9 +588,8 @@ export const generateFakerMappings = (
588588
return;
589589
}
590590

591-
const includeSampleValues = (
592-
await preferences.getConfigurableUserPreferences()
593-
).enableGenAISampleDocumentPassing;
591+
const includeSampleValues =
592+
preferences.getPreferences().enableGenAISampleDocumentPassing;
594593

595594
// todo: dedup/abort requests using requestId (CLOUDP-333850)
596595
const requestId = new UUID().toString();

packages/compass-collection/src/stores/collection-tab.spec.ts

Lines changed: 5 additions & 127 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,7 @@ import {
2828
} from '../schema-analysis-types';
2929
import type { SchemaAnalysisState } from '../schema-analysis-types';
3030
import { MockDataGeneratorStep } from '../components/mock-data-generator-modal/types';
31-
import type { MockDataGeneratorState } from '../components/mock-data-generator-modal/types';
3231
import { CollectionActions } from '../modules/collection-tab';
33-
import { type MockDataSchemaResponse } from '@mongodb-js/compass-generative-ai';
3432

3533
const defaultMetadata = {
3634
namespace: 'test.foo',
@@ -328,53 +326,11 @@ describe('Collection Tab Content store', function () {
328326
};
329327

330328
describe('on FakerMappingGenerationStarted', function () {
331-
it('should not change state when analyis is incomplete; or schema generation request in progress or completed', function () {
332-
const noOpStates: CollectionState[] = [
333-
{ ...baseState },
334-
{
335-
...baseState,
336-
schemaAnalysis: completeSchemaState,
337-
mockDataGenerator: {
338-
isModalOpen: false,
339-
currentStep: MockDataGeneratorStep.SCHEMA_CONFIRMATION,
340-
},
341-
fakerSchemaGeneration: {
342-
status: 'in-progress',
343-
requestId: 'existing_id',
344-
},
345-
},
346-
{
347-
...baseState,
348-
schemaAnalysis: completeSchemaState,
349-
mockDataGenerator: {
350-
isModalOpen: false,
351-
currentStep: MockDataGeneratorStep.SCHEMA_CONFIRMATION,
352-
},
353-
fakerSchemaGeneration: {
354-
status: 'completed',
355-
fakerSchema: {
356-
content: {
357-
fields: [
358-
{
359-
fieldPath: 'name',
360-
probability: 1.0,
361-
mongoType: 'string' as const,
362-
fakerMethod: 'person.firstName',
363-
fakerArgs: [],
364-
isArray: false,
365-
},
366-
],
367-
},
368-
},
369-
requestId: 'existing_id',
370-
},
371-
},
372-
];
373-
374-
noOpStates.forEach((state) => {
375-
const action = fakerMappingGenerationStartedAction;
376-
expect(collectionTabReducer(state, action)).to.deep.equal(state);
377-
});
329+
it('should not change state when analyis is incomplete', function () {
330+
const action = fakerMappingGenerationStartedAction;
331+
expect(collectionTabReducer({ ...baseState }, action)).to.deep.equal(
332+
baseState
333+
);
378334
});
379335

380336
it('should update status to generating when conditions are met', function () {
@@ -424,45 +380,6 @@ describe('Collection Tab Content store', function () {
424380
requestId: 'test_request_id',
425381
};
426382

427-
it('should not transition to completed if in idle, completed, or error state', function () {
428-
const noOpStates: MockDataGeneratorState[] = [
429-
{ status: 'idle' },
430-
{
431-
status: 'completed',
432-
fakerSchema: {
433-
content: {
434-
fields: [
435-
{
436-
fieldPath: 'name',
437-
probability: 1.0,
438-
mongoType: 'string' as const,
439-
fakerMethod: 'person.firstName',
440-
fakerArgs: [],
441-
isArray: false,
442-
},
443-
],
444-
},
445-
},
446-
requestId: 'existing_id',
447-
},
448-
{
449-
status: 'error',
450-
error: 'Some error',
451-
requestId: 'error_request_id',
452-
},
453-
];
454-
455-
noOpStates.forEach((fakerSchemaGeneration) => {
456-
const state: CollectionState = {
457-
...baseState,
458-
fakerSchemaGeneration,
459-
};
460-
const action = fakerMappingGenerationCompletedAction;
461-
462-
expect(collectionTabReducer(state, action)).to.deep.equal(state);
463-
});
464-
});
465-
466383
it('should update status to completed when generation is in progress', function () {
467384
const state: CollectionState = {
468385
...baseState,
@@ -498,45 +415,6 @@ describe('Collection Tab Content store', function () {
498415
requestId: 'test_request_id',
499416
};
500417

501-
it('should not transition to error if in idle, completed, or error state', function () {
502-
const noOpStates: MockDataGeneratorState[] = [
503-
{ status: 'idle' },
504-
{
505-
status: 'completed',
506-
fakerSchema: {
507-
content: {
508-
fields: [
509-
{
510-
fieldPath: 'name',
511-
probability: 1.0,
512-
mongoType: 'string' as const,
513-
fakerMethod: 'person.firstName',
514-
fakerArgs: [],
515-
isArray: false,
516-
},
517-
],
518-
},
519-
},
520-
requestId: 'existing_id',
521-
},
522-
{
523-
status: 'error',
524-
error: 'Previous error',
525-
requestId: 'error_request_id',
526-
},
527-
];
528-
529-
noOpStates.forEach((fakerSchemaGeneration) => {
530-
const state: CollectionState = {
531-
...baseState,
532-
fakerSchemaGeneration,
533-
};
534-
const action = fakerMappingGenerationFailedAction;
535-
536-
expect(collectionTabReducer(state, action)).to.deep.equal(state);
537-
});
538-
});
539-
540418
it('should update status to error when generation is in progress', function () {
541419
const state: CollectionState = {
542420
...baseState,

0 commit comments

Comments
 (0)