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

chore: add tests for query params #430

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

maxdeichmann
Copy link
Member

@maxdeichmann maxdeichmann commented Oct 9, 2024

Important

Add tests and modify encodeQueryParams to handle special characters and arrays, and comment out a test in langfuse-integration-node.spec.ts.

  • Tests:
    • Add tests for encodeQueryParams in utils.spec.ts to handle special characters, arrays, and null/undefined values.
  • Functions:
    • Modify encodeQueryParams in utils.ts to encode special characters and arrays correctly.
  • Misc:
    • Comment out create span test in langfuse-integration-node.spec.ts.

This description was created by Ellipsis for dfedb37. It will automatically update as commits are pushed.

Copy link

vercel bot commented Oct 9, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
langfuse-js ✅ Ready (Inspect) Visit Preview Oct 9, 2024 0:21am

Copy link

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

❌ Changes requested. Reviewed everything up to 9a6ea8a in 22 seconds

More details
  • Looked at 160 lines of code in 3 files
  • Skipped 0 files when reviewing.
  • Skipped posting 1 drafted comments based on config settings.
1. langfuse-core/src/utils.ts:116
  • Draft comment:
    Consider encoding array values in a way that is compatible with your API, such as using multiple key-value pairs for each element or a different delimiter.
  • Reason this comment was not posted:
    Comment was on unchanged code.

Workflow ID: wflow_AlpN9hwJWWgTksAo


Want Ellipsis to fix these issues? Tag @ellipsis-dev in a comment. You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

traceId: trace.id,
version: null,
});
it.only("create span", async () => {
Copy link

Choose a reason for hiding this comment

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

Remove it.only to ensure all tests run.

Copy link

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

👍 Looks good to me! Incremental review on dfedb37 in 18 seconds

More details
  • Looked at 74 lines of code in 1 files
  • Skipped 0 files when reviewing.
  • Skipped posting 1 drafted comments based on config settings.
1. integration-test/langfuse-integration-node.spec.ts:117
  • Draft comment:
    The test case 'create span' is duplicated. Consider removing the commented-out version to avoid confusion.
  • Reason this comment was not posted:
    Decided after close inspection that this draft comment was likely wrong and/or not actionable:
    The comment is relevant because it addresses a change in the diff where a test case was uncommented and modified. The suggestion to remove the commented-out version is actionable and clear, as it helps maintain code clarity by removing unnecessary commented-out code.
    The comment might be considered unnecessary if the commented-out code is already removed in the diff, making the suggestion redundant.
    The comment is still useful as it highlights the importance of removing commented-out code to avoid confusion, even if it was already addressed in the diff.
    Keep the comment as it provides a clear and actionable suggestion related to the changes made in the diff.

Workflow ID: wflow_YcULl8vjgJ6ih7LT


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

Disclaimer: Experimental PR review

PR Summary

This pull request refactors the query parameter encoding and adds corresponding tests, with a focus on improving array handling in the Langfuse Node.js SDK.

  • Refactored encodeQueryParams function in langfuse-core/src/utils.ts for better array support and security
  • Added new tests in langfuse-core/test/utils.spec.ts to verify query parameter encoding, including arrays and special characters
  • Modified 'create span' test in integration-test/langfuse-integration-node.spec.ts to fetch traces with specific tags (temporary change)
  • Improved encoding of both keys and values using encodeURIComponent for enhanced security and compatibility

3 file(s) reviewed, 2 comment(s)
Edit PR Review Bot Settings

Comment on lines +122 to +123
value instanceof Date ? encodeURIComponent(value.toISOString()) : encodeURIComponent(value.toString());
return `${encodedKey}=${encodedValue}`;
Copy link

Choose a reason for hiding this comment

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

logic: This doesn't handle array values correctly. Arrays will be converted to strings, potentially losing data. Consider adding specific array handling.

Comment on lines +46 to +58
describe("encodeQueryParams", () => {
it("should encode query parameters correctly", () => {
const params = {
name: "John Doe",
age: 30,
active: true,
date: new Date("2022-01-01T00:00:00.000Z"),
empty: null,
undefinedValue: undefined,
};
const expected = "name=John%20Doe&age=30&active=true&date=2022-01-01T00%3A00%3A00.000Z";
expect(encodeQueryParams(params)).toEqual(expected);
});
Copy link

Choose a reason for hiding this comment

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

logic: Test case doesn't check handling of null and undefined values

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