Skip to content

Conversation

@rjrudin
Copy link
Contributor

@rjrudin rjrudin commented Oct 10, 2025

Simplifying nodejs-optic-nodes - it doesn't need to do XML documents, we have other tests for that. Hoping this avoids the mysterious 500 error.

Then had Copilot fix the other two tests where they were failing with a message of "done called multiple times".

Copilot AI review requested due to automatic review settings October 10, 2025 15:12
Copy link

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 fixes failing tests by simplifying the nodejs-optic-nodes test to remove XML document testing and addressing "done called multiple times" errors in two other tests.

  • Simplified nodejs-optic-nodes test by removing XML document construction and related assertions
  • Fixed "done called multiple times" error in nodejs-dmsdk-removeAllUris test by adding error handling
  • Fixed "done called multiple times" error in nodejs-dmsdk-queryToTransformAll test by removing done() call from onBatchSuccess callback

Reviewed Changes

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

File Description
test-complete/nodejs-optic-nodes.js Removed XML document testing code and related assertions to simplify test
test-complete/nodejs-dmsdk-removeAllUris.js Added error handling to prevent multiple done() calls
test-complete/nodejs-dmsdk-queryToTransformAll.js Removed done() call from onBatchSuccess to prevent multiple calls
CONTRIBUTING.md Added documentation about test-complete folder tests

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines +59 to 61
console.log(JSON.stringify(output, null, 2));
expect(output.columns[1].name).to.equal('myJSON');
expect(output.columns[1].type).to.equal('object');
Copy link

Copilot AI Oct 10, 2025

Choose a reason for hiding this comment

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

Debug console.log statement should be removed before merging to production code.

Suggested change
console.log(JSON.stringify(output, null, 2));
expect(output.columns[1].name).to.equal('myJSON');
expect(output.columns[1].type).to.equal('object');
expect(output.columns[1].name).to.equal('myJSON');
expect(output.columns[1].type).to.equal('object');
expect(output.columns[1].type).to.equal('object');

Copilot uses AI. Check for mistakes.
@github-actions
Copy link

github-actions bot commented Oct 10, 2025

Copyright Validation Results
Total: 3 | Passed: 2 | Failed: 0 | Skipped: 1 | at: 2025-10-10 18:35:55 UTC | commit: 83aa6bc

⏭️ Skipped (Excluded) Files

  • CONTRIBUTING.md

✅ Valid Files

  • lib/responder.js
  • test-complete/nodejs-optic-nodes.js

✅ All files have valid copyright headers!

@rjrudin rjrudin marked this pull request as draft October 10, 2025 15:19
progress.docsFailedToBeTransformed.should.be.equal(0);
progress.timeElapsed.should.be.greaterThanOrEqual(0);
}),
onCompletion: ((summary) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

done is called here only in case of exception. The purpose of adding a try block is so that whenever something goes wrong here, it does not show timeout.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is in regards to this intermittent error:

image

Copilot's reasoning was that "done()" would be called multiple times if assertions failed in 2 or more batches. Instead, the assertion errors should bubble up automatically , and onCompletion will handle calling "done()".

});
}).catch(done);

});
Copy link
Contributor

Choose a reason for hiding this comment

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

We don't need to catch done. I know there are a lot of tests with this statement but I don't see much use.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copilot added it - here's it's reasoning:

Purpose of .catch(done) on line 47

The .catch(done) serves as a safety net for the beforeEach hook to handle errors that occur in the writeAll() method itself (not just the write operation).

Two-layer error handling:

  1. Primary: onCompletion callback handles errors during the write operation (via summary.error)
  2. Secondary: .catch(done) handles errors from the writeAll() method itself

Without .catch(done), these scenarios would cause the test to hang:

  • MarkLogic server connection failures
  • Authentication errors
  • Network timeouts
  • Malformed requests that throw immediately

This prevents the "done() called multiple times" issue by ensuring:

  • Only one error path calls done()
  • Proper test failure instead of indefinite hanging
  • Robust error handling for Jenkins environment differences

This is a standard pattern for async Mocha tests - always include .catch(done) to handle promise rejections outside of your main success/error logic.

@rjrudin rjrudin force-pushed the feature/construct-json-test branch from f3e992a to 898d70e Compare October 10, 2025 16:17
Simplifying nodejs-optic-nodes - it doesn't need to do XML documents, we have other tests for that. Hoping this avoids the mysterious 500 error.

Then had Copilot fix the other two tests where they were failing with a message of "done called multiple times".

Adding 500 response body to error message
@rjrudin rjrudin force-pushed the feature/construct-json-test branch from 898d70e to 85a29a0 Compare October 10, 2025 17:12
And undoing a couple test changes that didn't seem to help.
@rjrudin rjrudin force-pushed the feature/construct-json-test branch from 85a29a0 to 4c2a846 Compare October 10, 2025 17:27
@rjrudin
Copy link
Contributor Author

rjrudin commented Oct 13, 2025

Closing this. Going to simplify it down with a change to responder to include the request body for a 500.

@rjrudin rjrudin closed this Oct 13, 2025
@rjrudin rjrudin deleted the feature/construct-json-test branch October 13, 2025 20:59
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.

3 participants