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

add integration tests for typescript language #7265

Merged
merged 1 commit into from
Apr 1, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Change Log

## v1.1.0

Breaking changes:

- [plugin] removed `configStorage` argument from `PluginManager.registerPlugin`.
Use `PluginManager.configStorage` property instead. [#7265](https://github.com/eclipse-theia/theia/pull/7265#discussion_r399956070)

## v1.0.0

- [core] added functionality to ensure that nodes are refreshed properly on tree expansion [#7400](https://github.com/eclipse-theia/theia/pull/7400)
Expand Down
2 changes: 1 addition & 1 deletion dev-packages/application-manager/src/expose-loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export = function (this: webpack.loader.LoaderContext, source: string, sourceMap
this.cacheable();
}

let modulePackage = modulePackages.find(({ dir }) => this.resourcePath.startsWith(dir));
let modulePackage = modulePackages.find(({ dir }) => this.resourcePath.startsWith(dir + '/'));
if (modulePackage) {
this.callback(undefined, exposeModule(modulePackage, this.resourcePath, source), sourceMap);
return;
Expand Down
21 changes: 21 additions & 0 deletions examples/api-tests/src/api-tests.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/********************************************************************************
* Copyright (C) 2020 TypeFox and others.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* This Source Code may also be made available under the following Secondary
* Licenses when the conditions for such availability set forth in the Eclipse
* Public License v. 2.0 are satisfied: GNU General Public License, version 2
* with the GNU Classpath Exception which is available at
* https://www.gnu.org/software/classpath/license.html.
*
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
********************************************************************************/

interface Window {
theia: {
container: import('inversify').Container
}
}
11 changes: 6 additions & 5 deletions examples/api-tests/src/launch-preferences.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
********************************************************************************/

// @ts-check
/// <reference types='@theia/monaco/src/typings/monaco'/>

/* eslint-disable no-unused-expressions, @typescript-eslint/no-explicit-any */

/**
Expand All @@ -28,6 +26,7 @@
* See https://github.com/akosyakov/vscode-launch/blob/master/src/test/extension.test.ts
*/
describe('Launch Preferences', function () {
this.timeout(5000);

const { assert } = chai;

Expand All @@ -38,8 +37,7 @@ describe('Launch Preferences', function () {
const { MonacoTextModelService } = require('@theia/monaco/lib/browser/monaco-text-model-service');
const { MonacoWorkspace } = require('@theia/monaco/lib/browser/monaco-workspace');

/** @type {import('inversify').Container} */
const container = window['theia'].container;
const container = window.theia.container;
/** @type {import('@theia/core/lib/browser/preferences/preference-service').PreferenceService} */
const preferences = container.get(PreferenceService);
const workspaceService = container.get(WorkspaceService);
Expand Down Expand Up @@ -425,7 +423,7 @@ describe('Launch Preferences', function () {
]);
}

const client = fileSystem.getClient();
const client = /** @type {import('@theia/filesystem/lib/common/filesystem').FileSystemClient} */ (fileSystem.getClient());
const originalShouldOverwrite = client.shouldOverwrite;

before(async () => {
Expand Down Expand Up @@ -460,6 +458,7 @@ describe('Launch Preferences', function () {
/** @typedef {monaco.editor.IReference<import('@theia/monaco/lib/browser/monaco-editor-model').MonacoEditorModel>} ConfigModelReference */
/** @type {ConfigModelReference[]} */
beforeEach(async () => {
/** @type {Promise<void>[]} */
const promises = [];
/**
* @param {string} name
Expand Down Expand Up @@ -507,11 +506,13 @@ describe('Launch Preferences', function () {
});

testIt('get from undefined', () => {
/** @type {any} */
const config = preferences.get('launch', undefined, undefined);
assert.deepStrictEqual(JSON.parse(JSON.stringify(config)), expectation);
});

testIt('get from rootUri', () => {
/** @type {any} */
const config = preferences.get('launch', undefined, rootUri.toString());
assert.deepStrictEqual(JSON.parse(JSON.stringify(config)), expectation);
});
Expand Down
5 changes: 2 additions & 3 deletions examples/api-tests/src/menus.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,10 @@ describe('Menus', function () {
const { ProblemContribution } = require('@theia/markers/lib/browser/problem/problem-contribution');
const { SearchInWorkspaceFrontendContribution } = require('@theia/search-in-workspace/lib/browser/search-in-workspace-frontend-contribution');

/** @type {import('inversify').Container} */
const container = window['theia'].container;
const container = window.theia.container;
const shell = container.get(ApplicationShell);
const menuBarContribution = container.get(BrowserMenuBarContribution);
const menuBar = menuBarContribution.menuBar;
const menuBar = /** @type {import('@theia/core/lib/browser/menu/browser-menu-plugin').MenuBarWidget} */ (menuBarContribution.menuBar);

for (const contribution of [
container.get(CallHierarchyContribution),
Expand Down
50 changes: 25 additions & 25 deletions examples/api-tests/src/monaco-api.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
********************************************************************************/

// @ts-check
/// <reference types='@theia/monaco/src/typings/monaco'/>
describe('Monaco API', async function () {
this.timeout(5000);

const { assert } = chai;

Expand All @@ -27,8 +27,7 @@ describe('Monaco API', async function () {
const { MonacoResolvedKeybinding } = require('@theia/monaco/lib/browser/monaco-resolved-keybinding');
const { MonacoTextmateService } = require('@theia/monaco/lib/browser/textmate/monaco-textmate-service');

/** @type {import('inversify').Container} */
const container = window['theia'].container;
const container = window.theia.container;
const editorManager = container.get(EditorManager);
const workspaceService = container.get(WorkspaceService);
const textmateService = container.get(MonacoTextmateService);
Expand All @@ -40,7 +39,7 @@ describe('Monaco API', async function () {
const editor = await editorManager.open(new Uri.default(root.uri).resolve('package.json'), {
mode: 'reveal'
});
monacoEditor = MonacoEditor.get(editor);
monacoEditor = /** @type {MonacoEditor} */ (MonacoEditor.get(editor));
});

it('KeybindingService.resolveKeybinding', () => {
Expand All @@ -65,24 +64,25 @@ describe('Monaco API', async function () {
assert.deepStrictEqual({
label, ariaLabel, electronAccelerator, userSettingsLabel, WYSIWYG, chord, parts, dispatchParts
}, {
label: "Ctrl+Shift+Alt+K",
ariaLabel: "Ctrl+Shift+Alt+K",
electronAccelerator: null,
userSettingsLabel: "ctrl+shift+alt+K",
WYSIWYG: true,
chord: false,
parts: [{
altKey: true,
ctrlKey: true,
keyAriaLabel: "K",
keyLabel: "K",
metaKey: false,
shiftKey: true
}],
dispatchParts: [
"ctrl+shift+alt+K"
]
});
label: 'Ctrl+Shift+Alt+K',
ariaLabel: 'Ctrl+Shift+Alt+K',
// eslint-disable-next-line no-null/no-null
electronAccelerator: null,
userSettingsLabel: 'ctrl+shift+alt+K',
WYSIWYG: true,
chord: false,
parts: [{
altKey: true,
ctrlKey: true,
keyAriaLabel: 'K',
keyLabel: 'K',
metaKey: false,
shiftKey: true
}],
dispatchParts: [
'ctrl+shift+alt+K'
]
});
} else {
assert.fail(`resolvedKeybinding must be of ${MonacoResolvedKeybinding.name} type`);
}
Expand All @@ -94,16 +94,16 @@ describe('Monaco API', async function () {
const toDispose = monaco.modes.TokenizationRegistry.onDidChange(() => {
toDispose.dispose();
resolve();
})
});
});
textmateService['themeService'].setCurrentTheme('light');
await didChangeColorMap;
}

const textMateColorMap = textmateService['grammarRegistry'].getColorMap();
assert.notEqual(textMateColorMap.indexOf('#795E26'), -1, 'Expected custom toke colors for the ligth theme to be enabled.')
assert.notEqual(textMateColorMap.indexOf('#795E26'), -1, 'Expected custom toke colors for the ligth theme to be enabled.');

const monacoColorMap = monaco.modes.TokenizationRegistry.getColorMap().
const monacoColorMap = (monaco.modes.TokenizationRegistry.getColorMap() || []).
splice(0, textMateColorMap.length).map(c => c.toString().toUpperCase());
assert.deepStrictEqual(monacoColorMap, textMateColorMap, 'Expected textmate colors to have the same index in the monaco color map.');
});
Expand Down
29 changes: 14 additions & 15 deletions examples/api-tests/src/saveable.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,21 @@

// @ts-check
describe('Saveable', function () {
this.timeout(5000);

const { assert } = chai;

const { EditorManager } = require('@theia/editor/lib/browser/editor-manager');
const { EditorWidget } = require('@theia/editor/lib/browser/editor-widget');
const { PreferenceService, PreferenceScope } = require('@theia/core/lib/browser/preferences/preference-service');
const { PreferenceService } = require('@theia/core/lib/browser/preferences/preference-service');
const Uri = require('@theia/core/lib/common/uri');
const { Saveable, SaveableWidget } = require('@theia/core/lib/browser/saveable');
const { WorkspaceService } = require('@theia/workspace/lib/browser/workspace-service');
const { FileSystem } = require('@theia/filesystem/lib/common/filesystem');
const { MonacoEditor } = require('@theia/monaco/lib/browser/monaco-editor');
const { DisposableCollection } = require('@theia/core/lib/common/disposable');
const { Deferred } = require('@theia/core/lib/common/promise-util');

/** @type {import('inversify').Container} */
const container = window['theia'].container;
const container = window.theia.container;
const editorManager = container.get(EditorManager);
const workspaceService = container.get(WorkspaceService);
/** @type {import('@theia/filesystem/lib/common/filesystem').FileSystem} */
Expand Down Expand Up @@ -79,9 +78,9 @@ describe('Saveable', function () {
assert.isTrue(Saveable.isDirty(widget), `should be dirty before '${edit}' save`);
await Saveable.save(widget);
assert.isFalse(Saveable.isDirty(widget), `should NOT be dirty after '${edit}' save`);
assert.equal(editor.getControl().getValue(), edit, `model should be updated with '${edit}'`);
assert.equal(editor.getControl().getValue().trimRight(), edit, `model should be updated with '${edit}'`);
const state = await fileSystem.resolveContent(fileUri.toString());
assert.equal(state.content, edit, `fs should be updated with '${edit}'`);
assert.equal(state.content.trimRight(), edit, `fs should be updated with '${edit}'`);
}
});

Expand Down Expand Up @@ -129,7 +128,7 @@ describe('Saveable', function () {
assert.isTrue(outOfSync, 'file should be out of sync');
assert.equal(outOfSyncCount, 1, 'user should be prompted only once with out of sync dialog');
assert.isTrue(Saveable.isDirty(widget), 'should be dirty after rejected save');
assert.equal(editor.getControl().getValue(), longContent.substring(3), 'model should be updated');
assert.equal(editor.getControl().getValue().trimRight(), longContent.substring(3), 'model should be updated');
const state = await fileSystem.resolveContent(fileUri.toString());
assert.equal(state.content, 'baz', 'fs should NOT be updated');
});
Expand All @@ -151,7 +150,7 @@ describe('Saveable', function () {
await Saveable.save(widget);
assert.isTrue(outOfSync, 'file should be out of sync');
assert.isTrue(Saveable.isDirty(widget), 'should be dirty after rejected save');
assert.equal(editor.getControl().getValue(), 'bar', 'model should be updated');
assert.equal(editor.getControl().getValue().trimRight(), 'bar', 'model should be updated');
let state = await fileSystem.resolveContent(fileUri.toString());
assert.equal(state.content, 'baz', 'fs should NOT be updated');

Expand All @@ -164,9 +163,9 @@ describe('Saveable', function () {
await Saveable.save(widget);
assert.isTrue(outOfSync, 'file should be out of sync');
assert.isFalse(Saveable.isDirty(widget), 'should NOT be dirty after save');
assert.equal(editor.getControl().getValue(), 'bar', 'model should be updated');
assert.equal(editor.getControl().getValue().trimRight(), 'bar', 'model should be updated');
state = await fileSystem.resolveContent(fileUri.toString());
assert.equal(state.content, 'bar', 'fs should be updated');
assert.equal(state.content.trimRight(), 'bar', 'fs should be updated');
});

it('accept new save', async () => {
Expand All @@ -181,9 +180,9 @@ describe('Saveable', function () {
await Saveable.save(widget);
assert.isTrue(outOfSync, 'file should be out of sync');
assert.isFalse(Saveable.isDirty(widget), 'should NOT be dirty after save');
assert.equal(editor.getControl().getValue(), 'bar', 'model should be updated');
assert.equal(editor.getControl().getValue().trimRight(), 'bar', 'model should be updated');
const state = await fileSystem.resolveContent(fileUri.toString());
assert.equal(state.content, 'bar', 'fs should be updated');
assert.equal(state.content.trimRight(), 'bar', 'fs should be updated');
});

it('cancel save on close', async () => {
Expand Down Expand Up @@ -243,7 +242,7 @@ describe('Saveable', function () {
assert.isTrue(outOfSync, 'file should be out of sync');
assert.isTrue(widget.isDisposed, 'model should be disposed after close');
const state = await fileSystem.resolveContent(fileUri.toString());
assert.equal(state.content, 'bar', 'fs should be updated');
assert.equal(state.content.trimRight(), 'bar', 'fs should be updated');
});

it('normal close', async () => {
Expand All @@ -254,7 +253,7 @@ describe('Saveable', function () {
});
assert.isTrue(widget.isDisposed, 'model should be disposed after close');
const state = await fileSystem.resolveContent(fileUri.toString());
assert.equal(state.content, 'bar', 'fs should be updated');
assert.equal(state.content.trimRight(), 'bar', 'fs should be updated');
});

it('delete file for saved', async () => {
Expand Down Expand Up @@ -320,7 +319,7 @@ describe('Saveable', function () {
assert.isFalse(Saveable.isDirty(widget), 'should NOT be dirty after save');
assert.isTrue(editor.document.valid, 'should be valid after save');
const state = await fileSystem.resolveContent(fileUri.toString());
assert.equal(state.content, 'bar', 'fs should be updated');
assert.equal(state.content.trimRight(), 'bar', 'fs should be updated');
});

it('move file for saved', async function () {
Expand Down
3 changes: 1 addition & 2 deletions examples/api-tests/src/shell.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ describe('Shell', function () {
const { ApplicationShell } = require('@theia/core/lib/browser/shell/application-shell');
const { StatusBarImpl } = require('@theia/core/lib/browser/status-bar');

/** @type {import('inversify').Container} */
const container = window['theia'].container;
const container = window.theia.container;
const shell = container.get(ApplicationShell);
const statusBar = container.get(StatusBarImpl);

Expand Down
Loading