-
Notifications
You must be signed in to change notification settings - Fork 6
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
Fio-8316 invalid data submitted in nested form #94
Changes from 3 commits
e2261bf
80284dd
7ff457e
2825f3b
a613a53
a7bf63c
723083c
e6eed0c
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 |
---|---|---|
@@ -1,6 +1,10 @@ | ||
.DS_Store | ||
.vscode | ||
node_modules | ||
docs | ||
lib | ||
dist | ||
.dccache | ||
# ignore nyc output | ||
.nyc_output | ||
coverage |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,7 +13,7 @@ | |
"./dist/formio.core.min.js": "./dist/formio.core.min.js" | ||
}, | ||
"scripts": { | ||
"test": "TEST=1 mocha -r ts-node/register -r tsconfig-paths/register -r mock-local-storage -r jsdom-global/register -b -t 0 'src/**/__tests__/*.test.ts'", | ||
"test": "TEST=1 nyc --reporter=lcov --reporter=text --reporter=text-summary mocha -r ts-node/register -r tsconfig-paths/register -r mock-local-storage -r jsdom-global/register -t 0 'src/**/__tests__/*.test.ts'", | ||
"lib": "tsc --project tsconfig.json && tsc-alias -p tsconfig.json", | ||
"replace": "node -r tsconfig-paths/register -r ts-node/register ./lib/base/array/ArrayComponent.js", | ||
"test:debug": "mocha -r ts-node/register -r tsconfig-paths/register -r mock-local-storage -r jsdom-global/register --debug-brk --inspect '**/*.spec.ts'", | ||
|
@@ -72,6 +72,7 @@ | |
"mocha": "^10.0.0", | ||
"mocha-jsdom": "^2.0.0", | ||
"mock-local-storage": "^1.1.20", | ||
"nyc": "^15.1.0", | ||
"power-assert": "^1.6.1", | ||
"sinon": "^17.0.1", | ||
"ts-loader": "^9.5.0", | ||
|
@@ -97,5 +98,23 @@ | |
"json-logic-js": "^2.0.2", | ||
"lodash": "^4.17.21", | ||
"moment": "^2.29.4" | ||
}, | ||
"nyc": { | ||
"check-coverage": true, | ||
"statements": 62, | ||
"branches": 52, | ||
"functions": 57, | ||
"lines": 60, | ||
"include": [ | ||
"src/**/*.ts", | ||
"src/**/*.js" | ||
], | ||
"exclude": [ | ||
"src/**/*.test.ts", | ||
"src/**/__tests__/", | ||
"src/experimental/**/*.ts", | ||
"src/types/**/*.ts" | ||
], | ||
"all": true | ||
} | ||
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. code coverage configuration. Some of the exclusions should be reviewed. the coverage thresholds are based on current value based on the entire project. |
||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,7 +15,7 @@ export const filterProcessSync: ProcessorFnSync<FilterScope> = (context: FilterC | |
scope.filter[absolutePath] = { | ||
compModelType: modelType, | ||
include: true, | ||
value: {data: {}} | ||
value: { data: {} } | ||
}; | ||
break; | ||
case 'array': | ||
|
@@ -47,19 +47,28 @@ export const filterProcess: ProcessorFn<FilterScope> = async (context: FilterCon | |
}; | ||
|
||
export const filterPostProcess: ProcessorFnSync<FilterScope> = (context: FilterContext) => { | ||
|
||
const { scope, submission } = context; | ||
console.log('filterPostProcess: context', Object.keys(context)); | ||
console.dir(context.components) | ||
|
||
const filtered = {}; | ||
for (const path in scope.filter) { | ||
if (scope.filter[path].include) { | ||
let value = get(submission?.data, path); | ||
if (isObject(value) && isObject(scope.filter[path].value)) { | ||
if (scope.filter[path].compModelType === 'dataObject') { | ||
value = {...value, ...scope.filter[path].value, data: (value as any)?.data} | ||
} else { | ||
value = {...value, ...scope.filter[path].value} | ||
} | ||
console.log('filterPostProcess path:', path); | ||
const pathFilter = scope.filter[path]; | ||
if (pathFilter) { | ||
|
||
let value = get(submission?.data, path) as any; | ||
console.log('path filter:', scope.filter[path]); | ||
console.log('path value:', value); | ||
|
||
// dataObject types (nested form) paths are recursively added to the scope.filter | ||
// excluding those from this and setting their components onto the submission directly | ||
if (pathFilter.compModelType !== 'dataObject') { | ||
set(filtered, path, value); | ||
} else { | ||
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. removing the logic to append the data object when the path is an object. skipping |
||
console.log('skipping path:', path, 'value:', value) | ||
} | ||
set(filtered, path, value); | ||
} | ||
} | ||
context.data = filtered; | ||
|
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.
This will run the test through the code coverage. It creates an HTML report to look at manually and file coverage and summary reports in the console.
I also removed the bail flag so all tests run. Not sure if that will cause and issue downstream or not.