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

Add test and improve loopback link #301

Merged
merged 10 commits into from
Mar 7, 2025
Merged

Add test and improve loopback link #301

merged 10 commits into from
Mar 7, 2025

Conversation

openint-bot
Copy link
Collaborator

@openint-bot openint-bot commented Mar 6, 2025

Important

Add tests for loopback link, refactor server utilities, update dependencies, and improve test configurations.

  • Tests:
    • Add index.test.ts in dev-packages/loopback-link to test loopback link functionality with Elysia and server-utils.
    • Add elysia.test.ts in packages/api-v1/__tests__ to test Elysia server handling.
    • Update migration.spec.ts and rls.spec.ts in packages/db/__tests__ to improve database migration and RLS testing.
  • Server Utilities:
    • Add server-utils.ts in dev-packages/loopback-link for server handling with serverFromHandler and serverFromElysia functions.
    • Refactor loopbackLink in index.ts to use serverFromHandler for server management.
  • Package Updates:
    • Remove @types/jest from kits/file-picker/package.json.
    • Add elysia as a devDependency in dev-packages/loopback-link/package.json.
    • Update test scripts in package.json to use bun for testing.
  • Miscellaneous:
    • Rename neon.test.ts to neon.spec.ts and sql-generation.spec.ts to sql-generation.test.ts in packages/db/__tests__.
    • Add runtime detection utility in packages/util/__tests__/test-utils.ts.

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

Copy link

vercel bot commented Mar 6, 2025

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

Name Status Preview Comments Updated (UTC)
openint ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 7, 2025 3:16am

applyLinks(req, [
loopbackLink(),
async (req) =>
new Response(await req.text(), {
Copy link

Choose a reason for hiding this comment

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

Calling req.text() consumes the request body stream, which means it can only be read once. Since this is an intermediary handler in a chain (via applyLinks), consuming the body here will prevent downstream handlers from accessing the request body. Should consider cloning the request before reading the body or pass the body through differently.


React with 👍 to tell me that this comment was useful, or 👎 if not (and I'll stop posting more comments like this in the future)

Copy link

recurseml bot commented Mar 6, 2025

😱 Found 1 issue. Time to roll up your sleeves! 😱

@openint-bot openint-bot marked this pull request as ready for review March 7, 2025 03:01
@openint-bot openint-bot changed the title Add test for loopback link Add test and improve loopback link Mar 7, 2025
Copy link
Contributor

@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 807cf2f in 2 minutes and 53 seconds

More details
  • Looked at 549 lines of code in 9 files
  • Skipped 1 files when reviewing.
  • Skipped posting 14 drafted comments based on config settings.
1. dev-packages/loopback-link/index.test.ts:17
  • Draft comment:
    Tests cover both server setups well. Consider adding error case tests for failures.
  • Reason this comment was not posted:
    Confidence changes required: 33% <= threshold 50%
    None
2. dev-packages/loopback-link/index.ts:15
  • Draft comment:
    Good use of startIfNeeded and cleanup with stop. Consider adding error handling if starting the server fails.
  • Reason this comment was not posted:
    Confidence changes required: 33% <= threshold 50%
    None
3. dev-packages/loopback-link/server-utils.ts:6
  • Draft comment:
    nodeRequestToWebRequest assumes req.url is defined. Consider a fallback if url is undefined.
  • Reason this comment was not posted:
    Decided after close inspection that this draft comment was likely wrong and/or not actionable: usefulness confidence = 10% vs. threshold = 50%
    The IncomingMessage type from Node.js guarantees that url will be present. Even for malformed requests, it will be at least '/'. The suggestion is trying to solve a problem that doesn't exist. The current code is correct as is.
    I could be wrong about the Node.js types - maybe there are edge cases where url is undefined that I'm not aware of.
    The Node.js documentation and types are clear that url is a required property. Even if there were edge cases, the server would return a 500 error which is appropriate for malformed requests.
    The comment should be deleted as it suggests adding unnecessary defensive code for a scenario that cannot occur.
4. packages/api-v1/__tests__/elysia.test.ts:65
  • Draft comment:
    Typo in test description: 'listen on random random port' - remove duplicated word.
  • Reason this comment was not posted:
    Decided after close inspection that this draft comment was likely wrong and/or not actionable: usefulness confidence = 10% vs. threshold = 50%
    While the comment is technically correct about the typo, fixing test descriptions is a very minor issue that doesn't affect functionality. The rules specifically state not to make comments that are obvious or unimportant. A duplicate word in a test description falls into this category - it's something the author can easily spot and fix themselves if they care to.
    The typo could potentially make the test description confusing to future readers. Clear test descriptions are important for maintainability.
    While clear test descriptions are good, this particular typo is obvious enough that it doesn't significantly impact readability, and pointing it out creates unnecessary review noise.
    Delete the comment as it violates the rule about not making obvious or unimportant comments. The typo is minor and doesn't affect code functionality.
5. packages/util/__tests__/test-utils.ts:1
  • Draft comment:
    Test utilities are implemented correctly. ESLint directives are appropriate.
  • Reason this comment was not posted:
    Confidence changes required: 0% <= threshold 50%
    None
6. dev-packages/loopback-link/index.test.ts:22
  • Draft comment:
    Potential resource leak: the server started with startIfNeeded() is never stopped. Consider calling server.stop() after the test to free resources.
  • Reason this comment was not posted:
    Marked as duplicate.
7. dev-packages/loopback-link/package.json:3
  • Draft comment:
    The package version is set to 0.0.0; ensure you bump the version before release if this is not intentional.
  • Reason this comment was not posted:
    Confidence changes required: 33% <= threshold 50%
    None
8. dev-packages/loopback-link/server-utils.ts:75
  • Draft comment:
    startIfNeeded caches the promise; note that if a different port is provided in a subsequent call, it will be ignored. Consider documenting or handling this behavior.
  • Reason this comment was not posted:
    Decided after close inspection that this draft comment was likely wrong and/or not actionable: usefulness confidence = 20% vs. threshold = 50%
    This is a legitimate observation about the behavior of the code. The caching of startPromise means only the first port value will be used. However, this appears to be intentional design - the server should only be started once, and the port should not change after that. The behavior is consistent with the function name "startIfNeeded" which implies it's meant to ensure single initialization.
    The behavior could be surprising to users who expect the port parameter to always be respected. The function name doesn't clearly indicate the port parameter will be ignored after first call.
    While the behavior could be surprising, it's a common pattern for ensuring singleton initialization. The function name "startIfNeeded" implies it's about initialization state, not configuration.
    The comment should be deleted. The behavior appears to be intentional design rather than a bug or issue that needs fixing.
9. dev-packages/loopback-link/server-utils.ts:50
  • Draft comment:
    Consider a more robust error handling strategy instead of simply logging errors with console.error.
  • Reason this comment was not posted:
    Confidence changes required: 33% <= threshold 50%
    None
10. packages/api-v1/__tests__/elysia.test.ts:65
  • Draft comment:
    Typo in test title: 'listen on random random port'—consider renaming to 'listen on random port and handle request'.
  • Reason this comment was not posted:
    Decided after close inspection that this draft comment was likely wrong and/or not actionable: usefulness confidence = 10% vs. threshold = 50%
    While the comment is technically correct about the typo, test names are primarily for developer readability and documentation. The duplicate "random" is a minor issue that doesn't affect functionality. According to the rules, we should not make purely informative comments or point out obvious/unimportant issues.
    The typo could make the test slightly harder to read and understand at first glance. Test names are part of documentation.
    However, the meaning is still clear despite the typo, and this is exactly the kind of nitpicky comment that the rules tell us to avoid. It's not pointing out a functional issue or suggesting an important code quality improvement.
    We should delete this comment as it's purely cosmetic and doesn't affect functionality or code quality in a meaningful way.
11. packages/api-v1/__tests__/elysia.test.ts:22
  • Draft comment:
    The test for POST to /test diverges based on runtime. Ensure this conditional behavior (expecting a 500 error on Node and 200 on others) is intentional and well-documented.
  • Reason this comment was not posted:
    Decided after close inspection that this draft comment was likely wrong and/or not actionable: usefulness confidence = 10% vs. threshold = 50%
    The code already clearly documents the different runtime behaviors. The test name and inline comments show this is intentional. The comment violates the rule about not asking authors to verify their intentions. The divergent behavior is being tested on purpose as part of the test suite.
    Maybe there's a real bug here that needs to be fixed rather than just documented? The error message about GET/HEAD methods seems strange for a POST request.
    While there might be an underlying issue, that's not what the comment is addressing - it's just asking for verification of intended behavior that's already clearly documented.
    Delete the comment as it violates the rule about asking authors to verify their intentions, and the runtime differences are already well-documented in the code.
12. packages/util/__tests__/test-utils.ts:28
  • Draft comment:
    Consider consolidating the multiple eslint-disable directives into a single block for cleaner configuration.
  • Reason this comment was not posted:
    Confidence changes required: 33% <= threshold 50%
    None
13. packages/api-v1/__tests__/elysia.test.ts:65
  • Draft comment:
    Typo in test name: 'listen on random random port and handling request'. Consider removing the duplicate 'random' to keep the test description clear.
  • Reason this comment was not posted:
    Decided after close inspection that this draft comment was likely wrong and/or not actionable: usefulness confidence = 10% vs. threshold = 50%
    While the typo is real (random appears twice), this is a very minor issue. Test names are primarily for developer readability and documentation. The duplicate word doesn't impact functionality or cause confusion about the test's purpose. According to the rules, we should not make comments that are obvious or unimportant.
    The typo could potentially make the test documentation slightly less professional. It's a real issue that would be easy to fix.
    However, this is exactly the kind of minor, non-functional nitpick that the rules tell us to avoid. The meaning is still clear despite the typo.
    This comment should be deleted as it's too minor and doesn't impact code functionality or clarity in any meaningful way.
14. packages/db/__tests__/neon.spec.ts:18
  • Draft comment:
    Typographical error: In the comment on line 18, the import string is missing a closing quote. It currently reads await import('ws); please update it to await import('ws') to fix the typo.
  • Reason this comment was not posted:
    Comment was not on a location in the diff, so it can't be submitted as a review comment.

Workflow ID: wflow_uGTha98XGR1XJ7ca


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.

async (req, next) => {
const server = await serveAsync(next, opts)
const server = serverFromHandler(next)
await server.startIfNeeded(opts?.port)
const res = await fetch(
Copy link
Contributor

Choose a reason for hiding this comment

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

Wrap the fetch call in a try...finally block to ensure server.stop() is called even if fetch throws an error.

Copy link
Contributor

@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 0342948 in 1 minute and 26 seconds

More details
  • Looked at 125 lines of code in 5 files
  • Skipped 1 files when reviewing.
  • Skipped posting 12 drafted comments based on config settings.
1. dev-packages/loopback-link/index.test.ts:31
  • Draft comment:
    Consider using a try-finally block to ensure the server is stopped even if the test fails.
  • Reason this comment was not posted:
    Comment was not on a location in the diff, so it can't be submitted as a review comment.
2. kits/file-picker/package.json:72
  • Draft comment:
    Removal of @types/jest: verify that the dependency is truly unneeded or moved to a global config.
  • Reason this comment was not posted:
    Confidence changes required: 50% <= threshold 50%
    None
3. packages/db/__tests__/migration.spec.ts:6
  • Draft comment:
    Added comment regarding Bun’s slower performance; ensure this comment stays relevant if environments change.
  • Reason this comment was not posted:
    Confidence changes required: 0% <= threshold 50%
    None
4. packages/db/__tests__/rls.spec.ts:8
  • Draft comment:
    SQL formatting improvements improve readability; verify SQL statements still align with intended logic.
  • Reason this comment was not posted:
    Confidence changes required: 0% <= threshold 50%
    None
5. packages/db/__tests__/test-utils.ts:2
  • Draft comment:
    Explicitly importing Jest globals is good for clarity; ensure no duplicate imports exist elsewhere.
  • Reason this comment was not posted:
    Confidence changes required: 0% <= threshold 50%
    None
6. dev-packages/loopback-link/index.test.ts:31
  • Draft comment:
    Good cleanup—stopping the server after the test prevents resource leakage. Consider using an afterAll hook if more tests are added in the future.
  • Reason this comment was not posted:
    Decided after close inspection that this draft comment was likely wrong and/or not actionable: usefulness confidence = 20% vs. threshold = 50%
    The comment suggests a future improvement that isn't currently needed. Only one test uses the server, and it's already being cleaned up properly. The suggestion would only become relevant if more tests using the server are added later. Making speculative suggestions about future code changes violates our review rules.
    The comment does point out a valid pattern for test cleanup that could be useful if more server tests are added. Maybe this is good documentation for future developers?
    While the pattern is valid, our rules explicitly state not to make speculative comments about future changes. The current code handles cleanup correctly for its current needs.
    Delete the comment. It makes a speculative suggestion about future code changes that aren't currently needed, and the current cleanup approach is correct.
7. kits/file-picker/package.json:72
  • Draft comment:
    Ensure removal of '@types/jest' is intentional. Verify that Jest’s global types are provided elsewhere to prevent type errors in tests.
  • Reason this comment was not posted:
    Decided after close inspection that this draft comment was likely wrong and/or not actionable: usefulness confidence = 10% vs. threshold = 50%
    This comment violates several rules. It asks to "ensure" and "verify" something, which is explicitly against our rules. It's also about TypeScript types which would cause immediate build failures if there were issues. The presence of ts-jest suggests type definitions are likely handled automatically.
    Maybe there's a specific reason they need @types/jest that isn't covered by ts-jest or @testing-library/jest-dom? Could there be a subtle typing issue that won't be caught immediately?
    Even if there were typing issues, they would be immediately apparent when running tests or typechecking. The project has both "test" and "typecheck" scripts that would catch any problems.
    Delete this comment. It asks for verification rather than pointing out a concrete issue, and any real problems would be caught by the build system.
8. packages/db/__tests__/migration.spec.ts:6
  • Draft comment:
    The added comment clarifying that 'Bun' runs slower than Jest improves context. This helps in understanding test performance variations.
  • Reason this comment was not posted:
    Confidence changes required: 10% <= threshold 50%
    None
9. packages/db/__tests__/rls.spec.ts:5
  • Draft comment:
    Improved SQL query formatting enhances readability. Double-check that the adjusted indentation doesn't affect SQL parsing.
  • Reason this comment was not posted:
    Confidence changes required: 10% <= threshold 50%
    None
10. packages/db/__tests__/test-utils.ts:2
  • Draft comment:
    Explicitly importing jest globals improves clarity about the test environment; ensure consistency across all test files.
  • Reason this comment was not posted:
    Confidence changes required: 10% <= threshold 50%
    None
11. kits/file-picker/package.json:4
  • Draft comment:
    Typographical error: Consider changing "Sharepoint" to "SharePoint" and "One Drive" to "OneDrive" in the description to align with the official spellings.
  • Reason this comment was not posted:
    Comment was not on a location in the diff, so it can't be submitted as a review comment.
12. packages/db/__tests__/test-utils.ts:19
  • Draft comment:
    There's a duplicated 'and' in the comment on lines 19-20. Consider removing one 'and' to improve clarity.
  • Reason this comment was not posted:
    Comment was not on a location in the diff, so it can't be submitted as a review comment.

Workflow ID: wflow_0RFTFT9N17yJHH3H


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

@openint-bot openint-bot merged commit 6467ab5 into main Mar 7, 2025
4 checks passed
@openint-bot openint-bot deleted the loopback-better branch March 7, 2025 03:23
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