Skip to content

Commit a444035

Browse files
committed
handle modal closed action on fakerSchemaGeneration state
1 parent e88a7f7 commit a444035

File tree

2 files changed

+29
-2
lines changed

2 files changed

+29
-2
lines changed

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,9 @@ const reducer: Reducer<CollectionState, Action> = (
286286
...state.mockDataGenerator,
287287
isModalOpen: false,
288288
},
289+
fakerSchemaGeneration: {
290+
status: 'idle',
291+
},
289292
};
290293
}
291294

@@ -365,8 +368,6 @@ const reducer: Reducer<CollectionState, Action> = (
365368
};
366369
}
367370

368-
// todo: reset `fakerSchemaGeneration` state when modal flow restarts
369-
370371
if (
371372
isAction<FakerMappingGenerationStartedAction>(
372373
action,

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

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -747,5 +747,31 @@ describe('Collection Tab Content store', function () {
747747
expect(newState.metadata).to.deep.equal(state.metadata);
748748
});
749749
});
750+
751+
describe('on MockDataGeneratorModalClosed', function () {
752+
it('should reset fakerSchemaGeneration to idle', function () {
753+
const state: CollectionState = {
754+
...baseState,
755+
schemaAnalysis: completeSchemaState,
756+
mockDataGenerator: {
757+
isModalOpen: false,
758+
currentStep: MockDataGeneratorStep.SCHEMA_CONFIRMATION,
759+
},
760+
fakerSchemaGeneration: {
761+
status: 'error',
762+
error: 'Some error',
763+
requestId: 'some_request_id',
764+
},
765+
};
766+
767+
const action = {
768+
type: CollectionActions.MockDataGeneratorModalClosed,
769+
};
770+
const newState = collectionTabReducer(state, action);
771+
expect(newState.fakerSchemaGeneration).to.deep.equal({
772+
status: 'idle',
773+
});
774+
});
775+
});
750776
});
751777
});

0 commit comments

Comments
 (0)