Skip to content

MLE-24194 Fixing checkConnection and better tests#1036

Merged
rjrudin merged 1 commit intodevelopfrom
feature/testing-3
Nov 20, 2025
Merged

MLE-24194 Fixing checkConnection and better tests#1036
rjrudin merged 1 commit intodevelopfrom
feature/testing-3

Conversation

@rjrudin
Copy link
Contributor

@rjrudin rjrudin commented Nov 20, 2025

This was way harder than it should have been, but Copilot finally got it done. checkConnection had the wrong return type, so the method didn't actually working in a "real" TS test - and we now have a "real" TS test. See the Copilot-authored README for explanation.

Copilot AI review requested due to automatic review settings November 20, 2025 18:29
@github-actions
Copy link

github-actions bot commented Nov 20, 2025

Copyright Validation Results
Total: 15 | Passed: 7 | Failed: 0 | Skipped: 8 | at: 2025-11-20 19:52:33 UTC | commit: 77a1a2c

⏭️ Skipped (Excluded) Files

  • .gitignore
  • Jenkinsfile
  • package-lock.json
  • package.json
  • test-typescript/README.md
  • tsconfig.json
  • typescript-test-project/package.json
  • typescript-test-project/tsconfig.json

✅ Valid Files

  • lib/responder.js
  • marklogic.d.ts
  • test-typescript/checkConnection-runtime.test.ts
  • test-typescript/connection-methods.test.ts
  • test-typescript/error-examples.test.ts
  • test-typescript/type-constraints.test.ts
  • typescript-test-project/test.ts

✅ All files have valid copyright headers!

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 a critical bug in the checkConnection method's TypeScript return type and adds comprehensive runtime testing. The method was incorrectly typed to return ConnectionCheckResult directly instead of ResultProvider<ConnectionCheckResult>, causing it to fail in actual TypeScript code that needed to call .result() to get the promise.

Key changes:

  • Fixed TypeScript definition for checkConnection to return ResultProvider<ConnectionCheckResult>
  • Added runtime test suite to validate TypeScript definitions match actual JavaScript behavior
  • Updated test infrastructure to support both compile-only and runtime TypeScript tests

Reviewed Changes

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

Show a summary per file
File Description
test-typescript/checkConnection-runtime.test.ts New comprehensive runtime test validating checkConnection returns ResultProvider with proper type safety
test-typescript/README.md Enhanced documentation explaining the dual approach of compile-only vs runtime TypeScript tests
typescript-test-project/test.ts Simplified to realistic usage pattern, correctly calling .result() on checkConnection
typescript-test-project/tsconfig.json Enabled compilation output for runtime execution of the test project
typescript-test-project/package.json Added scripts to build and run the TypeScript test project
package.json Added test:compile script and @types/mocha dependency for runtime TypeScript tests
lib/responder.js Added null check for connectionParams before accessing apiKey property
Jenkinsfile Integrated new TypeScript runtime tests into CI pipeline across all MarkLogic versions

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

package.json Outdated
"lint": "gulp lint",
"test:types": "tsc --noEmit"
"test:types": "tsc --noEmit",
"test:compile": "tsc test-typescript/checkConnection-runtime.test.ts --outDir test-typescript --module commonjs --target ES2020 --esModuleInterop --skipLibCheck",
Copy link

Copilot AI Nov 20, 2025

Choose a reason for hiding this comment

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

The long inline TypeScript compilation command is difficult to maintain. Consider moving these compiler options to a dedicated tsconfig file (e.g., test-typescript/tsconfig.json) and simplifying the script to 'tsc -p test-typescript', which would be more maintainable and consistent with standard TypeScript project structure.

Suggested change
"test:compile": "tsc test-typescript/checkConnection-runtime.test.ts --outDir test-typescript --module commonjs --target ES2020 --esModuleInterop --skipLibCheck",
"test:compile": "tsc -p test-typescript",

Copilot uses AI. Check for mistakes.
@rjrudin rjrudin force-pushed the feature/testing-3 branch 2 times, most recently from d990dd4 to 243e6ba Compare November 20, 2025 18:59
This was way harder than it should have been, but Copilot finally got it done. checkConnection had the wrong return type, so the method didn't actually working in a "real" TS test - and we now have a "real" TS test. See the Copilot-authored README for explanation.
@rjrudin rjrudin merged commit 74264b0 into develop Nov 20, 2025
5 of 6 checks passed
@rjrudin rjrudin deleted the feature/testing-3 branch November 20, 2025 20:43
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.

1 participant