Skip to content

Conversation

@leonelsanchesdasilva
Copy link
Collaborator

No description provided.

@github-actions
Copy link

github-actions bot commented Jan 23, 2026

Coverage report

St.
Category Percentage Covered / Total
🟡 Statements
76.42% (+0.01% 🔼)
2437/3189
🟡 Branches 65.26% 1317/2018
🟡 Functions 74.09% 326/440
🟡 Lines
76.8% (+0.01% 🔼)
2304/3000

Test suite run success

578 tests passing in 44 suites.

Report generated by 🧪jest coverage report action from 859688d

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the XSLT 3.0 xml-to-json() / json-to-xml() support and aligns behavior and tests with the intended version restrictions and library behavior.

Changes:

  • Tightens xml-to-json() and json-to-xml() version checks so they are only allowed when xsltVersion === '3.0', with updated error messages and new XSLT 2.0 tests.
  • Adjusts json-to-xml() to return null in failure cases and refactors convertXPathNodeToXNode to lazily require DOM-related classes/constants.
  • Simplifies multiple json-to-xml tests from DOM-structure assertions to string includes checks and updates the xpath lib submodule pointer.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.

File Description
tests/xml/xml-to-json.test.tsx Updates error message expectations and adds XSLT 2.0 coverage for xml-to-json().
tests/json-to-xml.test.tsx Updates error expectations, adds XSLT 2.0 coverage, and simplifies many structural assertions to string checks.
src/xpath/xpath.ts Adjusts version checks, changes json-to-xml() return semantics, and refactors node conversion to use lazy require for DOM-related types.
src/xpath/lib Bumps the xpath library submodule to a new commit.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +72 to +73
// Should contain a root element with text content "hello"
assert(outXmlString.includes('hello'));
Copy link

Copilot AI Jan 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test used to parse the output XML and assert on the actual DOM structure (root element presence and its text content), but it now only checks that the string "hello" appears somewhere in the serialized XML, which would still pass even if the structure or element name is wrong. To better protect behavior, consider restoring DOM-based checks (e.g., parse with xmlParser.xmlParse and assert the root element and its text node) or equivalent structural assertions rather than relying solely on includes.

Copilot uses AI. Check for mistakes.
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot open a new pull request to apply changes based on this feedback

Comment on lines +349 to +350
// Should convert property name to valid XML element (prefixed with underscore)
assert(outXmlString.includes('prop') || outXmlString.includes('_'));
Copy link

Copilot AI Jan 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The original test verified that the generated element name was a valid XML name (not starting with a digit) and that it contained the expected value; this assertion now only checks for the presence of the substring 'prop' or '_' anywhere in the output, which could be satisfied by unrelated content. To maintain confidence in the sanitization behavior, consider parsing the output and asserting on the actual element name (starts with a letter/underscore) and its text content rather than a loose substring check.

Copilot uses AI. Check for mistakes.
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot open a new pull request to apply changes based on this feedback

Copy link
Contributor

Copilot AI commented Jan 23, 2026

@leonelsanchesdasilva I've opened a new pull request, #155, to work on those changes. Once the pull request is ready, I'll request review from you.

Copy link
Contributor

Copilot AI commented Jan 23, 2026

@leonelsanchesdasilva I've opened a new pull request, #156, to work on those changes. Once the pull request is ready, I'll request review from you.

@leonelsanchesdasilva leonelsanchesdasilva merged commit ec95260 into main Jan 23, 2026
3 checks passed
@leonelsanchesdasilva leonelsanchesdasilva deleted the pr-150 branch January 23, 2026 21:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants