Skip to content
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

Closed
wants to merge 8 commits into from

Conversation

redixhumayun
Copy link
Contributor

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

  • I'm updating documentation
    • I've checked the rendering of the Markdown text I've added
    • If I'm adding a new section, I've updated the Table of Content
  • I'm adding or updating code
    • I've added and/or updated tests
    • I've updated docs if needed
    • [X ] I've run npm run cs-format on my branch to conform my code to prettier coding style
  • I'm adding a new feature
    • I've updated the playground with an example use of the feature

@redixhumayun
Copy link
Contributor Author

@edi9999 @jonathonlui Hi, any updates on this?

definitions,
formData,
idSchema["$id"]
);
Copy link
Collaborator

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 ?

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.

Copy link
Contributor Author

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.

@jamesdebolt
Copy link

jamesdebolt commented Apr 4, 2018

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

@edi9999
Copy link
Collaborator

edi9999 commented Apr 5, 2018

@jamesdebolt
Copy link

@redixhumayun Can you check out why the test is failing? Thanks everyone for their work here!

@redixhumayun
Copy link
Contributor Author

@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
Is this ready to be accepted and merged?

@@ -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"
Copy link
Collaborator

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", () => {
Copy link
Collaborator

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

Copy link
Collaborator

@edi9999 edi9999 Apr 6, 2018

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));
Copy link
Collaborator

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" },
Copy link
Collaborator

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.

@edi9999
Copy link
Collaborator

edi9999 commented Apr 6, 2018

@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
Is this ready to be accepted and merged?

@redixhumayun I mean a test that would fail without your fix, but with your fix, it should pass (regression test).
The process I usually follow to write these kind of tests is as follows :

  1. I have a bug, which I am trying to understand, leading to bad behavior
  2. I write a test that fails with the current version of the code (I didn't modify the source code yet). This test describes the correct behavior.
  3. I fix the given bug, and verify that the test that I added now succeeds.

@Alligator
Copy link

@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.

@edi9999
Copy link
Collaborator

edi9999 commented Aug 7, 2018

@Alligator I think you can do the fix in a new MR.

@redixhumayun
Copy link
Contributor Author

@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.

@epicfaace
Copy link
Member

@redixhumayun Do you plan to complete this?

@epicfaace
Copy link
Member

Closing this -- and I believe #1320 may have already fixed the issue that this PR was initially meant to address? Is that right, @redixhumayun ?

@epicfaace epicfaace closed this Aug 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants