Skip to content

Commit 01372f5

Browse files
committed
remove thunk isolation test
1 parent 6d022af commit 01372f5

File tree

1 file changed

+0
-202
lines changed

1 file changed

+0
-202
lines changed

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

Lines changed: 0 additions & 202 deletions
Original file line numberDiff line numberDiff line change
@@ -295,208 +295,6 @@ describe('Collection Tab Content store', function () {
295295
});
296296
});
297297

298-
describe('generateFakerMappings thunk', function () {
299-
it('can complete successfully', async function () {
300-
const dispatch = sandbox.spy();
301-
const getState = sandbox.stub().returns({
302-
namespace: 'some_db.some_collection',
303-
schemaAnalysis: {
304-
status: SCHEMA_ANALYSIS_STATE_COMPLETE,
305-
processedSchema: {
306-
name: {
307-
type: 'String',
308-
probability: 1.0,
309-
sampleValues: ['John', 'Jane', 'Bob'],
310-
},
311-
age: {
312-
type: 'Number',
313-
probability: 0.9,
314-
sampleValues: [25, 30],
315-
},
316-
isActive: {
317-
type: 'Boolean',
318-
probability: 0.8,
319-
sampleValues: [true, false],
320-
},
321-
},
322-
schemaMetadata: {
323-
maxNestingDepth: 1,
324-
validationRules: null,
325-
},
326-
},
327-
fakerSchemaGeneration: { status: 'idle' },
328-
});
329-
const logger = {
330-
log: { error: sandbox.spy() },
331-
debug: sandbox.spy(),
332-
};
333-
const preferences = {
334-
getConfigurableUserPreferences: sandbox.stub().resolves({
335-
enableGenAISampleDocumentPassing: true,
336-
}),
337-
};
338-
339-
const mockDataSchemaResponse: MockDataSchemaResponse = {
340-
content: {
341-
fields: [
342-
{
343-
fieldPath: 'name',
344-
probability: 1.0,
345-
mongoType: 'string',
346-
fakerMethod: 'person.firstName',
347-
fakerArgs: [],
348-
isArray: false,
349-
},
350-
{
351-
fieldPath: 'isActive',
352-
probability: 1.0,
353-
mongoType: 'boolean',
354-
fakerMethod: 'datatype.boolean',
355-
fakerArgs: [],
356-
isArray: false,
357-
},
358-
],
359-
},
360-
};
361-
const atlasAiService = {
362-
getMockDataSchema: sandbox.stub().resolves(mockDataSchemaResponse),
363-
};
364-
365-
// Act
366-
const thunk = collectionTabModule.generateFakerMappings(
367-
mockAtlasConnectionInfo.current
368-
);
369-
await thunk(dispatch, getState, {
370-
logger,
371-
atlasAiService,
372-
preferences,
373-
} as any);
374-
375-
// Assert
376-
expect(dispatch).to.have.been.calledTwice;
377-
378-
const calls = dispatch.getCalls();
379-
const startedCall = calls[0];
380-
const completedCall = calls[1];
381-
382-
expect(startedCall).to.be.calledWith({
383-
type: CollectionActions.FakerMappingGenerationStarted,
384-
requestId: Sinon.match.string,
385-
});
386-
387-
expect(completedCall).to.be.calledWith({
388-
type: CollectionActions.FakerMappingGenerationCompleted,
389-
fakerSchema: mockDataSchemaResponse,
390-
requestId: Sinon.match.string,
391-
});
392-
});
393-
394-
it('can dispatch a failure', async function () {
395-
const dispatch = sandbox.spy();
396-
const getState = sandbox.stub().returns({
397-
namespace: 'some_db.some_collection',
398-
schemaAnalysis: {
399-
status: SCHEMA_ANALYSIS_STATE_COMPLETE,
400-
processedSchema: undefined,
401-
},
402-
fakerSchemaGeneration: { status: 'idle' },
403-
});
404-
const logger = {
405-
log: { error: sandbox.spy() },
406-
debug: sandbox.spy(),
407-
};
408-
const preferences = {
409-
getConfigurableUserPreferences: sandbox.stub().resolves({
410-
enableGenAISampleDocumentPassing: true,
411-
}),
412-
};
413-
414-
const atlasAiService = {
415-
getMockDataSchema: sandbox.stub().resolves({}),
416-
};
417-
418-
// Act
419-
const thunk = collectionTabModule.generateFakerMappings(
420-
mockAtlasConnectionInfo.current
421-
);
422-
await thunk(dispatch, getState, {
423-
logger,
424-
atlasAiService,
425-
preferences,
426-
} as any);
427-
428-
// Assert
429-
expect(dispatch).to.have.been.calledTwice;
430-
431-
const calls = dispatch.getCalls();
432-
const startedCall = calls[0];
433-
const completedCall = calls[1];
434-
435-
expect(startedCall).to.be.calledWith({
436-
type: CollectionActions.FakerMappingGenerationStarted,
437-
requestId: Sinon.match.string,
438-
});
439-
440-
expect(completedCall).to.be.calledWith({
441-
type: CollectionActions.FakerMappingGenerationFailed,
442-
error: Sinon.match.string,
443-
requestId: Sinon.match.string,
444-
});
445-
});
446-
447-
it('should not initiate if schemaAnalysis is incomplete', async function () {
448-
// Arrange
449-
const dispatch = sandbox.spy();
450-
const getState = sandbox.stub().returns({
451-
schemaAnalysis: { status: SCHEMA_ANALYSIS_STATE_INITIAL },
452-
fakerSchemaGeneration: { status: 'idle' },
453-
});
454-
const logger = {
455-
log: { error: sandbox.spy() },
456-
debug: sandbox.spy(),
457-
};
458-
const atlasAiService = {};
459-
460-
// Act
461-
const thunk = collectionTabModule.generateFakerMappings(
462-
mockAtlasConnectionInfo.current
463-
);
464-
await thunk(dispatch, getState, { logger, atlasAiService } as any);
465-
466-
// Assert
467-
expect(dispatch).to.not.have.been.called;
468-
expect(logger.log.error).to.have.been.calledOnce;
469-
});
470-
471-
it('should not initiate if fakerSchemaGeneration is in progress', async function () {
472-
// Arrange
473-
const dispatch = sandbox.spy();
474-
const getState = sandbox.stub().returns({
475-
schemaAnalysis: { status: SCHEMA_ANALYSIS_STATE_COMPLETE },
476-
fakerSchemaGeneration: {
477-
status: 'in-progress',
478-
},
479-
});
480-
const logger = {
481-
log: { error: sandbox.spy() },
482-
debug: sandbox.spy(),
483-
};
484-
const atlasAiService = {
485-
getMockDataSchema: sandbox.stub().returns(Promise.resolve({})),
486-
};
487-
488-
// Act
489-
const thunk = collectionTabModule.generateFakerMappings(
490-
mockAtlasConnectionInfo.current
491-
);
492-
await thunk(dispatch, getState, { logger, atlasAiService } as any);
493-
494-
// Assert
495-
expect(dispatch).to.not.have.been.called;
496-
expect(logger.debug).to.have.been.calledOnce;
497-
});
498-
});
499-
500298
describe('reducer handles fakerSchemaGeneration state transitions', function () {
501299
const baseState: CollectionState = {
502300
workspaceTabId: 'test_tab_id',

0 commit comments

Comments
 (0)