-
Notifications
You must be signed in to change notification settings - Fork 7.5k
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
fix(core): Fix 431 for large dynamic node parameters #9384
Changes from all commits
e5d5a74
0127322
3174770
e6d3049
4236530
2e65fab
5e2e01a
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 |
---|---|---|
@@ -0,0 +1,80 @@ | ||
import type { SuperTest, Test } from 'supertest'; | ||
import { createOwner } from '../shared/db/users'; | ||
import { setupTestServer } from '../shared/utils'; | ||
import * as AdditionalData from '@/WorkflowExecuteAdditionalData'; | ||
import type { | ||
INodeListSearchResult, | ||
IWorkflowExecuteAdditionalData, | ||
ResourceMapperFields, | ||
} from 'n8n-workflow'; | ||
import { mock } from 'jest-mock-extended'; | ||
import { DynamicNodeParametersService } from '@/services/dynamicNodeParameters.service'; | ||
|
||
describe('DynamicNodeParametersController', () => { | ||
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. I was thinking about adding unit tests instead, since there are plenty of logical checks in the controller itself. 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. Thanks, this fix is about switching to |
||
const testServer = setupTestServer({ endpointGroups: ['dynamic-node-parameters'] }); | ||
let ownerAgent: SuperTest<Test>; | ||
|
||
beforeAll(async () => { | ||
const owner = await createOwner(); | ||
ownerAgent = testServer.authAgentFor(owner); | ||
}); | ||
|
||
const commonRequestParams = { | ||
credentials: {}, | ||
currentNodeParameters: {}, | ||
nodeTypeAndVersion: {}, | ||
path: 'path', | ||
methodName: 'methodName', | ||
}; | ||
|
||
describe('POST /dynamic-node-parameters/options', () => { | ||
jest.spyOn(AdditionalData, 'getBase').mockResolvedValue(mock<IWorkflowExecuteAdditionalData>()); | ||
|
||
it('should take params via body', async () => { | ||
jest | ||
.spyOn(DynamicNodeParametersService.prototype, 'getOptionsViaMethodName') | ||
.mockResolvedValue([]); | ||
|
||
await ownerAgent | ||
.post('/dynamic-node-parameters/options') | ||
.send({ | ||
...commonRequestParams, | ||
loadOptions: 'loadOptions', | ||
}) | ||
.expect(200); | ||
}); | ||
}); | ||
|
||
describe('POST /dynamic-node-parameters/resource-locator-results', () => { | ||
it('should take params via body', async () => { | ||
jest | ||
.spyOn(DynamicNodeParametersService.prototype, 'getResourceLocatorResults') | ||
.mockResolvedValue(mock<INodeListSearchResult>()); | ||
|
||
await ownerAgent | ||
.post('/dynamic-node-parameters/resource-locator-results') | ||
.send({ | ||
...commonRequestParams, | ||
filter: 'filter', | ||
paginationToken: 'paginationToken', | ||
}) | ||
.expect(200); | ||
}); | ||
}); | ||
|
||
describe('POST /dynamic-node-parameters/resource-mapper-fields', () => { | ||
it('should take params via body', async () => { | ||
jest | ||
.spyOn(DynamicNodeParametersService.prototype, 'getResourceMappingFields') | ||
.mockResolvedValue(mock<ResourceMapperFields>()); | ||
|
||
await ownerAgent | ||
.post('/dynamic-node-parameters/resource-mapper-fields') | ||
.send({ | ||
...commonRequestParams, | ||
loadOptions: 'loadOptions', | ||
}) | ||
.expect(200); | ||
}); | ||
}); | ||
}); |
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.
should we consider converting
DynamicNodeParametersRequest.Options
(and other request types in this controller) to a validatable class, to ensure that properties likenodeTypeAndVersion
andcurrentNodeParameters
are actually sent and valid?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.
I'd love this - Val is planning to address this more generally: https://n8nio.slack.com/archives/C069HS026UF/p1715177726506449?thread_ts=1715164850.683949&cid=C069HS026UF