mirror of
https://github.com/QwenLM/qwen-code.git
synced 2025-12-19 09:33:53 +00:00
feat: Add custom URL support for the /bug command (#1017)
This commit is contained in:
@@ -129,6 +129,7 @@ describe('useSlashCommandProcessor', () => {
|
||||
getModel: vi.fn(() => 'test-model'),
|
||||
getProjectRoot: vi.fn(() => '/test/dir'),
|
||||
getCheckpointEnabled: vi.fn(() => true),
|
||||
getBugCommand: vi.fn(() => undefined),
|
||||
} as unknown as Config;
|
||||
mockCorgiMode = vi.fn();
|
||||
mockUseSessionStats.mockReturnValue({
|
||||
@@ -418,6 +419,47 @@ Add any other context about the problem here.
|
||||
expect(open).toHaveBeenCalledWith(expectedUrl);
|
||||
expect(commandResult).toBe(true);
|
||||
});
|
||||
|
||||
it('should use the custom bug command URL from config if available', async () => {
|
||||
const bugCommand = {
|
||||
urlTemplate:
|
||||
'https://custom-bug-tracker.com/new?title={title}&body={body}',
|
||||
};
|
||||
mockConfig = {
|
||||
...mockConfig,
|
||||
getBugCommand: vi.fn(() => bugCommand),
|
||||
} as unknown as Config;
|
||||
|
||||
const { handleSlashCommand } = getProcessor();
|
||||
const bugDescription = 'This is a custom bug';
|
||||
const diagnosticInfo = `
|
||||
## Describe the bug
|
||||
A clear and concise description of what the bug is.
|
||||
|
||||
## Additional context
|
||||
Add any other context about the problem here.
|
||||
|
||||
## Diagnostic Information
|
||||
* **CLI Version:** unknown
|
||||
* **Git Commit:** ${GIT_COMMIT_INFO}
|
||||
* **Operating System:** test-platform test-node-version
|
||||
* **Sandbox Environment:** no sandbox
|
||||
* **Model Version:** test-model
|
||||
* **Memory Usage:** 11.8 MB
|
||||
`;
|
||||
const expectedUrl = bugCommand.urlTemplate
|
||||
.replace('{title}', encodeURIComponent(bugDescription))
|
||||
.replace('{body}', encodeURIComponent(diagnosticInfo));
|
||||
|
||||
let commandResult: SlashCommandActionReturn | boolean = false;
|
||||
await act(async () => {
|
||||
commandResult = await handleSlashCommand(`/bug ${bugDescription}`);
|
||||
});
|
||||
|
||||
expect(mockAddItem).toHaveBeenCalledTimes(2);
|
||||
expect(open).toHaveBeenCalledWith(expectedUrl);
|
||||
expect(commandResult).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe('/quit and /exit commands', () => {
|
||||
|
||||
Reference in New Issue
Block a user