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

Use new report issue command api #23033

Merged
8 changes: 7 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
"testObserver",
"quickPickItemTooltip",
"terminalDataWriteEvent",
"terminalExecuteCommandEvent"
"terminalExecuteCommandEvent",
"contribIssueReporter"
],
"author": {
"name": "Microsoft Corporation"
Expand Down Expand Up @@ -1243,6 +1244,11 @@
}
],
"menus": {
"issue/reporter": [
{
"command": "python.reportIssue"
}
],
"commandPalette": [
{
"category": "Python",
Expand Down
19 changes: 1 addition & 18 deletions resources/report_issue_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,9 @@ XXX
**After** creating the issue on GitHub, you can add screenshots and GIFs of what is happening. Consider tools like https://www.cockos.com/licecap/, https://github.com/phw/peek or https://www.screentogif.com/ for GIF creation.
-->

<!-- **NOTE**: Everything below except Python output panel is auto-generated; no editing required. Please do provide Python output panel. -->
<!-- **NOTE**: Please do provide Python output panel. -->
paulacamargo25 marked this conversation as resolved.
Show resolved Hide resolved
# Diagnostic data

- Python version (& distribution if applicable, e.g. Anaconda): {0}
- Type of virtual environment used (e.g. conda, venv, virtualenv, etc.): {1}
- Value of the `python.languageServer` setting: {2}

<details>

<summary>Output for <code>Python</code> in the <code>Output</code> panel (<code>View</code>→<code>Output</code>, change the drop-down the upper-right of the <code>Output</code> panel to <code>Python</code>)
Expand All @@ -32,16 +28,3 @@ XXX

</p>
</details>

<details>

<summary>User Settings</summary>

<p>

```
{3}{4}
```

</p>
</details>
16 changes: 16 additions & 0 deletions resources/report_issue_user_data_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
- Python version (& distribution if applicable, e.g. Anaconda): {0}
- Type of virtual environment used (e.g. conda, venv, virtualenv, etc.): {1}
- Value of the `python.languageServer` setting: {2}

<details>

<summary>User Settings</summary>

<p>

```
{3}{4}
```

</p>
</details>
6 changes: 5 additions & 1 deletion src/client/common/application/commands/reportIssueCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ export class ReportIssueCommandHandler implements IExtensionSingleActivationServ

private templatePath = path.join(EXTENSION_ROOT_DIR, 'resources', 'report_issue_template.md');

private userDataTemplatePath = path.join(EXTENSION_ROOT_DIR, 'resources', 'report_issue_user_data_template.md');

public async openReportIssue(): Promise<void> {
const settings: IPythonSettings = this.configurationService.getSettings();
const argSettings = JSON.parse(await fs.readFile(this.argSettingsPath, 'utf8'));
Expand Down Expand Up @@ -86,6 +88,7 @@ export class ReportIssueCommandHandler implements IExtensionSingleActivationServ
}
});
const template = await fs.readFile(this.templatePath, 'utf8');
const userTemplate = await fs.readFile(this.userDataTemplatePath, 'utf8');
const interpreter = await this.interpreterService.getActiveInterpreter();
const pythonVersion = interpreter?.version?.raw ?? '';
const languageServer =
Expand All @@ -99,7 +102,8 @@ export class ReportIssueCommandHandler implements IExtensionSingleActivationServ
: '';
await this.commandManager.executeCommand('workbench.action.openIssueReporter', {
extensionId: 'ms-python.python',
issueBody: template.format(
issueBody: template,
data: userTemplate.format(
pythonVersion,
virtualEnvKind,
languageServer,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,9 @@ XXX
**After** creating the issue on GitHub, you can add screenshots and GIFs of what is happening. Consider tools like https://www.cockos.com/licecap/, https://github.com/phw/peek or https://www.screentogif.com/ for GIF creation.
-->

<!-- **NOTE**: Everything below except Python output panel is auto-generated; no editing required. Please do provide Python output panel. -->
<!-- **NOTE**: Please do provide Python output panel. -->
paulacamargo25 marked this conversation as resolved.
Show resolved Hide resolved
# Diagnostic data

- Python version (& distribution if applicable, e.g. Anaconda): 3.9.0
- Type of virtual environment used (e.g. conda, venv, virtualenv, etc.): Venv
- Value of the `python.languageServer` setting: Pylance

<details>

<summary>Output for <code>Python</code> in the <code>Output</code> panel (<code>View</code>→<code>Output</code>, change the drop-down the upper-right of the <code>Output</code> panel to <code>Python</code>)
Expand All @@ -32,22 +28,3 @@ XXX

</p>
</details>

<details>

<summary>User Settings</summary>

<p>

```
Multiroot scenario, following user settings may not apply:

experiments
• enabled: false

venvPath: "<placeholder>"

```

</p>
</details>
56 changes: 0 additions & 56 deletions src/test/common/application/commands/issueTemplateVenv1.md

This file was deleted.

25 changes: 25 additions & 0 deletions src/test/common/application/commands/issueUserDataTemplateVenv1.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
- Python version (& distribution if applicable, e.g. Anaconda): 3.9.0
- Type of virtual environment used (e.g. conda, venv, virtualenv, etc.): Venv
- Value of the `python.languageServer` setting: Pylance

<details>

<summary>User Settings</summary>

<p>

```

experiments
• enabled: false
• optInto: []
• optOutFrom: []

venvPath: "<placeholder>"

pipenvPath: "<placeholder>"

```

</p>
</details>
22 changes: 22 additions & 0 deletions src/test/common/application/commands/issueUserDataTemplateVenv2.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
- Python version (& distribution if applicable, e.g. Anaconda): 3.9.0
- Type of virtual environment used (e.g. conda, venv, virtualenv, etc.): Venv
- Value of the `python.languageServer` setting: Pylance

<details>

<summary>User Settings</summary>

<p>

```
Multiroot scenario, following user settings may not apply:

experiments
• enabled: false

venvPath: "<placeholder>"

```

</p>
</details>
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ suite('Report Issue Command', () => {
let interpreterService: IInterpreterService;
let configurationService: IConfigurationService;
let appEnvironment: IApplicationEnvironment;
let expectedIssueBody: string;

setup(async () => {
workspaceService = mock(WorkspaceService);
Expand Down Expand Up @@ -79,6 +80,17 @@ suite('Report Issue Command', () => {
instance(appEnvironment),
);
await reportIssueCommandHandler.activate();

const issueTemplatePath = path.join(
EXTENSION_ROOT_DIR_FOR_TESTS,
'src',
'test',
'common',
'application',
'commands',
'issueTemplate.md',
);
expectedIssueBody = fs.readFileSync(issueTemplatePath, 'utf8');
});

teardown(() => {
Expand All @@ -88,27 +100,28 @@ suite('Report Issue Command', () => {
test('Test if issue body is filled correctly when including all the settings', async () => {
await reportIssueCommandHandler.openReportIssue();

const templatePath = path.join(
const userDataTemplatePath = path.join(
EXTENSION_ROOT_DIR_FOR_TESTS,
'src',
'test',
'common',
'application',
'commands',
'issueTemplateVenv1.md',
'issueUserDataTemplateVenv1.md',
);
const expectedIssueBody = fs.readFileSync(templatePath, 'utf8');
const expectedData = fs.readFileSync(userDataTemplatePath, 'utf8');

const args: [string, { extensionId: string; issueBody: string }] = capture<
const args: [string, { extensionId: string; issueBody: string; data: string }] = capture<
AllCommands,
{ extensionId: string; issueBody: string }
{ extensionId: string; issueBody: string; data: string }
>(cmdManager.executeCommand).last();

verify(cmdManager.registerCommand(Commands.ReportIssue, anything(), anything())).once();
verify(cmdManager.executeCommand('workbench.action.openIssueReporter', anything())).once();
expect(args[0]).to.be.equal('workbench.action.openIssueReporter');
const actual = args[1].issueBody;
expect(actual).to.be.equal(expectedIssueBody);
const { issueBody, data } = args[1];
expect(issueBody).to.be.equal(expectedIssueBody);
expect(data).to.be.equal(expectedData);
});

test('Test if issue body is filled when only including settings which are explicitly set', async () => {
Expand All @@ -128,26 +141,27 @@ suite('Report Issue Command', () => {
await reportIssueCommandHandler.activate();
await reportIssueCommandHandler.openReportIssue();

const templatePath = path.join(
const userDataTemplatePath = path.join(
EXTENSION_ROOT_DIR_FOR_TESTS,
'src',
'test',
'common',
'application',
'commands',
'issueTemplateVenv2.md',
'issueUserDataTemplateVenv2.md',
);
const expectedIssueBody = fs.readFileSync(templatePath, 'utf8');
const expectedData = fs.readFileSync(userDataTemplatePath, 'utf8');

const args: [string, { extensionId: string; issueBody: string }] = capture<
const args: [string, { extensionId: string; issueBody: string; data: string }] = capture<
AllCommands,
{ extensionId: string; issueBody: string }
{ extensionId: string; issueBody: string; data: string }
>(cmdManager.executeCommand).last();

verify(cmdManager.executeCommand('workbench.action.openIssueReporter', anything())).once();
expect(args[0]).to.be.equal('workbench.action.openIssueReporter');
const actual = args[1].issueBody;
expect(actual).to.be.equal(expectedIssueBody);
const { issueBody, data } = args[1];
expect(issueBody).to.be.equal(expectedIssueBody);
expect(data).to.be.equal(expectedData);
});
test('Should send telemetry event when run Report Issue Command', async () => {
const sendTelemetryStub = sinon.stub(Telemetry, 'sendTelemetryEvent');
Expand Down
Loading