Skip to content

Commit 8635eda

Browse files
Keep testing configuration alive after losing focus (#4316)
1 parent 70a0025 commit 8635eda

6 files changed

Lines changed: 24 additions & 15 deletions

File tree

.github/test_plan.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -273,11 +273,6 @@ class FailingTests(unittest.TestCase):
273273
- [ ] `Run Test` works
274274
- [ ] `Debug Test` works
275275
- [ ] Module/suite setup methods are also run (run the `test_setup` method to verify)
276-
- [ ] `Configure Unit Tests` works
277-
- [ ] quick pick for framework (and its settings)
278-
- [ ] selected framework enabled in workspace settings
279-
- [ ] framework's config added (and old config removed)
280-
- [ ] other frameworks disabled in workspace settings
281276

282277
#### [`pytest`](https://code.visualstudio.com/docs/python/unit-testing#_pytest-configuration-settings)
283278
```python
@@ -326,5 +321,11 @@ def test_failure():
326321
- [ ] `Run Unit Test Method ...` works
327322
- [ ] `View Unit Test Output` works
328323
- [ ] After having at least one failure, `Run Failed Tests` works
324+
- [ ] `Configure Unit Tests` works
325+
- [ ] quick pick for framework (and its settings)
326+
- [ ] selected framework enabled in workspace settings
327+
- [ ] framework's config added (and old config removed)
328+
- [ ] other frameworks disabled in workspace settings
329+
- [ ] `Configure Unit Tests` does not close if it loses focus
329330

330331
</details>

news/1 Enhancements/4288.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Keep testing configuration alive when losing UI focus.

src/client/unittests/common/managers/testConfigurationManager.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import * as path from 'path';
2-
import { OutputChannel, QuickPickItem, Uri, window } from 'vscode';
2+
import { OutputChannel, QuickPickItem, Uri } from 'vscode';
3+
import { IApplicationShell } from '../../../common/application/types';
34
import { IInstaller, IOutputChannel, Product } from '../../../common/types';
45
import { createDeferred } from '../../../common/utils/async';
56
import { getSubDirectories } from '../../../common/utils/fs';
@@ -38,6 +39,7 @@ export abstract class TestConfigurationManager implements ITestConfigurationMana
3839
}
3940
protected selectTestDir(rootDir: string, subDirs: string[], customOptions: QuickPickItem[] = []): Promise<string> {
4041
const options = {
42+
ignoreFocusOut: true,
4143
matchOnDescription: true,
4244
matchOnDetail: true,
4345
placeHolder: 'Select the directory containing the unit tests'
@@ -59,7 +61,8 @@ export abstract class TestConfigurationManager implements ITestConfigurationMana
5961
items = [{ label: '.', description: 'Root directory' }, ...items];
6062
items = customOptions.concat(items);
6163
const def = createDeferred<string>();
62-
window.showQuickPick(items, options).then(item => {
64+
const appShell = this.serviceContainer.get<IApplicationShell>(IApplicationShell);
65+
appShell.showQuickPick(items, options).then(item => {
6366
if (!item) {
6467
return def.resolve();
6568
}
@@ -72,6 +75,7 @@ export abstract class TestConfigurationManager implements ITestConfigurationMana
7275

7376
protected selectTestFilePattern(): Promise<string> {
7477
const options = {
78+
ignoreFocusOut: true,
7579
matchOnDescription: true,
7680
matchOnDetail: true,
7781
placeHolder: 'Select the pattern to identify test files'
@@ -85,7 +89,8 @@ export abstract class TestConfigurationManager implements ITestConfigurationMana
8589
];
8690

8791
const def = createDeferred<string>();
88-
window.showQuickPick(items, options).then(item => {
92+
const appShell = this.serviceContainer.get<IApplicationShell>(IApplicationShell);
93+
appShell.showQuickPick(items, options).then(item => {
8994
if (!item) {
9095
return def.resolve();
9196
}

src/client/unittests/common/testUtils.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { inject, injectable, named } from 'inversify';
22
import * as path from 'path';
3-
import { Uri, window, workspace } from 'vscode';
3+
import { Uri, workspace } from 'vscode';
44
import { IApplicationShell, ICommandManager } from '../../common/application/types';
55
import * as constants from '../../common/constants';
66
import { IUnitTestSettings, Product } from '../../common/types';
@@ -9,14 +9,13 @@ import { CommandSource } from './constants';
99
import { TestFlatteningVisitor } from './testVisitors/flatteningVisitor';
1010
import { ITestsHelper, ITestVisitor, TestFile, TestFolder, TestProvider, Tests, TestSettingsPropertyNames, TestsToRun, UnitTestProduct } from './types';
1111

12-
export async function selectTestWorkspace(): Promise<Uri | undefined> {
12+
export async function selectTestWorkspace(appShell: IApplicationShell): Promise<Uri | undefined> {
1313
if (!Array.isArray(workspace.workspaceFolders) || workspace.workspaceFolders.length === 0) {
1414
return undefined;
1515
} else if (workspace.workspaceFolders.length === 1) {
1616
return workspace.workspaceFolders[0].uri;
1717
} else {
18-
// tslint:disable-next-line:no-any prefer-type-cast
19-
const workspaceFolder = await (window as any).showWorkspaceFolderPick({ placeHolder: 'Select a workspace' });
18+
const workspaceFolder = await appShell.showWorkspaceFolderPick({ placeHolder: 'Select a workspace' });
2019
return workspaceFolder ? workspaceFolder.uri : undefined;
2120
}
2221
}

src/client/unittests/configuration.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ export class UnitTestConfigurationService implements IUnitTestConfigurationServi
6060
detail: 'https://nose.readthedocs.io/'
6161
}];
6262
const options = {
63+
ignoreFocusOut: true,
6364
matchOnDescription: true,
6465
matchOnDetail: true,
6566
placeHolder: placeHolderMessage

src/client/unittests/main.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99
OutputChannel, TextDocument, Uri, window
1010
} from 'vscode';
1111
import {
12-
ICommandManager, IDocumentManager, IWorkspaceService
12+
IApplicationShell, ICommandManager, IDocumentManager, IWorkspaceService
1313
} from '../common/application/types';
1414
import * as constants from '../common/constants';
1515
import '../common/extensions';
@@ -89,7 +89,8 @@ export class UnitTestManagementService implements IUnitTestManagementService, Di
8989
const wkspaceFolder = this.workspaceService.getWorkspaceFolder(resource);
9090
wkspace = wkspaceFolder ? wkspaceFolder.uri : undefined;
9191
} else {
92-
wkspace = await selectTestWorkspace();
92+
const appShell = this.serviceContainer.get<IApplicationShell>(IApplicationShell);
93+
wkspace = await selectTestWorkspace(appShell);
9394
}
9495
if (!wkspace) {
9596
return;
@@ -322,7 +323,8 @@ export class UnitTestManagementService implements IUnitTestManagementService, Di
322323
const wkspaceFolder = this.workspaceService.getWorkspaceFolder(resource);
323324
wkspace = wkspaceFolder ? wkspaceFolder.uri : undefined;
324325
} else {
325-
wkspace = await selectTestWorkspace();
326+
const appShell = this.serviceContainer.get<IApplicationShell>(IApplicationShell);
327+
wkspace = await selectTestWorkspace(appShell);
326328
}
327329
if (!wkspace) {
328330
return;

0 commit comments

Comments
 (0)