Path: blob/main/extensions/copilot/src/extension/conversation/vscode-node/test/githubPullRequestTitleAndDescription.test.ts
13405 views
/*---------------------------------------------------------------------------------------------1* Copyright (c) Microsoft Corporation. All rights reserved.2* Licensed under the MIT License. See License.txt in the project root for license information.3*--------------------------------------------------------------------------------------------*/45import assert from 'assert';6import { GitHubPullRequestTitleAndDescriptionGenerator } from '../../../prompt/node/githubPullRequestTitleAndDescriptionGenerator';78suite('GitHub Pull Request title and description test suite', function () {9test('Test parse assistant output, trailing after last +++', function () {10const assistantOutput = `+++Title: Improve inline chat functionality11Description: This pull request improves the inline chat functionality by not expanding the wholeRange to the function if the current line is empty or whitespace only. This prevents unnecessary code suggestions and improves the user experience. No files or commits are listed in the description. This change addresses issue #123.+++.`;1213const parsed = GitHubPullRequestTitleAndDescriptionGenerator.parseFetchResult(assistantOutput);14assert.strictEqual(parsed?.title, 'Improve inline chat functionality');15assert.strictEqual(parsed?.description, `This pull request improves the inline chat functionality by not expanding the wholeRange to the function if the current line is empty or whitespace only. This prevents unnecessary code suggestions and improves the user experience. No files or commits are listed in the description. This change addresses issue #123.`);16});1718test('Test parse assistant output, ideal', function () {19const assistantOutput = `+++Update bug report template with additional fields20+++This pull request updates the bug report template to include additional fields that will help us better understand and reproduce reported issues. The new fields include Repository Clone Configuration (single repository/fork of an upstream repository) and Github Product (Github.com/Github Enterprise version x.x.x). This will allow us to better diagnose and resolve issues.+++`;2122const parsed = GitHubPullRequestTitleAndDescriptionGenerator.parseFetchResult(assistantOutput);23assert.strictEqual(parsed?.title, 'Update bug report template with additional fields');24assert.strictEqual(parsed?.description, `This pull request updates the bug report template to include additional fields that will help us better understand and reproduce reported issues. The new fields include Repository Clone Configuration (single repository/fork of an upstream repository) and Github Product (Github.com/Github Enterprise version x.x.x). This will allow us to better diagnose and resolve issues.`);25});2627test('Test parse assistant output, newlines', function () {28const assistantOutput = `+++29Title: Fix tab bar submenu capitalization30Description: This pull request fixes the capitalization of the "Tab Bar" submenu in the editor tabs bar context menu. It also adds an empty editor group menu item to the same context menu. These changes were made to improve consistency and clarity in the user interface. This pull request includes the following commits:31- Empty Group Maximized Action Item32+++`;3334const parsed = GitHubPullRequestTitleAndDescriptionGenerator.parseFetchResult(assistantOutput);35assert.strictEqual(parsed?.title, 'Fix tab bar submenu capitalization');36assert.strictEqual(parsed?.description, `This pull request fixes the capitalization of the "Tab Bar" submenu in the editor tabs bar context menu. It also adds an empty editor group menu item to the same context menu. These changes were made to improve consistency and clarity in the user interface. This pull request includes the following commits:3738- Empty Group Maximized Action Item`);39});4041test('Test parse assistant output, without final +++', function () {42const assistantOutput = `+++Update tab bar group and order in layoutActions.ts43+++This pull request updates the group and order of the tab bar in layoutActions.ts to better align with the overall layout of the workbench. Specifically, the group has been changed to '3_workbench_layout_move' and the order has been changed to 10. These changes will improve the user experience and make the layout more intuitive.`;4445const parsed = GitHubPullRequestTitleAndDescriptionGenerator.parseFetchResult(assistantOutput);46assert.strictEqual(parsed?.title, 'Update tab bar group and order in layoutActions.ts');47assert.strictEqual(parsed?.description, `This pull request updates the group and order of the tab bar in layoutActions.ts to better align with the overall layout of the workbench. Specifically, the group has been changed to '3_workbench_layout_move' and the order has been changed to 10. These changes will improve the user experience and make the layout more intuitive.`);48});4950test('Test parse assistant output, title in quotes', function () {51const assistantOutput = `+++"Update bug report template with additional fields"52+++This pull request updates the bug report template to include additional fields that will help us better understand and reproduce reported issues. The new fields include Repository Clone Configuration (single repository/fork of an upstream repository) and Github Product (Github.com/Github Enterprise version x.x.x). This will allow us to better diagnose and resolve issues.+++`;5354const parsed = GitHubPullRequestTitleAndDescriptionGenerator.parseFetchResult(assistantOutput);55assert.strictEqual(parsed?.title, 'Update bug report template with additional fields');56assert.strictEqual(parsed?.description, `This pull request updates the bug report template to include additional fields that will help us better understand and reproduce reported issues. The new fields include Repository Clone Configuration (single repository/fork of an upstream repository) and Github Product (Github.com/Github Enterprise version x.x.x). This will allow us to better diagnose and resolve issues.`);57});5859test('Test parse assistant output, extra +s', function () {60const assistantOutput = `+++++ Improve error attribution and stest name validation61+++++This pull request includes two commits. The first commit improves error attribution by making it easier to attribute errors to specific scenarios. The second commit adds validation for stest names, stripping newlines and limiting the length to 100 characters. These changes enhance the reliability and readability of the codebase.`;6263const parsed = GitHubPullRequestTitleAndDescriptionGenerator.parseFetchResult(assistantOutput);64assert.strictEqual(parsed?.title, 'Improve error attribution and stest name validation');65assert.strictEqual(parsed?.description, `This pull request includes two commits. The first commit improves error attribution by making it easier to attribute errors to specific scenarios. The second commit adds validation for stest names, stripping newlines and limiting the length to 100 characters. These changes enhance the reliability and readability of the codebase.`);66});67});686970