Repository navigation
Fix codelens action for opening a dropdown on parametrized tests in windows 10 #8647
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
Merged
Eric Snow (ericsnowcurrently)
merged 2 commits into
microsoft:master
from
phloose:codelens-on-parametrized-tests-8627
Dec 11, 2019
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| Fixes that the test selection drop-down did not open when a code lens for a parameterized test was clicked on windows. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,116 @@ | ||
| // Copyright (c) Microsoft Corporation. All rights reserved. | ||
| // Licensed under the MIT License. | ||
|
|
||
| 'use strict'; | ||
|
|
||
| import { anything, instance, mock, verify, when } from 'ts-mockito'; | ||
| import { Uri } from 'vscode'; | ||
| import { ApplicationShell } from '../../../client/common/application/applicationShell'; | ||
| import { CommandManager } from '../../../client/common/application/commandManager'; | ||
| import { IApplicationShell, ICommandManager } from '../../../client/common/application/types'; | ||
| import { FileSystem } from '../../../client/common/platform/fileSystem'; | ||
| import { PlatformService } from '../../../client/common/platform/platformService'; | ||
| import { IFileSystem } from '../../../client/common/platform/types'; | ||
| import { ServiceContainer } from '../../../client/ioc/container'; | ||
| import { IServiceContainer } from '../../../client/ioc/types'; | ||
| import { CommandSource } from '../../../client/testing/common/constants'; | ||
| import { TestCollectionStorageService } from '../../../client/testing/common/services/storageService'; | ||
| import { ITestCollectionStorageService, TestFunction, Tests } from '../../../client/testing/common/types'; | ||
| import { TestDisplay } from '../../../client/testing/display/picker'; | ||
| import { createEmptyResults } from '../results'; | ||
|
|
||
| // tslint:disable:no-any | ||
|
|
||
| // tslint:disable-next-line: max-func-body-length | ||
| suite('Testing - TestDisplay', () => { | ||
| const wkspace = Uri.file(__dirname); | ||
| let mockedCommandManager: ICommandManager; | ||
| let mockedServiceContainer: IServiceContainer; | ||
| let mockedTestCollectionStorage: ITestCollectionStorageService; | ||
| let mockedAppShell: IApplicationShell; | ||
| let testDisplay: TestDisplay; | ||
|
|
||
| function fullPathInTests(collectedTests: Tests, fullpath?: string): Tests { | ||
| collectedTests.testFiles = [{ | ||
| fullPath: fullpath ? fullpath : 'path/to/testfile', | ||
| ...anything() | ||
| }]; | ||
| return collectedTests; | ||
| } | ||
|
|
||
| setup(() => { | ||
| mockedCommandManager = mock(CommandManager); | ||
| mockedServiceContainer = mock(ServiceContainer); | ||
| mockedTestCollectionStorage = mock(TestCollectionStorageService); | ||
| mockedAppShell = mock(ApplicationShell); | ||
| when(mockedServiceContainer.get<ITestCollectionStorageService>(ITestCollectionStorageService)) | ||
| .thenReturn(instance(mockedTestCollectionStorage)); | ||
| when(mockedServiceContainer.get<IApplicationShell>(IApplicationShell)) | ||
| .thenReturn(instance(mockedAppShell)); | ||
|
|
||
| testDisplay = new TestDisplay(instance(mockedServiceContainer), instance(mockedCommandManager)); | ||
| }); | ||
|
|
||
| suite('displayFunctionTestPickerUI', () => { | ||
| const paths: { [key: string]: any } = { | ||
| match: { | ||
| fullPath: '/path/to/testfile', | ||
| fileName: '/path/to/testfile' | ||
| }, | ||
| mismatch: { | ||
| fullPath: '/path/to/testfile', | ||
| fileName: '/testfile/to/path' | ||
| } | ||
| }; | ||
| let tests: Tests; | ||
|
|
||
| function codeLensTestFunctions(testfunctions?: TestFunction[]): TestFunction[] { | ||
| if (!testfunctions) { | ||
| return [{ ...anything() }]; | ||
| } | ||
| const functions: TestFunction[] = []; | ||
| testfunctions.forEach(fn => functions.push(fn)); | ||
| return functions; | ||
| } | ||
|
|
||
| setup(() => { | ||
| tests = createEmptyResults(); | ||
| when(mockedServiceContainer.get<IFileSystem>(IFileSystem)).thenReturn(new FileSystem(new PlatformService())); | ||
| when(mockedTestCollectionStorage.getTests(wkspace)).thenReturn(tests); | ||
| when(mockedAppShell.showQuickPick(anything(), anything())).thenResolve(); | ||
| }); | ||
|
|
||
| test(`Test that a dropdown picker for parametrized tests is shown if compared paths are equal (OS independent) (#8627)`, () => { | ||
| const { fullPath, fileName } = paths.match; | ||
| fullPathInTests(tests, fullPath); | ||
|
|
||
| testDisplay.displayFunctionTestPickerUI(CommandSource.commandPalette, wkspace, 'rootDirectory', Uri.file(fileName), codeLensTestFunctions()); | ||
|
|
||
| verify(mockedAppShell.showQuickPick(anything(), anything())).once(); | ||
| }); | ||
|
|
||
| test(`Test that a dropdown picker for parametrized tests is NOT shown if compared paths are NOT equal (OS independent) (#8627)`, () => { | ||
| const { fullPath, fileName } = paths.mismatch; | ||
| fullPathInTests(tests, fullPath); | ||
|
|
||
| testDisplay.displayFunctionTestPickerUI(CommandSource.commandPalette, wkspace, 'rootDirectory', Uri.file(fileName), codeLensTestFunctions()); | ||
|
|
||
| verify(mockedAppShell.showQuickPick(anything(), anything())).never(); | ||
| }); | ||
|
|
||
| test(`Test that clicking a codelens on parametrized tests opens a dropdown picker on windows (#8627)`, function () { | ||
| if (process.platform !== 'win32') { | ||
| // tslint:disable-next-line: no-invalid-this | ||
| this.skip(); | ||
| } | ||
| // The error described in #8627 originated from the problem that the casing of the drive letter was different | ||
| // in a test items fullPath property to the one of a file that contained the clicked parametrized test. | ||
| const fileName = 'c:\\path\\to\\testfile'; | ||
| fullPathInTests(tests, 'C:\\path\\to\\testfile'); | ||
|
|
||
| testDisplay.displayFunctionTestPickerUI(CommandSource.commandPalette, wkspace, 'rootDirectory', Uri.file(fileName), codeLensTestFunctions()); | ||
|
|
||
| verify(mockedAppShell.showQuickPick(anything(), anything())).once(); | ||
| }); | ||
| }); | ||
| }); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.