Skip to content

Commit

Permalink
Fix more tests
Browse files Browse the repository at this point in the history
Signed-off-by: Thomas Mäder <t.s.maeder@gmail.com>
  • Loading branch information
tsmaeder committed Jan 12, 2024
1 parent be71d55 commit 2f74624
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
6 changes: 3 additions & 3 deletions examples/api-tests/src/monaco-api.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,11 +177,11 @@ describe('Monaco API', async function () {
const key = 'monaco-api-test-context';
const firstValue = 'first setting';
const secondValue = 'second setting';
assert.isFalse(contextKeys.match(`${key} == ${firstValue}`));
assert.isFalse(contextKeys.match(`${key} == '${firstValue}'`));
await commands.executeCommand(setContext, key, firstValue);
assert.isTrue(contextKeys.match(`${key} == ${firstValue}`));
assert.isTrue(contextKeys.match(`${key} == '${firstValue}'`));
await commands.executeCommand(setContext, key, secondValue);
assert.isTrue(contextKeys.match(`${key} == ${secondValue}`));
assert.isTrue(contextKeys.match(`${key} == '${secondValue}'`));
});

it('Supports context key: inQuickOpen', async () => {
Expand Down
15 changes: 7 additions & 8 deletions examples/api-tests/src/typescript.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -688,11 +688,10 @@ SPAN {
editor.getControl().revealPosition({ lineNumber, column });
assert.equal(currentChar(), ';', 'Failed at assert 1');

/** @type {import('@theia/monaco-editor-core/src/vs/editor/contrib/codeAction/browser/codeActionCommands').CodeActionController} */
/** @type {import('@theia/monaco-editor-core/src/vs/editor/contrib/codeAction/browser/codeActionController').CodeActionController} */
const codeActionController = editor.getControl().getContribution('editor.contrib.codeActionController');
const lightBulbNode = () => {
const ui = codeActionController['_ui'].rawValue;
const lightBulb = ui && ui['_lightBulbWidget'].rawValue;
const lightBulb = codeActionController['_lightBulbWidget'].rawValue;
return lightBulb && lightBulb['_domNode'];
};
const lightBulbVisible = () => {
Expand All @@ -704,14 +703,14 @@ SPAN {
await waitForAnimation(() => lightBulbVisible());

await commands.executeCommand('editor.action.quickFix');
const codeActionSelector = '.codeActionWidget';
const codeActionSelector = '.action-widget';
assert.isFalse(!!document.querySelector(codeActionSelector), 'Failed at assert 3 - codeActionWidget should not be visible');

console.log('Waiting for Quick Fix widget to be visible');
await waitForAnimation(() => {
const quickFixWidgetVisible = !!document.querySelector(codeActionSelector);
if (!quickFixWidgetVisible) {
console.log('...');
// console.log('...');
return false;
}
return true;
Expand Down Expand Up @@ -797,10 +796,10 @@ SPAN {

it('Can execute code actions', async function () {
const editor = await openEditor(demoFileUri);
/** @type {import('@theia/monaco-editor-core/src/vs/editor/contrib/codeAction/browser/codeActionCommands').CodeActionController} */
/** @type {import('@theia/monaco-editor-core/src/vs/editor/contrib/codeAction/browser/codeActionController').CodeActionController} */
const codeActionController = editor.getControl().getContribution('editor.contrib.codeActionController');
const isActionAvailable = () => {
const lightbulbVisibility = codeActionController['_ui'].rawValue?.['_lightBulbWidget'].rawValue?.['_domNode'].style.visibility;
const lightbulbVisibility = codeActionController['_lightBulbWidget'].rawValue?.['_domNode'].style.visibility;
return lightbulbVisibility !== undefined && lightbulbVisibility !== 'hidden';
}
assert.isFalse(isActionAvailable());
Expand All @@ -811,7 +810,7 @@ SPAN {
assert.isTrue(isActionAvailable());

await commands.executeCommand('editor.action.quickFix');
await waitForAnimation(() => Boolean(document.querySelector('.context-view-pointerBlock')), 5000, 'No context menu appeared. (1)');
await waitForAnimation(() => Boolean(document.querySelector('.action-widget')), 5000, 'No context menu appeared. (1)');
await animationFrame();

keybindings.dispatchKeyDown('Enter');
Expand Down

0 comments on commit 2f74624

Please sign in to comment.