-
Notifications
You must be signed in to change notification settings - Fork 1
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
Fix buffershown test #27
Conversation
WalkthroughThe pull request introduces modifications to the Changes
Possibly related PRs
Suggested reviewers
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Outside diff range and nitpick comments (6)
denops/aider/mockAiderCommand.ts (2)
10-12
: Improved buffer handling, consider using a constant for the mock buffer name.The changes to obtain the current buffer number and set the buffer name look good. Using
"%"
to get the current buffer number is more flexible and aligns with Vim's conventions.Consider defining a constant for the mock buffer name (e.g.,
MOCK_AIDER_BUFFER_NAME = "mockaider"
) at the top of the file and using it here. This would make it easier to maintain and change the mock buffer name if needed in the future.+const MOCK_AIDER_BUFFER_NAME = "mockaider"; // ... later in the code ... -await denops.cmd("file mockaider"); // set buffer name +await denops.cmd(`file ${MOCK_AIDER_BUFFER_NAME}`); // set buffer name
17-19
: ImprovedsilentRun
implementation, consider adding a comment for clarity.The changes to
silentRun
look good. Using an arrow function maintains lexicalthis
, which is beneficial for consistency. Adding theenew
command ensures a new empty buffer is created before running the command, which should help address the test inconsistencies mentioned in the PR description.Consider adding a brief comment explaining the purpose of the
enew
command for future maintainers:silentRun: async (denops: Denops): Promise<undefined> => { - await denops.cmd("enew"); + await denops.cmd("enew"); // Create a new empty buffer await commands.run(denops); await denops.cmd("b#"); // hide buffer },tests/assertions.ts (1)
Line range hint
1-46
: Overall improvements to Aider buffer assertionsThe changes in this file significantly enhance the testing capabilities for Aider buffer-related functionality. The removal of "not working" comments from existing functions and the addition of the
assertAiderBufferString
function align well with the PR objectives of fixing buffer-related tests.To further improve the robustness of these assertions:
- Consider adding unit tests for these assertion functions themselves to ensure they behave correctly under various scenarios (e.g., empty buffers, multi-line content).
- Document any specific preconditions or assumptions these functions make about the state of the Denops environment or Aider buffer.
These improvements will contribute to a more maintainable and reliable test suite for the Aider functionality.
tests/aider_test.ts (3)
2-3
: Approve new imports and suggest removing unused import.The new imports for
assertAiderBufferHidden
andassertAiderBufferShown
are appropriate for the changes made in this PR. However, it appears thatassertAiderBufferAlive
is no longer used in this file.Consider removing the unused import:
import { assertAiderBufferHidden, assertAiderBufferShown, assertAiderBufferString, sleep } from "./assertions.ts"; - import { assertAiderBufferAlive } from "./assertions.ts";
29-30
: Approve change in assertion for "vsplit" AiderAddCurrentFile test.The update to the expected string in
assertAiderBufferString
is appropriate and consistent with the "floating" test case. This change improves the specificity of the test.Consider adding a comment to explain the expected behavior:
+ // Verify that the Aider buffer contains the expected input string after adding the current file await assertAiderBufferString(denops, "input: /add \n");
32-44
: Approve new test cases for AiderSilentRun and suggest creating an issue for the mentioned bug.The addition of test cases for AiderSilentRun in both "floating" and "vsplit" scenarios is a valuable improvement to the test coverage. These tests correctly verify that the Aider buffer is hidden after running AiderSilentRun.
The TODO comments mention a subtle bug when no buffer is open. To ensure this doesn't get overlooked, would you like me to create a GitHub issue to track this potential edge case? This will help in addressing the bug in a future update.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (3)
- denops/aider/mockAiderCommand.ts (1 hunks)
- tests/aider_test.ts (2 hunks)
- tests/assertions.ts (1 hunks)
🧰 Additional context used
🔇 Additional comments (7)
denops/aider/mockAiderCommand.ts (2)
14-14
: Correct update ofmockAiderBufnr
.This change ensures that the mock Aider buffer number is correctly updated after running the command. It's a small but important modification that helps maintain consistency in the mock implementation.
Line range hint
1-38
: Overall, the changes look good and address the PR objectives.The modifications to
mockAiderCommand.ts
improve buffer handling and should resolve the test inconsistencies mentioned in the PR description. The changes to therun
andsilentRun
methods are well-thought-out and align with best practices.A few minor suggestions were made for further improvement:
- Consider using a constant for the mock buffer name.
- Add a brief comment explaining the purpose of the
enew
command insilentRun
.These changes should enhance the maintainability of the code without affecting its functionality.
tests/assertions.ts (3)
Line range hint
34-46
: Excellent addition ofassertAiderBufferString
function.The new function
assertAiderBufferString
is a valuable addition to the test assertions. It provides a clear way to verify the content of the Aider buffer, which will enhance the test coverage and reliability.A minor suggestion for improvement:
Consider adding a check for an empty buffer. If
lines
is an empty array, thejoin("\n")
operation will result in an empty string, which might not be the intended behavior in all cases. You could add a check like this:assert(lines.length > 0, "Aider buffer is empty");This would provide a more specific error message if the buffer is unexpectedly empty.
#!/bin/bash # Description: Check for tests using the new assertAiderBufferString function rg --type typescript 'assertAiderBufferString' tests/
Line range hint
10-15
: Verify thatassertAiderBufferShown
is now working correctly.The removal of the "not working" comment suggests that this function is now functioning as intended. Please confirm that this is the case and that appropriate tests have been added or updated to verify its behavior.
✅ Verification successful
Verified: The removal of the "not working" comment from
assertAiderBufferShown
is appropriate. The function is being utilized intests/aider_test.ts
, confirming it is functioning as intended.🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Check for tests using assertAiderBufferShown rg --type typescript 'assertAiderBufferShown' tests/Length of output: 87
Script:
#!/bin/bash # Description: Check for tests using assertAiderBufferShown rg --type ts 'assertAiderBufferShown' tests/Length of output: 397
Line range hint
20-25
: Verify thatassertAiderBufferHidden
is now working correctly.The removal of the "not working" comment indicates that this function is now functioning as intended. Please confirm that this is the case and that appropriate tests have been added or updated to verify its behavior.
✅ Verification successful
Please update the shell script to correctly target TypeScript files and rerun the verification.
Verified:
assertAiderBufferHidden
is being appropriately tested intests/aider_test.ts
. The removal of the "not working" comment is supported by existing test cases that assert the function's behavior.🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Check for tests using assertAiderBufferHidden rg --type typescript 'assertAiderBufferHidden' tests/Length of output: 88
Script:
#!/bin/bash # Description: Check for tests using assertAiderBufferHidden rg --glob "*.ts" 'assertAiderBufferHidden' tests/Length of output: 405
Script:
#!/bin/bash # Description: Inspect tests/aider_test.ts for assertions related to assertAiderBufferHidden cat tests/aider_test.ts | grep -A 5 'assertAiderBufferHidden'Length of output: 696
tests/aider_test.ts (2)
9-9
: Approve change in assertion for "floating" AiderRun test.The replacement of
assertAiderBufferAlive
withassertAiderBufferShown
is appropriate and aligns with the PR objectives. This change more accurately verifies the expected state of the Aider buffer after running the AiderRun command.
15-15
: Approve change in assertion for "vsplit" AiderRun test.The replacement of
assertAiderBufferAlive
withassertAiderBufferShown
in the "vsplit" test is consistent with the change made in the "floating" test. This modification improves the accuracy of the test and aligns with the PR objectives.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
( ;´ワ `;)つLGTM!!
Summary by CodeRabbit
Summary by CodeRabbit
New Features
Bug Fixes
Tests
AiderSilentRun
command.Documentation