Conversation
- Added `tests/unit/helpers.test.ts` to test `getUriParts`. - Created `tests/mocks/vscode.ts` to mock VS Code API for tests. - Created `tsconfig.test.json` to configure path mapping for tests. - Updated `package.json` to use `tsconfig.test.json` for tests. - Fixed `src/platform/cryptoShim.ts` to use optional chaining for `import.meta.env` to prevent crashes in Node.js test environment. Co-authored-by: zknpr <96851588+zknpr@users.noreply.github.com>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Summary of ChangesHello @zknpr, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly improves the testing landscape by introducing new unit tests for the Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request adds valuable unit tests for the getUriParts utility, which is a great improvement for code quality and maintainability. The setup of a dedicated test configuration and the fix for the runtime crash in cryptoShim.ts are also excellent additions. My review focuses on a correctness issue in getUriParts that the new tests have helped uncover, and some improvements to the new vscode mock to make it more robust for future testing.
| it('should parse simple file path URI', () => { | ||
| const uri = vsc.Uri.file('/home/user/test.txt'); | ||
| const parts = getUriParts(uri); | ||
| assert.strictEqual(parts.dirname, 'file:///home/user/'); // Regex matches from uri.toString() which returns file://... |
There was a problem hiding this comment.
This test reveals a correctness issue with the getUriParts implementation. The function's documentation states it "Extract[s] path components from a URI", but as your test and comment correctly note, it includes the URI scheme (file://) in the dirname when passed a vscode.Uri object. This is because it operates on uri.toString() instead of the uri.path property, which can lead to unexpected behavior.
To fix this, getUriParts should be modified to use the .path property when it receives a vscode.Uri object.
Here is a suggested change for src/helpers.ts:
export function getUriParts(uri: string | vsc.Uri): { /* ... */ } {
const pathString = typeof uri === 'string' ? uri : uri.path;
const match = pathString.match(uriPathPattern);
// ... the rest of the function
}With this change in getUriParts, this test assertion should be updated to expect '/home/user/'.
| parse: (value: string) => ({ | ||
| toString: () => value, | ||
| path: value, | ||
| scheme: 'file' | ||
| }), |
There was a problem hiding this comment.
The path property in this mock for Uri.parse is incorrect. It returns the entire URI string, whereas it should return only the path component. For example, for a URI file:///foo/bar.txt, path should be /foo/bar.txt.
This is inconsistent with the file() mock and could cause issues in future tests that rely on uri.path. This becomes more important if getUriParts is changed to use uri.path as suggested in another comment.
Consider making the mock more accurate to prevent future issues.
| parse: (value: string) => ({ | |
| toString: () => value, | |
| path: value, | |
| scheme: 'file' | |
| }), | |
| parse: (value: string) => ({ | |
| toString: () => value, | |
| path: value.startsWith('file://') ? new URL(value).pathname : value, | |
| scheme: 'file' | |
| }), |
| file: (path: string) => ({ | ||
| toString: () => `file://${path}`, | ||
| path, | ||
| scheme: 'file' | ||
| }) |
There was a problem hiding this comment.
This mock for Uri.file doesn't handle Windows paths correctly. For a path like C:\\Users\\test.txt, toString() would produce file://C:\\Users\\test.txt, which is not a valid URI. A valid file URI for a Windows path should look like file:///C:/Users/test.txt.
While the current tests only use POSIX-style paths, making the mock cross-platform compatible would make it more robust for future tests.
file: (path: string) => {
// Handle Windows paths to create valid file URIs.
const posixPath = path.replace(/\\/g, '/');
const uriPath = /^[a-zA-Z]:\//.test(posixPath) ? `/${posixPath}` : posixPath;
return {
toString: () => `file://${uriPath}`,
path: uriPath,
scheme: 'file'
};
}|
Merged as part of v1.3.0 release in PR #65 |
Acknowledged. Thank you for the update. I am glad the changes are merged. |
Improved testing for
getUriPartsinsrc/helpers.ts.Changes:
vscodemodule without affecting the main build.cryptoShim.tswhen running in Node.js environment.PR created automatically by Jules for task 3659151931186356262 started by @zknpr