-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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 for lack of id schema being generated in schema dependency demo #819
Conversation
@edi9999 @jonathonlui Hi, any updates on this? |
definitions, | ||
formData, | ||
idSchema["$id"] | ||
); |
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.
Can you add a test that shows that it failed before ?
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.
@redixhumayun you can use or adapt the test of ObjetField
from my branch: master...jonathonlui:fix-nested-object-dynamic-conditionals
When ObjectField.js
does not have these changes applied then using npm test
the test correctly fails . However, there is an issue with the test when running npm run tdd
: the first test run will correctly fail but when the test is rerun because of a changed file, the test will incorrectly pass. I'm guessing it's related to resetting the console.error
stub but I was not able to resolve the issue.
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.
@edi9999 - Hi added a failing and passing test to ObjectField_test.js. Take a look when you get a chance.
…ma and then toIdSchema
Any updates on this PR? I am needing required fields within a schema dependency a level down, and this seems to be the fix. @edi9999 |
The CI is failing : https://travis-ci.org/mozilla-services/react-jsonschema-form/jobs/336896307 |
@redixhumayun Can you check out why the test is failing? Thanks everyone for their work here! |
@jamesdebolt - The CI is failing because I was asked to add a test that showed the failure I was trying to fix by @edi9999. You can see that in the thread below the commit |
@@ -16,7 +16,8 @@ | |||
"publish-to-npm": "npm run build:readme && npm run dist && npm publish", | |||
"start": "node devServer.js", | |||
"tdd": "cross-env NODE_ENV=test mocha --compilers js:babel-register --watch --require ./test/setup-jsdom.js test/**/*_test.js", | |||
"test": "cross-env NODE_ENV=test mocha --compilers js:babel-register --require ./test/setup-jsdom.js test/**/*_test.js" | |||
"test": "cross-env NODE_ENV=test mocha --compilers js:babel-register --require ./test/setup-jsdom.js test/**/*_test.js", | |||
"test_ObjectField": "cross-env NODE_ENV=test mocha --compilers js:babel-register --require ./test/setup-jsdom.js test/**/ObjectField_test.js" |
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 think you can remove this from package.json
@@ -381,4 +382,76 @@ describe("ObjectField", () => { | |||
expect(node.querySelector("#title-")).to.be.null; | |||
}); | |||
}); | |||
|
|||
describe.only("schema generation for dependencies", () => { |
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.
Please remove this describe.only
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.
To replace it by a describe
const definitions = {}; | ||
const formData = { a: { c: 1234 } }; | ||
let result = retrieveSchema(schema, definitions, formData); | ||
console.log(toIdSchema(result, null, definitions, formData)); |
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.
Please remove the console.log in all your code
properties: { | ||
b: { type: "string" }, | ||
c: { type: "number" }, | ||
d: { type: "number" }, |
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.
Please update the expectation so that the test is passing with your fix.
@redixhumayun I mean a test that would fail without your fix, but with your fix, it should pass (regression test).
|
@redixhumayun Hey, are you going to work on the PR any further? I need this fix and it doesn't look like much more needs to be done to get this over the line. I don't mind doing them myself in a new PR if needs be. |
@Alligator I think you can do the fix in a new MR. |
@edi9999 Hi, sorry I completely forgot about this. My apologies. If @Alligator is not going to be picking this up, I don't mind completing this. I just need to remove the failing test case. Let me know. |
@redixhumayun Do you plan to complete this? |
Closing this -- and I believe #1320 may have already fixed the issue that this PR was initially meant to address? Is that right, @redixhumayun ? |
Reasons for making this change
A new idSchema needs to be generated in the ObjectField.js file, because the retrieveSchema function does not resolve nested dependencies further than one level deep in the JSON object.
Checklist
npm run cs-format
on my branch to conform my code to prettier coding style