mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-03-30 08:40:29 -04:00
Utilize test skipping to reduce merge conflicts (#6937)
* utilize test skipping to reduce merge conflicts * fix compile error
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
import * as assert from 'assert';
|
||||
import { replaceWhitespace, renderExpressionValue, renderVariable } from 'vs/workbench/contrib/debug/browser/baseDebugView';
|
||||
import * as dom from 'vs/base/browser/dom';
|
||||
import { Expression, Variable, Scope, StackFrame, Thread } from 'vs/workbench/contrib/debug/common/debugModel';
|
||||
import { MockSession } from 'vs/workbench/contrib/debug/test/common/mockDebug';
|
||||
import { HighlightedLabel } from 'vs/base/browser/ui/highlightedlabel/highlightedLabel';
|
||||
const $ = dom.$;
|
||||
@@ -19,7 +20,72 @@ suite('Debug - Base Debug View', () => {
|
||||
assert.equal(replaceWhitespace('hey \r\t\n\t\t\n there'), 'hey \\r\\t\\n\\t\\t\\n there');
|
||||
});
|
||||
|
||||
test('render variable', () => {
|
||||
// {{SQL CARBON EDIT}} - Disable test
|
||||
test.skip('render expression value', () => { // {{SQL CARBON EDIT}} skip test
|
||||
let container = $('.container');
|
||||
renderExpressionValue('render \n me', container, { showHover: true, preserveWhitespace: true });
|
||||
assert.equal(container.className, 'value');
|
||||
assert.equal(container.title, 'render \n me');
|
||||
assert.equal(container.textContent, 'render \n me');
|
||||
|
||||
const expression = new Expression('console');
|
||||
expression.value = 'Object';
|
||||
container = $('.container');
|
||||
renderExpressionValue(expression, container, { colorize: true });
|
||||
assert.equal(container.className, 'value unavailable error');
|
||||
|
||||
expression.available = true;
|
||||
expression.value = '"string value"';
|
||||
container = $('.container');
|
||||
renderExpressionValue(expression, container, { colorize: true });
|
||||
assert.equal(container.className, 'value string');
|
||||
assert.equal(container.textContent, '"string value"');
|
||||
|
||||
expression.type = 'boolean';
|
||||
container = $('.container');
|
||||
renderExpressionValue(expression, container, { colorize: true });
|
||||
assert.equal(container.className, 'value boolean');
|
||||
assert.equal(container.textContent, expression.value);
|
||||
|
||||
expression.value = 'this is a long string';
|
||||
container = $('.container');
|
||||
renderExpressionValue(expression, container, { colorize: true, maxValueLength: 4 });
|
||||
assert.equal(container.textContent, 'this...');
|
||||
});
|
||||
|
||||
test.skip('render variable', () => { // {{SQL CARBON EDIT}} skip test
|
||||
const session = new MockSession();
|
||||
const thread = new Thread(session, 'mockthread', 1);
|
||||
const stackFrame = new StackFrame(thread, 1, null!, 'app.js', 'normal', { startLineNumber: 1, startColumn: 1, endLineNumber: undefined!, endColumn: undefined! }, 0);
|
||||
const scope = new Scope(stackFrame, 1, 'local', 1, false, 10, 10);
|
||||
|
||||
let variable = new Variable(session, scope, 2, 'foo', 'bar.foo', undefined!, 0, 0, {}, 'string');
|
||||
let expression = $('.');
|
||||
let name = $('.');
|
||||
let value = $('.');
|
||||
let label = new HighlightedLabel(name, false);
|
||||
renderVariable(variable, { expression, name, value, label }, false, []);
|
||||
|
||||
assert.equal(label.element.textContent, 'foo');
|
||||
assert.equal(value.textContent, '');
|
||||
assert.equal(value.title, '');
|
||||
|
||||
variable.value = 'hey';
|
||||
expression = $('.');
|
||||
name = $('.');
|
||||
value = $('.');
|
||||
renderVariable(variable, { expression, name, value, label }, false, []);
|
||||
assert.equal(value.textContent, 'hey');
|
||||
assert.equal(label.element.textContent, 'foo:');
|
||||
assert.equal(label.element.title, 'string');
|
||||
|
||||
variable = new Variable(session, scope, 2, 'console', 'console', '5', 0, 0, { kind: 'virtual' });
|
||||
expression = $('.');
|
||||
name = $('.');
|
||||
value = $('.');
|
||||
renderVariable(variable, { expression, name, value, label }, false, []);
|
||||
assert.equal(name.className, 'virtual');
|
||||
assert.equal(label.element.textContent, 'console:');
|
||||
assert.equal(label.element.title, 'console');
|
||||
assert.equal(value.className, 'value number');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -167,8 +167,390 @@ function aGalleryExtension(name: string, properties: any = {}, galleryExtensionP
|
||||
return <IGalleryExtension>galleryExtension;
|
||||
}
|
||||
|
||||
// {{SQL CARBON EDIT}} disable broken tests
|
||||
suite('ExtensionsTipsService Test', () => {
|
||||
suite.skip('ExtensionsTipsService Test', () => { // {{SQL CARBON EDIT}} skip suite
|
||||
let workspaceService: IWorkspaceContextService;
|
||||
let instantiationService: TestInstantiationService;
|
||||
let testConfigurationService: TestConfigurationService;
|
||||
let testObject: ExtensionTipsService;
|
||||
let parentResource: string;
|
||||
let installEvent: Emitter<InstallExtensionEvent>,
|
||||
didInstallEvent: Emitter<DidInstallExtensionEvent>,
|
||||
uninstallEvent: Emitter<IExtensionIdentifier>,
|
||||
didUninstallEvent: Emitter<DidUninstallExtensionEvent>;
|
||||
let prompted: boolean;
|
||||
let onModelAddedEvent: Emitter<ITextModel>;
|
||||
let experimentService: TestExperimentService;
|
||||
|
||||
suiteSetup(() => {
|
||||
instantiationService = new TestInstantiationService();
|
||||
installEvent = new Emitter<InstallExtensionEvent>();
|
||||
didInstallEvent = new Emitter<DidInstallExtensionEvent>();
|
||||
uninstallEvent = new Emitter<IExtensionIdentifier>();
|
||||
didUninstallEvent = new Emitter<DidUninstallExtensionEvent>();
|
||||
instantiationService.stub(IExtensionGalleryService, ExtensionGalleryService);
|
||||
instantiationService.stub(ISharedProcessService, TestSharedProcessService);
|
||||
instantiationService.stub(ILifecycleService, new TestLifecycleService());
|
||||
testConfigurationService = new TestConfigurationService();
|
||||
instantiationService.stub(IConfigurationService, testConfigurationService);
|
||||
instantiationService.stub(INotificationService, new TestNotificationService());
|
||||
instantiationService.stub(IExtensionManagementService, ExtensionManagementService);
|
||||
instantiationService.stub(IExtensionManagementService, 'onInstallExtension', installEvent.event);
|
||||
instantiationService.stub(IExtensionManagementService, 'onDidInstallExtension', didInstallEvent.event);
|
||||
instantiationService.stub(IExtensionManagementService, 'onUninstallExtension', uninstallEvent.event);
|
||||
instantiationService.stub(IExtensionManagementService, 'onDidUninstallExtension', didUninstallEvent.event);
|
||||
instantiationService.stub(IExtensionEnablementService, new TestExtensionEnablementService(instantiationService));
|
||||
instantiationService.stub(ITelemetryService, NullTelemetryService);
|
||||
instantiationService.stub(IURLService, URLService);
|
||||
instantiationService.set(IProductService, {
|
||||
...productService,
|
||||
...{
|
||||
extensionTips: {
|
||||
'ms-vscode.csharp': '{**/*.cs,**/project.json,**/global.json,**/*.csproj,**/*.sln,**/appsettings.json}',
|
||||
'msjsdiag.debugger-for-chrome': '{**/*.ts,**/*.tsx**/*.js,**/*.jsx,**/*.es6,**/.babelrc}',
|
||||
'lukehoban.Go': '**/*.go'
|
||||
},
|
||||
extensionImportantTips: {
|
||||
'ms-python.python': {
|
||||
'name': 'Python',
|
||||
'pattern': '{**/*.py}'
|
||||
},
|
||||
'ms-vscode.PowerShell': {
|
||||
'name': 'PowerShell',
|
||||
'pattern': '{**/*.ps,**/*.ps1}'
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
experimentService = instantiationService.createInstance(TestExperimentService);
|
||||
instantiationService.stub(IExperimentService, experimentService);
|
||||
|
||||
onModelAddedEvent = new Emitter<ITextModel>();
|
||||
});
|
||||
|
||||
suiteTeardown(() => {
|
||||
if (experimentService) {
|
||||
experimentService.dispose();
|
||||
}
|
||||
});
|
||||
|
||||
setup(() => {
|
||||
instantiationService.stub(IEnvironmentService, <Partial<IEnvironmentService>>{ extensionDevelopmentPath: false });
|
||||
instantiationService.stubPromise(IExtensionManagementService, 'getInstalled', []);
|
||||
instantiationService.stub(IExtensionGalleryService, 'isEnabled', true);
|
||||
instantiationService.stubPromise(IExtensionGalleryService, 'query', aPage<IGalleryExtension>(...mockExtensionGallery));
|
||||
|
||||
prompted = false;
|
||||
|
||||
class TestNotificationService2 extends TestNotificationService {
|
||||
public prompt(severity: Severity, message: string, choices: IPromptChoice[], options?: IPromptOptions) {
|
||||
prompted = true;
|
||||
return null!;
|
||||
}
|
||||
}
|
||||
|
||||
instantiationService.stub(INotificationService, new TestNotificationService2());
|
||||
|
||||
testConfigurationService.setUserConfiguration(ConfigurationKey, { ignoreRecommendations: false, showRecommendationsOnlyOnDemand: false });
|
||||
instantiationService.stub(IStorageService, <Partial<IStorageService>>{ get: (a: string, b: StorageScope, c?: string) => c, getBoolean: (a: string, b: StorageScope, c: boolean) => c, store: () => { } });
|
||||
instantiationService.stub(IModelService, <IModelService>{
|
||||
getModels(): any { return []; },
|
||||
onModelAdded: onModelAddedEvent.event
|
||||
});
|
||||
});
|
||||
|
||||
teardown(done => {
|
||||
(<ExtensionTipsService>testObject).dispose();
|
||||
if (parentResource) {
|
||||
rimraf(parentResource, RimRafMode.MOVE).then(done, done);
|
||||
} else {
|
||||
done();
|
||||
}
|
||||
});
|
||||
|
||||
function setUpFolderWorkspace(folderName: string, recommendedExtensions: string[], ignoredRecommendations: string[] = []): Promise<void> {
|
||||
const id = uuid.generateUuid();
|
||||
parentResource = path.join(os.tmpdir(), 'vsctests', id);
|
||||
return setUpFolder(folderName, parentResource, recommendedExtensions, ignoredRecommendations);
|
||||
}
|
||||
|
||||
async function setUpFolder(folderName: string, parentDir: string, recommendedExtensions: string[], ignoredRecommendations: string[] = []): Promise<void> {
|
||||
const folderDir = path.join(parentDir, folderName);
|
||||
const workspaceSettingsDir = path.join(folderDir, '.vscode');
|
||||
await mkdirp(workspaceSettingsDir, 493);
|
||||
const configPath = path.join(workspaceSettingsDir, 'extensions.json');
|
||||
fs.writeFileSync(configPath, JSON.stringify({
|
||||
'recommendations': recommendedExtensions,
|
||||
'unwantedRecommendations': ignoredRecommendations,
|
||||
}, null, '\t'));
|
||||
|
||||
const myWorkspace = testWorkspace(URI.from({ scheme: 'file', path: folderDir }));
|
||||
workspaceService = new TestContextService(myWorkspace);
|
||||
instantiationService.stub(IWorkspaceContextService, workspaceService);
|
||||
const fileService = new FileService(new NullLogService());
|
||||
fileService.registerProvider(Schemas.file, new DiskFileSystemProvider(new NullLogService()));
|
||||
instantiationService.stub(IFileService, fileService);
|
||||
}
|
||||
|
||||
function testNoPromptForValidRecommendations(recommendations: string[]) {
|
||||
return setUpFolderWorkspace('myFolder', recommendations).then(() => {
|
||||
testObject = instantiationService.createInstance(ExtensionTipsService);
|
||||
return testObject.loadWorkspaceConfigPromise.then(() => {
|
||||
assert.equal(Object.keys(testObject.getAllRecommendationsWithReason()).length, recommendations.length);
|
||||
assert.ok(!prompted);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function testNoPromptOrRecommendationsForValidRecommendations(recommendations: string[]) {
|
||||
return setUpFolderWorkspace('myFolder', mockTestData.validRecommendedExtensions).then(() => {
|
||||
testObject = instantiationService.createInstance(ExtensionTipsService);
|
||||
assert.equal(!testObject.loadWorkspaceConfigPromise, true);
|
||||
assert.ok(!prompted);
|
||||
|
||||
return testObject.getWorkspaceRecommendations().then(() => {
|
||||
assert.equal(Object.keys(testObject.getAllRecommendationsWithReason()).length, 0);
|
||||
assert.ok(!prompted);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
test('ExtensionTipsService: No Prompt for valid workspace recommendations when galleryService is absent', () => {
|
||||
const galleryQuerySpy = sinon.spy();
|
||||
instantiationService.stub(IExtensionGalleryService, { query: galleryQuerySpy, isEnabled: () => false });
|
||||
|
||||
return testNoPromptOrRecommendationsForValidRecommendations(mockTestData.validRecommendedExtensions)
|
||||
.then(() => assert.ok(galleryQuerySpy.notCalled));
|
||||
});
|
||||
|
||||
test('ExtensionTipsService: No Prompt for valid workspace recommendations during extension development', () => {
|
||||
instantiationService.stub(IEnvironmentService, { extensionDevelopmentLocationURI: [URI.file('/folder/file')] });
|
||||
return testNoPromptOrRecommendationsForValidRecommendations(mockTestData.validRecommendedExtensions);
|
||||
});
|
||||
|
||||
test('ExtensionTipsService: No workspace recommendations or prompts when extensions.json has empty array', () => {
|
||||
return testNoPromptForValidRecommendations([]);
|
||||
});
|
||||
|
||||
test('ExtensionTipsService: Prompt for valid workspace recommendations', () => {
|
||||
return setUpFolderWorkspace('myFolder', mockTestData.recommendedExtensions).then(() => {
|
||||
testObject = instantiationService.createInstance(ExtensionTipsService);
|
||||
return testObject.loadWorkspaceConfigPromise.then(() => {
|
||||
const recommendations = Object.keys(testObject.getAllRecommendationsWithReason());
|
||||
|
||||
assert.equal(recommendations.length, mockTestData.validRecommendedExtensions.length);
|
||||
mockTestData.validRecommendedExtensions.forEach(x => {
|
||||
assert.equal(recommendations.indexOf(x.toLowerCase()) > -1, true);
|
||||
});
|
||||
|
||||
assert.ok(prompted);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
test('ExtensionTipsService: No Prompt for valid workspace recommendations if they are already installed', () => {
|
||||
instantiationService.stubPromise(IExtensionManagementService, 'getInstalled', mockExtensionLocal);
|
||||
return testNoPromptForValidRecommendations(mockTestData.validRecommendedExtensions);
|
||||
});
|
||||
|
||||
test('ExtensionTipsService: No Prompt for valid workspace recommendations with casing mismatch if they are already installed', () => {
|
||||
instantiationService.stubPromise(IExtensionManagementService, 'getInstalled', mockExtensionLocal);
|
||||
return testNoPromptForValidRecommendations(mockTestData.validRecommendedExtensions.map(x => x.toUpperCase()));
|
||||
});
|
||||
|
||||
test('ExtensionTipsService: No Prompt for valid workspace recommendations if ignoreRecommendations is set', () => {
|
||||
testConfigurationService.setUserConfiguration(ConfigurationKey, { ignoreRecommendations: true });
|
||||
return testNoPromptForValidRecommendations(mockTestData.validRecommendedExtensions);
|
||||
});
|
||||
|
||||
test('ExtensionTipsService: No Prompt for valid workspace recommendations if showRecommendationsOnlyOnDemand is set', () => {
|
||||
testConfigurationService.setUserConfiguration(ConfigurationKey, { showRecommendationsOnlyOnDemand: true });
|
||||
return setUpFolderWorkspace('myFolder', mockTestData.validRecommendedExtensions).then(() => {
|
||||
testObject = instantiationService.createInstance(ExtensionTipsService);
|
||||
return testObject.loadWorkspaceConfigPromise.then(() => {
|
||||
assert.equal(Object.keys(testObject.getAllRecommendationsWithReason()).length, 0);
|
||||
assert.ok(!prompted);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
test('ExtensionTipsService: No Prompt for valid workspace recommendations if ignoreRecommendations is set for current workspace', () => {
|
||||
instantiationService.stub(IStorageService, <Partial<IStorageService>>{ get: (a: string, b: StorageScope, c?: string) => c, getBoolean: (a: string, b: StorageScope, c?: boolean) => a === 'extensionsAssistant/workspaceRecommendationsIgnore' || c });
|
||||
return testNoPromptForValidRecommendations(mockTestData.validRecommendedExtensions);
|
||||
});
|
||||
|
||||
test('ExtensionTipsService: No Recommendations of globally ignored recommendations', () => {
|
||||
const storageGetterStub = (a: string, _: StorageScope, c?: string) => {
|
||||
const storedRecommendations = '["ms-vscode.csharp", "ms-python.python", "ms-vscode.vscode-typescript-tslint-plugin"]';
|
||||
const ignoredRecommendations = '["ms-vscode.csharp", "mockpublisher2.mockextension2"]'; // ignore a stored recommendation and a workspace recommendation.
|
||||
if (a === 'extensionsAssistant/recommendations') { return storedRecommendations; }
|
||||
if (a === 'extensionsAssistant/ignored_recommendations') { return ignoredRecommendations; }
|
||||
return c;
|
||||
};
|
||||
|
||||
instantiationService.stub(IStorageService, <Partial<IStorageService>>{
|
||||
get: storageGetterStub,
|
||||
getBoolean: (a: string, _: StorageScope, c?: boolean) => a === 'extensionsAssistant/workspaceRecommendationsIgnore' || c
|
||||
});
|
||||
|
||||
return setUpFolderWorkspace('myFolder', mockTestData.validRecommendedExtensions).then(() => {
|
||||
testObject = instantiationService.createInstance(ExtensionTipsService);
|
||||
return testObject.loadWorkspaceConfigPromise.then(() => {
|
||||
const recommendations = testObject.getAllRecommendationsWithReason();
|
||||
assert.ok(!recommendations['ms-vscode.csharp']); // stored recommendation that has been globally ignored
|
||||
assert.ok(recommendations['ms-python.python']); // stored recommendation
|
||||
assert.ok(recommendations['mockpublisher1.mockextension1']); // workspace recommendation
|
||||
assert.ok(!recommendations['mockpublisher2.mockextension2']); // workspace recommendation that has been globally ignored
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
test('ExtensionTipsService: No Recommendations of workspace ignored recommendations', () => {
|
||||
const ignoredRecommendations = ['ms-vscode.csharp', 'mockpublisher2.mockextension2']; // ignore a stored recommendation and a workspace recommendation.
|
||||
const storedRecommendations = '["ms-vscode.csharp", "ms-python.python"]';
|
||||
instantiationService.stub(IStorageService, <Partial<IStorageService>>{
|
||||
get: (a: string, b: StorageScope, c?: string) => a === 'extensionsAssistant/recommendations' ? storedRecommendations : c,
|
||||
getBoolean: (a: string, _: StorageScope, c?: boolean) => a === 'extensionsAssistant/workspaceRecommendationsIgnore' || c
|
||||
});
|
||||
|
||||
return setUpFolderWorkspace('myFolder', mockTestData.validRecommendedExtensions, ignoredRecommendations).then(() => {
|
||||
testObject = instantiationService.createInstance(ExtensionTipsService);
|
||||
return testObject.loadWorkspaceConfigPromise.then(() => {
|
||||
const recommendations = testObject.getAllRecommendationsWithReason();
|
||||
assert.ok(!recommendations['ms-vscode.csharp']); // stored recommendation that has been workspace ignored
|
||||
assert.ok(recommendations['ms-python.python']); // stored recommendation
|
||||
assert.ok(recommendations['mockpublisher1.mockextension1']); // workspace recommendation
|
||||
assert.ok(!recommendations['mockpublisher2.mockextension2']); // workspace recommendation that has been workspace ignored
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
test('ExtensionTipsService: Able to retrieve collection of all ignored recommendations', () => {
|
||||
|
||||
const storageGetterStub = (a: string, _: StorageScope, c?: string) => {
|
||||
const storedRecommendations = '["ms-vscode.csharp", "ms-python.python"]';
|
||||
const globallyIgnoredRecommendations = '["mockpublisher2.mockextension2"]'; // ignore a workspace recommendation.
|
||||
if (a === 'extensionsAssistant/recommendations') { return storedRecommendations; }
|
||||
if (a === 'extensionsAssistant/ignored_recommendations') { return globallyIgnoredRecommendations; }
|
||||
return c;
|
||||
};
|
||||
|
||||
const workspaceIgnoredRecommendations = ['ms-vscode.csharp']; // ignore a stored recommendation and a workspace recommendation.
|
||||
instantiationService.stub(IStorageService, <Partial<IStorageService>>{
|
||||
get: storageGetterStub,
|
||||
getBoolean: (a: string, _: StorageScope, c?: boolean) => a === 'extensionsAssistant/workspaceRecommendationsIgnore' || c
|
||||
});
|
||||
|
||||
return setUpFolderWorkspace('myFolder', mockTestData.validRecommendedExtensions, workspaceIgnoredRecommendations).then(() => {
|
||||
testObject = instantiationService.createInstance(ExtensionTipsService);
|
||||
return testObject.loadWorkspaceConfigPromise.then(() => {
|
||||
const recommendations = testObject.getAllRecommendationsWithReason();
|
||||
assert.ok(recommendations['ms-python.python']);
|
||||
|
||||
assert.ok(!recommendations['mockpublisher2.mockextension2']);
|
||||
assert.ok(!recommendations['ms-vscode.csharp']);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
test('ExtensionTipsService: Able to dynamically ignore/unignore global recommendations', () => {
|
||||
const storageGetterStub = (a: string, _: StorageScope, c?: string) => {
|
||||
const storedRecommendations = '["ms-vscode.csharp", "ms-python.python"]';
|
||||
const globallyIgnoredRecommendations = '["mockpublisher2.mockextension2"]'; // ignore a workspace recommendation.
|
||||
if (a === 'extensionsAssistant/recommendations') { return storedRecommendations; }
|
||||
if (a === 'extensionsAssistant/ignored_recommendations') { return globallyIgnoredRecommendations; }
|
||||
return c;
|
||||
};
|
||||
|
||||
instantiationService.stub(IStorageService, <Partial<IStorageService>>{
|
||||
get: storageGetterStub,
|
||||
store: () => { },
|
||||
getBoolean: (a: string, _: StorageScope, c?: boolean) => a === 'extensionsAssistant/workspaceRecommendationsIgnore' || c
|
||||
});
|
||||
|
||||
return setUpFolderWorkspace('myFolder', mockTestData.validRecommendedExtensions).then(() => {
|
||||
testObject = instantiationService.createInstance(ExtensionTipsService);
|
||||
return testObject.loadWorkspaceConfigPromise.then(() => {
|
||||
const recommendations = testObject.getAllRecommendationsWithReason();
|
||||
assert.ok(recommendations['ms-python.python']);
|
||||
assert.ok(recommendations['mockpublisher1.mockextension1']);
|
||||
|
||||
assert.ok(!recommendations['mockpublisher2.mockextension2']);
|
||||
|
||||
return testObject.toggleIgnoredRecommendation('mockpublisher1.mockextension1', true);
|
||||
}).then(() => {
|
||||
const recommendations = testObject.getAllRecommendationsWithReason();
|
||||
assert.ok(recommendations['ms-python.python']);
|
||||
|
||||
assert.ok(!recommendations['mockpublisher1.mockextension1']);
|
||||
assert.ok(!recommendations['mockpublisher2.mockextension2']);
|
||||
|
||||
return testObject.toggleIgnoredRecommendation('mockpublisher1.mockextension1', false);
|
||||
}).then(() => {
|
||||
const recommendations = testObject.getAllRecommendationsWithReason();
|
||||
assert.ok(recommendations['ms-python.python']);
|
||||
|
||||
assert.ok(recommendations['mockpublisher1.mockextension1']);
|
||||
assert.ok(!recommendations['mockpublisher2.mockextension2']);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
test('test global extensions are modified and recommendation change event is fired when an extension is ignored', () => {
|
||||
const storageSetterTarget = sinon.spy();
|
||||
const changeHandlerTarget = sinon.spy();
|
||||
const ignoredExtensionId = 'Some.Extension';
|
||||
instantiationService.stub(IStorageService, <any>{ // {{SQL CARBON EDIT}} strict-null-checks?
|
||||
get: (a: string, b: StorageScope, c?: boolean) => a === 'extensionsAssistant/ignored_recommendations' ? '["ms-vscode.vscode"]' : c,
|
||||
store: (...args: any[]) => {
|
||||
storageSetterTarget(...args);
|
||||
}
|
||||
});
|
||||
|
||||
return setUpFolderWorkspace('myFolder', []).then(() => {
|
||||
testObject = instantiationService.createInstance(ExtensionTipsService);
|
||||
testObject.onRecommendationChange(changeHandlerTarget);
|
||||
testObject.toggleIgnoredRecommendation(ignoredExtensionId, true);
|
||||
|
||||
assert.ok(changeHandlerTarget.calledOnce);
|
||||
assert.ok(changeHandlerTarget.getCall(0).calledWithMatch({ extensionId: 'Some.Extension', isRecommended: false }));
|
||||
assert.ok(storageSetterTarget.calledWithExactly('extensionsAssistant/ignored_recommendations', `["ms-vscode.vscode","${ignoredExtensionId.toLowerCase()}"]`, StorageScope.GLOBAL));
|
||||
});
|
||||
});
|
||||
|
||||
test('ExtensionTipsService: Get file based recommendations from storage (old format)', () => {
|
||||
const storedRecommendations = '["ms-vscode.csharp", "ms-python.python", "ms-vscode.vscode-typescript-tslint-plugin"]';
|
||||
instantiationService.stub(IStorageService, <Partial<IStorageService>>{ get: (a: string, b: StorageScope, c?: string) => a === 'extensionsAssistant/recommendations' ? storedRecommendations : c });
|
||||
|
||||
return setUpFolderWorkspace('myFolder', []).then(() => {
|
||||
testObject = instantiationService.createInstance(ExtensionTipsService);
|
||||
return testObject.loadWorkspaceConfigPromise.then(() => {
|
||||
const recommendations = testObject.getFileBasedRecommendations();
|
||||
assert.equal(recommendations.length, 2);
|
||||
assert.ok(recommendations.some(({ extensionId }) => extensionId === 'ms-vscode.csharp')); // stored recommendation that exists in product.extensionTips
|
||||
assert.ok(recommendations.some(({ extensionId }) => extensionId === 'ms-python.python')); // stored recommendation that exists in product.extensionImportantTips
|
||||
assert.ok(recommendations.every(({ extensionId }) => extensionId !== 'ms-vscode.vscode-typescript-tslint-plugin')); // stored recommendation that is no longer in neither product.extensionTips nor product.extensionImportantTips
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
test('ExtensionTipsService: Get file based recommendations from storage (new format)', () => {
|
||||
const milliSecondsInADay = 1000 * 60 * 60 * 24;
|
||||
const now = Date.now();
|
||||
const tenDaysOld = 10 * milliSecondsInADay;
|
||||
const storedRecommendations = `{"ms-vscode.csharp": ${now}, "ms-python.python": ${now}, "ms-vscode.vscode-typescript-tslint-plugin": ${now}, "lukehoban.Go": ${tenDaysOld}}`;
|
||||
instantiationService.stub(IStorageService, <Partial<IStorageService>>{ get: (a: string, b: StorageScope, c?: string) => a === 'extensionsAssistant/recommendations' ? storedRecommendations : c });
|
||||
|
||||
return setUpFolderWorkspace('myFolder', []).then(() => {
|
||||
testObject = instantiationService.createInstance(ExtensionTipsService);
|
||||
return testObject.loadWorkspaceConfigPromise.then(() => {
|
||||
const recommendations = testObject.getFileBasedRecommendations();
|
||||
assert.equal(recommendations.length, 2);
|
||||
assert.ok(recommendations.some(({ extensionId }) => extensionId === 'ms-vscode.csharp')); // stored recommendation that exists in product.extensionTips
|
||||
assert.ok(recommendations.some(({ extensionId }) => extensionId === 'ms-python.python')); // stored recommendation that exists in product.extensionImportantTips
|
||||
assert.ok(recommendations.every(({ extensionId }) => extensionId !== 'ms-vscode.vscode-typescript-tslint-plugin')); // stored recommendation that is no longer in neither product.extensionTips nor product.extensionImportantTips
|
||||
assert.ok(recommendations.every(({ extensionId }) => extensionId !== 'lukehoban.Go')); //stored recommendation that is older than a week
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -9,8 +9,228 @@ import { EDITOR_FONT_DEFAULTS } from 'vs/editor/common/config/editorOptions';
|
||||
import { TestConfigurationService } from 'vs/platform/configuration/test/common/testConfigurationService';
|
||||
import { LinuxDistro } from 'vs/workbench/contrib/terminal/common/terminal';
|
||||
|
||||
suite('Workbench - TerminalConfigHelper', () => {
|
||||
test('TerminalConfigHelper - getFont fontFamily', function () {
|
||||
// {{SQL CARBON EDIT}} - Remove tests
|
||||
suite.skip('Workbench - TerminalConfigHelper', () => { // {{SQL CARBON EDIT}} skip suite
|
||||
let fixture: HTMLElement;
|
||||
|
||||
setup(() => {
|
||||
fixture = document.body;
|
||||
});
|
||||
|
||||
// test('TerminalConfigHelper - getFont fontFamily', function () {
|
||||
// const configurationService = new TestConfigurationService();
|
||||
// configurationService.setUserConfiguration('editor', { fontFamily: 'foo' });
|
||||
// configurationService.setUserConfiguration('terminal', { integrated: { fontFamily: 'bar' } });
|
||||
// const configHelper = new TerminalConfigHelper(LinuxDistro.Unknown, configurationService, null!, null!, null!);
|
||||
// configHelper.panelContainer = fixture;
|
||||
// assert.equal(configHelper.getFont().fontFamily, 'bar', 'terminal.integrated.fontFamily should be selected over editor.fontFamily');
|
||||
// });
|
||||
|
||||
test('TerminalConfigHelper - getFont fontFamily (Linux Fedora)', function () {
|
||||
const configurationService = new TestConfigurationService();
|
||||
configurationService.setUserConfiguration('editor', { fontFamily: 'foo' });
|
||||
configurationService.setUserConfiguration('terminal', { integrated: { fontFamily: null } });
|
||||
const configHelper = new TerminalConfigHelper(LinuxDistro.Fedora, configurationService, null!, null!, null!);
|
||||
configHelper.panelContainer = fixture;
|
||||
assert.equal(configHelper.getFont().fontFamily, '\'DejaVu Sans Mono\', monospace', 'Fedora should have its font overridden when terminal.integrated.fontFamily not set');
|
||||
});
|
||||
|
||||
test('TerminalConfigHelper - getFont fontFamily (Linux Ubuntu)', function () {
|
||||
const configurationService = new TestConfigurationService();
|
||||
configurationService.setUserConfiguration('editor', { fontFamily: 'foo' });
|
||||
configurationService.setUserConfiguration('terminal', { integrated: { fontFamily: null } });
|
||||
const configHelper = new TerminalConfigHelper(LinuxDistro.Ubuntu, configurationService, null!, null!, null!);
|
||||
configHelper.panelContainer = fixture;
|
||||
assert.equal(configHelper.getFont().fontFamily, '\'Ubuntu Mono\', monospace', 'Ubuntu should have its font overridden when terminal.integrated.fontFamily not set');
|
||||
});
|
||||
|
||||
test('TerminalConfigHelper - getFont fontFamily (Linux Unknown)', function () {
|
||||
const configurationService = new TestConfigurationService();
|
||||
configurationService.setUserConfiguration('editor', { fontFamily: 'foo' });
|
||||
configurationService.setUserConfiguration('terminal', { integrated: { fontFamily: null } });
|
||||
const configHelper = new TerminalConfigHelper(LinuxDistro.Unknown, configurationService, null!, null!, null!);
|
||||
configHelper.panelContainer = fixture;
|
||||
assert.equal(configHelper.getFont().fontFamily, 'foo', 'editor.fontFamily should be the fallback when terminal.integrated.fontFamily not set');
|
||||
});
|
||||
|
||||
test('TerminalConfigHelper - getFont fontSize', function () {
|
||||
const configurationService = new TestConfigurationService();
|
||||
|
||||
configurationService.setUserConfiguration('editor', {
|
||||
fontFamily: 'foo',
|
||||
fontSize: 9
|
||||
});
|
||||
configurationService.setUserConfiguration('terminal', {
|
||||
integrated: {
|
||||
fontFamily: 'bar',
|
||||
fontSize: 10
|
||||
}
|
||||
});
|
||||
let configHelper = new TerminalConfigHelper(LinuxDistro.Unknown, configurationService, null!, null!, null!);
|
||||
configHelper.panelContainer = fixture;
|
||||
assert.equal(configHelper.getFont().fontSize, 10, 'terminal.integrated.fontSize should be selected over editor.fontSize');
|
||||
|
||||
configurationService.setUserConfiguration('editor', {
|
||||
fontFamily: 'foo'
|
||||
});
|
||||
configurationService.setUserConfiguration('terminal', {
|
||||
integrated: {
|
||||
fontFamily: null,
|
||||
fontSize: 0
|
||||
}
|
||||
});
|
||||
configHelper = new TerminalConfigHelper(LinuxDistro.Ubuntu, configurationService, null!, null!, null!);
|
||||
configHelper.panelContainer = fixture;
|
||||
assert.equal(configHelper.getFont().fontSize, 8, 'The minimum terminal font size (with adjustment) should be used when terminal.integrated.fontSize less than it');
|
||||
|
||||
configHelper = new TerminalConfigHelper(LinuxDistro.Unknown, configurationService, null!, null!, null!);
|
||||
configHelper.panelContainer = fixture;
|
||||
assert.equal(configHelper.getFont().fontSize, 6, 'The minimum terminal font size should be used when terminal.integrated.fontSize less than it');
|
||||
|
||||
configurationService.setUserConfiguration('editor', {
|
||||
fontFamily: 'foo'
|
||||
});
|
||||
configurationService.setUserConfiguration('terminal', {
|
||||
integrated: {
|
||||
fontFamily: 0,
|
||||
fontSize: 1500
|
||||
}
|
||||
});
|
||||
configHelper = new TerminalConfigHelper(LinuxDistro.Unknown, configurationService, null!, null!, null!);
|
||||
configHelper.panelContainer = fixture;
|
||||
assert.equal(configHelper.getFont().fontSize, 25, 'The maximum terminal font size should be used when terminal.integrated.fontSize more than it');
|
||||
|
||||
configurationService.setUserConfiguration('editor', {
|
||||
fontFamily: 'foo'
|
||||
});
|
||||
configurationService.setUserConfiguration('terminal', {
|
||||
integrated: {
|
||||
fontFamily: 0,
|
||||
fontSize: null
|
||||
}
|
||||
});
|
||||
configHelper = new TerminalConfigHelper(LinuxDistro.Ubuntu, configurationService, null!, null!, null!);
|
||||
configHelper.panelContainer = fixture;
|
||||
assert.equal(configHelper.getFont().fontSize, EDITOR_FONT_DEFAULTS.fontSize + 2, 'The default editor font size (with adjustment) should be used when terminal.integrated.fontSize is not set');
|
||||
|
||||
configHelper = new TerminalConfigHelper(LinuxDistro.Unknown, configurationService, null!, null!, null!);
|
||||
configHelper.panelContainer = fixture;
|
||||
assert.equal(configHelper.getFont().fontSize, EDITOR_FONT_DEFAULTS.fontSize, 'The default editor font size should be used when terminal.integrated.fontSize is not set');
|
||||
});
|
||||
|
||||
test('TerminalConfigHelper - getFont lineHeight', function () {
|
||||
const configurationService = new TestConfigurationService();
|
||||
|
||||
configurationService.setUserConfiguration('editor', {
|
||||
fontFamily: 'foo',
|
||||
lineHeight: 1
|
||||
});
|
||||
configurationService.setUserConfiguration('terminal', {
|
||||
integrated: {
|
||||
fontFamily: 0,
|
||||
lineHeight: 2
|
||||
}
|
||||
});
|
||||
let configHelper = new TerminalConfigHelper(LinuxDistro.Unknown, configurationService, null!, null!, null!);
|
||||
configHelper.panelContainer = fixture;
|
||||
assert.equal(configHelper.getFont().lineHeight, 2, 'terminal.integrated.lineHeight should be selected over editor.lineHeight');
|
||||
|
||||
configurationService.setUserConfiguration('editor', {
|
||||
fontFamily: 'foo',
|
||||
lineHeight: 1
|
||||
});
|
||||
configurationService.setUserConfiguration('terminal', {
|
||||
integrated: {
|
||||
fontFamily: 0,
|
||||
lineHeight: 0
|
||||
}
|
||||
});
|
||||
configHelper = new TerminalConfigHelper(LinuxDistro.Unknown, configurationService, null!, null!, null!);
|
||||
configHelper.panelContainer = fixture;
|
||||
assert.equal(configHelper.getFont().lineHeight, 1, 'editor.lineHeight should be 1 when terminal.integrated.lineHeight not set');
|
||||
});
|
||||
|
||||
test('TerminalConfigHelper - isMonospace monospace', function () {
|
||||
const configurationService = new TestConfigurationService();
|
||||
configurationService.setUserConfiguration('terminal', {
|
||||
integrated: {
|
||||
fontFamily: 'monospace'
|
||||
}
|
||||
});
|
||||
|
||||
let configHelper = new TerminalConfigHelper(LinuxDistro.Unknown, configurationService, null!, null!, null!);
|
||||
configHelper.panelContainer = fixture;
|
||||
assert.equal(configHelper.configFontIsMonospace(), true, 'monospace is monospaced');
|
||||
});
|
||||
|
||||
test('TerminalConfigHelper - isMonospace sans-serif', function () {
|
||||
const configurationService = new TestConfigurationService();
|
||||
configurationService.setUserConfiguration('terminal', {
|
||||
integrated: {
|
||||
fontFamily: 'sans-serif'
|
||||
}
|
||||
});
|
||||
let configHelper = new TerminalConfigHelper(LinuxDistro.Unknown, configurationService, null!, null!, null!);
|
||||
configHelper.panelContainer = fixture;
|
||||
assert.equal(configHelper.configFontIsMonospace(), false, 'sans-serif is not monospaced');
|
||||
});
|
||||
|
||||
test('TerminalConfigHelper - isMonospace serif', function () {
|
||||
const configurationService = new TestConfigurationService();
|
||||
configurationService.setUserConfiguration('terminal', {
|
||||
integrated: {
|
||||
fontFamily: 'serif'
|
||||
}
|
||||
});
|
||||
let configHelper = new TerminalConfigHelper(LinuxDistro.Unknown, configurationService, null!, null!, null!);
|
||||
configHelper.panelContainer = fixture;
|
||||
assert.equal(configHelper.configFontIsMonospace(), false, 'serif is not monospaced');
|
||||
});
|
||||
|
||||
test('TerminalConfigHelper - isMonospace monospace falls back to editor.fontFamily', function () {
|
||||
const configurationService = new TestConfigurationService();
|
||||
configurationService.setUserConfiguration('editor', {
|
||||
fontFamily: 'monospace'
|
||||
});
|
||||
configurationService.setUserConfiguration('terminal', {
|
||||
integrated: {
|
||||
fontFamily: null
|
||||
}
|
||||
});
|
||||
|
||||
let configHelper = new TerminalConfigHelper(LinuxDistro.Unknown, configurationService, null!, null!, null!);
|
||||
configHelper.panelContainer = fixture;
|
||||
assert.equal(configHelper.configFontIsMonospace(), true, 'monospace is monospaced');
|
||||
});
|
||||
|
||||
test('TerminalConfigHelper - isMonospace sans-serif falls back to editor.fontFamily', function () {
|
||||
const configurationService = new TestConfigurationService();
|
||||
configurationService.setUserConfiguration('editor', {
|
||||
fontFamily: 'sans-serif'
|
||||
});
|
||||
configurationService.setUserConfiguration('terminal', {
|
||||
integrated: {
|
||||
fontFamily: null
|
||||
}
|
||||
});
|
||||
|
||||
let configHelper = new TerminalConfigHelper(LinuxDistro.Unknown, configurationService, null!, null!, null!);
|
||||
configHelper.panelContainer = fixture;
|
||||
assert.equal(configHelper.configFontIsMonospace(), false, 'sans-serif is not monospaced');
|
||||
});
|
||||
|
||||
test('TerminalConfigHelper - isMonospace serif falls back to editor.fontFamily', function () {
|
||||
const configurationService = new TestConfigurationService();
|
||||
configurationService.setUserConfiguration('editor', {
|
||||
fontFamily: 'serif'
|
||||
});
|
||||
configurationService.setUserConfiguration('terminal', {
|
||||
integrated: {
|
||||
fontFamily: null
|
||||
}
|
||||
});
|
||||
|
||||
let configHelper = new TerminalConfigHelper(LinuxDistro.Unknown, configurationService, null!, null!, null!);
|
||||
configHelper.panelContainer = fixture;
|
||||
assert.equal(configHelper.configFontIsMonospace(), false, 'serif is not monospaced');
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user