-
Notifications
You must be signed in to change notification settings - Fork 231
feat(compass-collection): Output Validation Followup - Mock Data Generator LLM CLOUDP-347048 #7365
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
d9f6a23
406aa2b
0b079fb
df49911
b471586
06258a8
84ee0cf
a8b814b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -64,7 +64,7 @@ describe('MockDataGeneratorModal', () => { | |
|
||
const store = createStore( | ||
collectionTabReducer, | ||
initialState, | ||
initialState as any, | ||
applyMiddleware(thunk.withExtraArgument(mockServices)) | ||
); | ||
|
||
|
@@ -538,6 +538,111 @@ describe('MockDataGeneratorModal', () => { | |
); | ||
}); | ||
|
||
it('displays preview of the faker call without args when the args are invalid', async () => { | ||
const largeLengthArgs = Array.from({ length: 11 }, () => 'testArg'); | ||
const mockServices = createMockServices(); | ||
mockServices.atlasAiService.getMockDataSchema = () => | ||
Promise.resolve({ | ||
fields: [ | ||
{ | ||
fieldPath: 'name', | ||
mongoType: 'String', | ||
fakerMethod: 'person.firstName', | ||
fakerArgs: largeLengthArgs, | ||
isArray: false, | ||
probability: 1.0, | ||
}, | ||
{ | ||
fieldPath: 'age', | ||
mongoType: 'Int32', | ||
fakerMethod: 'number.int', | ||
fakerArgs: [ | ||
{ | ||
json: JSON.stringify({ | ||
a: largeLengthArgs, | ||
}), | ||
}, | ||
], | ||
isArray: false, | ||
probability: 1.0, | ||
}, | ||
{ | ||
fieldPath: 'username', | ||
mongoType: 'String', | ||
fakerMethod: 'string.alpha', | ||
// large string | ||
fakerArgs: ['a'.repeat(1001)], | ||
isArray: false, | ||
probability: 1.0, | ||
}, | ||
{ | ||
fieldPath: 'avatar', | ||
mongoType: 'String', | ||
fakerMethod: 'image.url', | ||
fakerArgs: [ | ||
{ | ||
json: JSON.stringify({ | ||
width: 100_000, | ||
height: 100_000, | ||
}), | ||
}, | ||
], | ||
isArray: false, | ||
probability: 1.0, | ||
}, | ||
], | ||
}); | ||
|
||
await renderModal({ | ||
mockServices, | ||
schemaAnalysis: { | ||
...defaultSchemaAnalysisState, | ||
processedSchema: { | ||
name: { | ||
type: 'String', | ||
probability: 1.0, | ||
}, | ||
age: { | ||
type: 'Int32', | ||
probability: 1.0, | ||
}, | ||
username: { | ||
type: 'String', | ||
probability: 1.0, | ||
}, | ||
avatar: { | ||
type: 'String', | ||
probability: 1.0, | ||
}, | ||
}, | ||
}, | ||
}); | ||
|
||
// advance to the schema editor step | ||
userEvent.click(screen.getByText('Confirm')); | ||
await waitFor(() => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. seems to be an assertion missing? I'm not connecting how "faker args that are too large" are not shown There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Addressed There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oops, I added the assertion in |
||
expect(screen.getByTestId('faker-schema-editor')).to.exist; | ||
}); | ||
|
||
userEvent.click(screen.getByText('name')); | ||
expect(screen.getByTestId('faker-function-call-preview')).to.exist; | ||
expect(screen.queryByText(/testArg/)).to.not.exist; | ||
|
||
userEvent.click(screen.getByText('age')); | ||
expect(screen.getByTestId('faker-function-call-preview')).to.exist; | ||
expect(screen.queryByText(/testArg/)).to.not.exist; | ||
|
||
userEvent.click(screen.getByText('username')); | ||
expect(screen.queryByText(/aaaaaaa/)).to.not.exist; | ||
expect(screen.getByTestId('faker-function-call-preview')).to.exist; | ||
|
||
userEvent.click(screen.getByText('avatar')); | ||
expect(screen.getByTestId('faker-function-call-preview')).to.exist; | ||
expect(screen.queryByText(/width/)).to.not.exist; | ||
expect(screen.queryByText(/height/)).to.not.exist; | ||
expect(screen.queryByText(/100000/)).to.not.exist; | ||
}); | ||
|
||
it('disables the Next button when the faker schema mapping is not confirmed', async () => { | ||
await renderModal({ | ||
mockServices: mockServicesWithMockDataResponse, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: there's a
parseFakerArgs
with a different behavior. One should be renamed