@theia/api-tests 1.46.1 → 1.47.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@theia/api-tests",
3
- "version": "1.46.1",
3
+ "version": "1.47.0",
4
4
  "description": "Theia API tests",
5
5
  "dependencies": {
6
- "@theia/core": "1.46.1"
6
+ "@theia/core": "1.47.0"
7
7
  },
8
8
  "license": "EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0",
9
9
  "repository": {
@@ -20,5 +20,5 @@
20
20
  "publishConfig": {
21
21
  "access": "public"
22
22
  },
23
- "gitHead": "1799210a8fba6eb81e2ddaf66f09d6fa071df012"
23
+ "gitHead": "96685e37b5450a599370355ccffd4062cf1b72ab"
24
24
  }
@@ -26,7 +26,7 @@ describe('Monaco API', async function () {
26
26
  const { MonacoResolvedKeybinding } = require('@theia/monaco/lib/browser/monaco-resolved-keybinding');
27
27
  const { MonacoTextmateService } = require('@theia/monaco/lib/browser/textmate/monaco-textmate-service');
28
28
  const { CommandRegistry } = require('@theia/core/lib/common/command');
29
- const { SimpleKeybinding } = require('@theia/monaco-editor-core/esm/vs/base/common/keybindings');
29
+ const { KeyCodeChord, ResolvedChord } = require('@theia/monaco-editor-core/esm/vs/base/common/keybindings');
30
30
  const { IKeybindingService } = require('@theia/monaco-editor-core/esm/vs/platform/keybinding/common/keybinding');
31
31
  const { StandaloneServices } = require('@theia/monaco-editor-core/esm/vs/editor/standalone/browser/standaloneServices');
32
32
  const { TokenizationRegistry } = require('@theia/monaco-editor-core/esm/vs/editor/common/languages');
@@ -59,10 +59,10 @@ describe('Monaco API', async function () {
59
59
  });
60
60
 
61
61
  it('KeybindingService.resolveKeybinding', () => {
62
- const simpleKeybinding = new SimpleKeybinding(true, true, true, true, 41 /* KeyCode.KeyK */);
63
- const chordKeybinding = simpleKeybinding.toChord();
64
- assert.equal(chordKeybinding.parts.length, 1);
65
- assert.equal(chordKeybinding.parts[0], simpleKeybinding);
62
+ const chord = new KeyCodeChord(true, true, true, true, 41 /* KeyCode.KeyK */);
63
+ const chordKeybinding = chord.toKeybinding();
64
+ assert.equal(chordKeybinding.chords.length, 1);
65
+ assert.equal(chordKeybinding.chords[0], chord);
66
66
 
67
67
  const resolvedKeybindings = StandaloneServices.get(IKeybindingService).resolveKeybinding(chordKeybinding);
68
68
  assert.equal(resolvedKeybindings.length, 1);
@@ -74,9 +74,8 @@ describe('Monaco API', async function () {
74
74
  const electronAccelerator = resolvedKeybinding.getElectronAccelerator();
75
75
  const userSettingsLabel = resolvedKeybinding.getUserSettingsLabel();
76
76
  const WYSIWYG = resolvedKeybinding.isWYSIWYG();
77
- const chord = resolvedKeybinding.isChord();
78
- const parts = resolvedKeybinding.getParts();
79
- const dispatchParts = resolvedKeybinding.getDispatchParts();
77
+ const parts = resolvedKeybinding.getChords();
78
+ const dispatchParts = resolvedKeybinding.getDispatchChords().map(str => str === null ? '' : str);
80
79
 
81
80
  const platform = window.navigator.platform;
82
81
  let expected;
@@ -89,14 +88,14 @@ describe('Monaco API', async function () {
89
88
  userSettingsLabel: 'ctrl+shift+alt+cmd+K',
90
89
  WYSIWYG: true,
91
90
  chord: false,
92
- parts: [{
93
- altKey: true,
94
- ctrlKey: true,
95
- keyAriaLabel: 'K',
96
- keyLabel: 'K',
97
- metaKey: true,
98
- shiftKey: true
99
- }],
91
+ parts: [new ResolvedChord(
92
+ true,
93
+ true,
94
+ true,
95
+ true,
96
+ 'K',
97
+ 'K',
98
+ )],
100
99
  dispatchParts: [
101
100
  'ctrl+shift+alt+meta+K'
102
101
  ]
@@ -108,15 +107,14 @@ describe('Monaco API', async function () {
108
107
  electronAccelerator: 'Ctrl+Shift+Alt+K',
109
108
  userSettingsLabel: 'ctrl+shift+alt+K',
110
109
  WYSIWYG: true,
111
- chord: false,
112
- parts: [{
113
- altKey: true,
114
- ctrlKey: true,
115
- keyAriaLabel: 'K',
116
- keyLabel: 'K',
117
- metaKey: false,
118
- shiftKey: true
119
- }],
110
+ parts: [new ResolvedChord(
111
+ true,
112
+ true,
113
+ true,
114
+ false,
115
+ 'K',
116
+ 'K'
117
+ )],
120
118
  dispatchParts: [
121
119
  'ctrl+shift+alt+K'
122
120
  ]
@@ -124,7 +122,7 @@ describe('Monaco API', async function () {
124
122
  }
125
123
 
126
124
  assert.deepStrictEqual({
127
- label, ariaLabel, electronAccelerator, userSettingsLabel, WYSIWYG, chord, parts, dispatchParts
125
+ label, ariaLabel, electronAccelerator, userSettingsLabel, WYSIWYG, parts, dispatchParts
128
126
  }, expected);
129
127
  } else {
130
128
  assert.fail(`resolvedKeybinding must be of ${MonacoResolvedKeybinding.name} type`);
@@ -136,7 +134,7 @@ describe('Monaco API', async function () {
136
134
  const didChangeColorMap = new Promise(resolve => {
137
135
  const toDispose = TokenizationRegistry.onDidChange(() => {
138
136
  toDispose.dispose();
139
- resolve();
137
+ resolve(undefined);
140
138
  });
141
139
  });
142
140
  textmateService['themeService'].setCurrentTheme('light');
@@ -175,15 +173,15 @@ describe('Monaco API', async function () {
175
173
  });
176
174
 
177
175
  it('Supports setting contexts using the command registry', async () => {
178
- const setContext = 'setContext';
176
+ const setContext = '_setContext';
179
177
  const key = 'monaco-api-test-context';
180
178
  const firstValue = 'first setting';
181
179
  const secondValue = 'second setting';
182
- assert.isFalse(contextKeys.match(`${key} == ${firstValue}`));
180
+ assert.isFalse(contextKeys.match(`${key} == '${firstValue}'`));
183
181
  await commands.executeCommand(setContext, key, firstValue);
184
- assert.isTrue(contextKeys.match(`${key} == ${firstValue}`));
182
+ assert.isTrue(contextKeys.match(`${key} == '${firstValue}'`));
185
183
  await commands.executeCommand(setContext, key, secondValue);
186
- assert.isTrue(contextKeys.match(`${key} == ${secondValue}`));
184
+ assert.isTrue(contextKeys.match(`${key} == '${secondValue}'`));
187
185
  });
188
186
 
189
187
  it('Supports context key: inQuickOpen', async () => {
@@ -16,7 +16,7 @@
16
16
 
17
17
  // @ts-check
18
18
  describe('Saveable', function () {
19
- this.timeout(5000);
19
+ this.timeout(30000);
20
20
 
21
21
  const { assert } = chai;
22
22
 
@@ -119,19 +119,28 @@ describe('TypeScript', function () {
119
119
  */
120
120
  function waitForAnimation(condition, timeout, message) {
121
121
  const success = new Promise(async (resolve, reject) => {
122
+ if (timeout === undefined) {
123
+ timeout = 100000;
124
+ }
125
+
126
+ let timedOut = false;
127
+ const handle = setTimeout(() => {
128
+ console.log(message);
129
+ timedOut = true;
130
+ }, timeout);
131
+
122
132
  toTearDown.push({ dispose: () => reject(message ?? 'Test terminated before resolution.') });
123
133
  do {
124
134
  await animationFrame();
125
- } while (!condition());
126
- resolve();
135
+ } while (!timedOut && !condition());
136
+ if (timedOut) {
137
+ reject(new Error(message ?? 'Wait for animation timed out.'));
138
+ } else {
139
+ clearTimeout(handle);
140
+ resolve(undefined);
141
+ }
142
+
127
143
  });
128
- if (timeout !== undefined) {
129
- const timedOut = new Promise((_, fail) => {
130
- const toClear = setTimeout(() => fail(new Error(message ?? 'Wait for animation timed out.')), timeout);
131
- toTearDown.push({ dispose: () => (fail(new Error(message ?? 'Wait for animation timed out.')), clearTimeout(toClear)) });
132
- });
133
- return Promise.race([success, timedOut]);
134
- }
135
144
  return success;
136
145
  }
137
146
 
@@ -689,11 +698,10 @@ SPAN {
689
698
  editor.getControl().revealPosition({ lineNumber, column });
690
699
  assert.equal(currentChar(), ';', 'Failed at assert 1');
691
700
 
692
- /** @type {import('@theia/monaco-editor-core/src/vs/editor/contrib/codeAction/browser/codeActionCommands').CodeActionController} */
701
+ /** @type {import('@theia/monaco-editor-core/src/vs/editor/contrib/codeAction/browser/codeActionController').CodeActionController} */
693
702
  const codeActionController = editor.getControl().getContribution('editor.contrib.codeActionController');
694
703
  const lightBulbNode = () => {
695
- const ui = codeActionController['_ui'].rawValue;
696
- const lightBulb = ui && ui['_lightBulbWidget'].rawValue;
704
+ const lightBulb = codeActionController['_lightBulbWidget'].rawValue;
697
705
  return lightBulb && lightBulb['_domNode'];
698
706
  };
699
707
  const lightBulbVisible = () => {
@@ -703,14 +711,14 @@ SPAN {
703
711
 
704
712
  await timeout(1000); // quick fix is always available: need to wait for the error fix to become available.
705
713
  await commands.executeCommand('editor.action.quickFix');
706
- const codeActionSelector = '.codeActionWidget';
714
+ const codeActionSelector = '.action-widget';
707
715
  assert.isFalse(!!document.querySelector(codeActionSelector), 'Failed at assert 3 - codeActionWidget should not be visible');
708
716
 
709
717
  console.log('Waiting for Quick Fix widget to be visible');
710
718
  await waitForAnimation(() => {
711
719
  const quickFixWidgetVisible = !!document.querySelector(codeActionSelector);
712
720
  if (!quickFixWidgetVisible) {
713
- console.log('...');
721
+ // console.log('...');
714
722
  return false;
715
723
  }
716
724
  return true;
@@ -768,27 +776,12 @@ SPAN {
768
776
  assert.equal(editor.getControl().getModel().getLineLength(lineNumber), originalLength);
769
777
  });
770
778
 
771
- for (const referenceViewCommand of ['references-view.find', 'references-view.findImplementations']) {
772
- it(referenceViewCommand, async function () {
773
- let steps = 0;
774
- const editor = await openEditor(demoFileUri);
775
- editor.getControl().setPosition({ lineNumber: 24, column: 11 });
776
- assert.equal(editor.getControl().getModel().getWordAtPosition(editor.getControl().getPosition()).word, 'demoInstance');
777
- await commands.executeCommand(referenceViewCommand);
778
- const view = await pluginViewRegistry.openView('references-view.tree', { reveal: true });
779
- const expectedMessage = referenceViewCommand === 'references-view.find' ? '2 results in 1 file' : '1 result in 1 file';
780
- const getResultText = () => view.node.getElementsByClassName('theia-TreeViewInfo').item(0)?.textContent;
781
- await waitForAnimation(() => getResultText() === expectedMessage, 5000);
782
- assert.equal(getResultText(), expectedMessage);
783
- });
784
- }
785
-
786
779
  it('Can execute code actions', async function () {
787
780
  const editor = await openEditor(demoFileUri);
788
- /** @type {import('@theia/monaco-editor-core/src/vs/editor/contrib/codeAction/browser/codeActionCommands').CodeActionController} */
781
+ /** @type {import('@theia/monaco-editor-core/src/vs/editor/contrib/codeAction/browser/codeActionController').CodeActionController} */
789
782
  const codeActionController = editor.getControl().getContribution('editor.contrib.codeActionController');
790
783
  const isActionAvailable = () => {
791
- const lightbulbVisibility = codeActionController['_ui'].rawValue?.['_lightBulbWidget'].rawValue?.['_domNode'].style.visibility;
784
+ const lightbulbVisibility = codeActionController['_lightBulbWidget'].rawValue?.['_domNode'].style.visibility;
792
785
  return lightbulbVisibility !== undefined && lightbulbVisibility !== 'hidden';
793
786
  }
794
787
  assert.isFalse(isActionAvailable());
@@ -798,8 +791,16 @@ SPAN {
798
791
  await waitForAnimation(() => isActionAvailable(), 5000, 'No code action available. (1)');
799
792
  assert.isTrue(isActionAvailable());
800
793
 
794
+ try { // for some reason, we need to wait a second here, otherwise, we run into some cancellation.
795
+ await waitForAnimation(() => false, 1000);
796
+ } catch (e) {
797
+ }
798
+
801
799
  await commands.executeCommand('editor.action.quickFix');
802
- await waitForAnimation(() => Boolean(document.querySelector('.context-view-pointerBlock')), 5000, 'No context menu appeared. (1)');
800
+ await waitForAnimation(() => {
801
+ const elements = document.querySelector('.action-widget');
802
+ return !!elements;
803
+ }, 5000, 'No context menu appeared. (1)');
803
804
  await animationFrame();
804
805
 
805
806
  keybindings.dispatchKeyDown('Enter');
@@ -841,4 +842,19 @@ SPAN {
841
842
  assert.isNotNull(editor.getControl().getModel());
842
843
  await waitForAnimation(() => editor.getControl().getModel().getLineContent(30) === 'import { DefinedInterface } from "./demo-definitions-file";', 5000, 'The named import did not take effect.');
843
844
  });
845
+
846
+ for (const referenceViewCommand of ['references-view.find', 'references-view.findImplementations']) {
847
+ it(referenceViewCommand, async function () {
848
+ let steps = 0;
849
+ const editor = await openEditor(demoFileUri);
850
+ editor.getControl().setPosition({ lineNumber: 24, column: 11 });
851
+ assert.equal(editor.getControl().getModel().getWordAtPosition(editor.getControl().getPosition()).word, 'demoInstance');
852
+ await commands.executeCommand(referenceViewCommand);
853
+ const view = await pluginViewRegistry.openView('references-view.tree', { reveal: true });
854
+ const expectedMessage = referenceViewCommand === 'references-view.find' ? '2 results in 1 file' : '1 result in 1 file';
855
+ const getResultText = () => view.node.getElementsByClassName('theia-TreeViewInfo').item(0)?.textContent;
856
+ await waitForAnimation(() => getResultText() === expectedMessage, 5000);
857
+ assert.equal(getResultText(), expectedMessage);
858
+ });
859
+ }
844
860
  });