diff --git a/core/block_svg.ts b/core/block_svg.ts index 2655642d7..c6c9c9fa3 100644 --- a/core/block_svg.ts +++ b/core/block_svg.ts @@ -1029,7 +1029,6 @@ export class BlockSvg icon.applyColour(); icon.updateEditable(); this.queueRender(); - renderManagement.triggerQueuedRenders(); this.bumpNeighbours(); } @@ -1058,7 +1057,6 @@ export class BlockSvg if (this.rendered) { this.queueRender(); - renderManagement.triggerQueuedRenders(); this.bumpNeighbours(); } return removed; diff --git a/core/icons/comment_icon.ts b/core/icons/comment_icon.ts index 7756088b6..6042b44e2 100644 --- a/core/icons/comment_icon.ts +++ b/core/icons/comment_icon.ts @@ -22,6 +22,7 @@ import {Svg} from '../utils/svg.js'; import {TextBubble} from '../bubbles/text_bubble.js'; import {TextInputBubble} from '../bubbles/textinput_bubble.js'; import type {WorkspaceSvg} from '../workspace_svg.js'; +import * as renderManagement from '../render_management.js'; /** The size of the comment icon in workspace-scale units. */ const SIZE = 17; @@ -138,12 +139,12 @@ export class CommentIcon extends Icon implements IHasBubble, ISerializable { * Updates the state of the bubble (editable / noneditable) to reflect the * state of the bubble if the bubble is currently shown. */ - override updateEditable(): void { + override async updateEditable(): Promise { super.updateEditable(); if (this.bubbleIsVisible()) { // Close and reopen the bubble to display the correct UI. - this.setBubbleVisible(false); - this.setBubbleVisible(true); + await this.setBubbleVisible(false); + await this.setBubbleVisible(true); } } @@ -214,8 +215,7 @@ export class CommentIcon extends Icon implements IHasBubble, ISerializable { state['height'] ?? DEFAULT_BUBBLE_HEIGHT, ); this.bubbleVisiblity = state['pinned'] ?? false; - // Give the block a chance to be positioned and rendered before showing. - setTimeout(() => this.setBubbleVisible(this.bubbleVisiblity), 1); + this.setBubbleVisible(this.bubbleVisiblity); } override onClick(): void { @@ -263,7 +263,7 @@ export class CommentIcon extends Icon implements IHasBubble, ISerializable { return this.bubbleVisiblity; } - setBubbleVisible(visible: boolean): void { + async setBubbleVisible(visible: boolean): Promise { if (visible && (this.textBubble || this.textInputBubble)) return; if (!visible && !(this.textBubble || this.textInputBubble)) return; @@ -271,6 +271,8 @@ export class CommentIcon extends Icon implements IHasBubble, ISerializable { if (!this.sourceBlock.rendered || this.sourceBlock.isInFlyout) return; + await renderManagement.finishQueuedRenders(); + if (visible) { if (this.sourceBlock.isEditable()) { this.showEditableBubble(); diff --git a/core/icons/mutator_icon.ts b/core/icons/mutator_icon.ts index 56365ed1f..f4c1ea83d 100644 --- a/core/icons/mutator_icon.ts +++ b/core/icons/mutator_icon.ts @@ -24,6 +24,7 @@ import {Svg} from '../utils/svg.js'; import type {WorkspaceSvg} from '../workspace_svg.js'; import * as deprecation from '../utils/deprecation.js'; import {IconType} from './icon_types.js'; +import * as renderManagement from '../render_management.js'; /** The size of the mutator icon in workspace-scale units. */ const SIZE = 17; @@ -165,9 +166,11 @@ export class MutatorIcon extends Icon implements IHasBubble { return !!this.miniWorkspaceBubble; } - setBubbleVisible(visible: boolean): void { + async setBubbleVisible(visible: boolean): Promise { if (this.bubbleIsVisible() === visible) return; + await renderManagement.finishQueuedRenders(); + if (visible) { this.miniWorkspaceBubble = new MiniWorkspaceBubble( this.getMiniWorkspaceConfig(), diff --git a/core/icons/warning_icon.ts b/core/icons/warning_icon.ts index f0862c3e9..08f511a60 100644 --- a/core/icons/warning_icon.ts +++ b/core/icons/warning_icon.ts @@ -17,6 +17,7 @@ import {Size} from '../utils.js'; import {Svg} from '../utils/svg.js'; import {TextBubble} from '../bubbles/text_bubble.js'; import {IconType} from './icon_types.js'; +import * as renderManagement from '../render_management.js'; /** The size of the warning icon in workspace-scale units. */ const SIZE = 17; @@ -168,9 +169,11 @@ export class WarningIcon extends Icon implements IHasBubble { return !!this.textBubble; } - setBubbleVisible(visible: boolean): void { + async setBubbleVisible(visible: boolean): Promise { if (this.bubbleIsVisible() === visible) return; + await renderManagement.finishQueuedRenders(); + if (visible) { this.textBubble = new TextBubble( this.getText(), diff --git a/core/interfaces/i_has_bubble.ts b/core/interfaces/i_has_bubble.ts index a2ba6093a..276feff21 100644 --- a/core/interfaces/i_has_bubble.ts +++ b/core/interfaces/i_has_bubble.ts @@ -9,7 +9,7 @@ export interface IHasBubble { bubbleIsVisible(): boolean; /** Sets whether the bubble is open or not. */ - setBubbleVisible(visible: boolean): void; + setBubbleVisible(visible: boolean): Promise; } /** Type guard that checks whether the given object is a IHasBubble. */ diff --git a/tests/mocha/blocks/procedures_test.js b/tests/mocha/blocks/procedures_test.js index 6173179cd..f9d027c99 100644 --- a/tests/mocha/blocks/procedures_test.js +++ b/tests/mocha/blocks/procedures_test.js @@ -86,10 +86,10 @@ suite('Procedures', function () { }); suite('adding procedure parameters', function () { - test('the mutator flyout updates to avoid parameter name conflicts', function () { + test('the mutator flyout updates to avoid parameter name conflicts', async function () { const defBlock = createProcDefBlock(this.workspace); const mutatorIcon = defBlock.getIcon(Blockly.icons.MutatorIcon.TYPE); - mutatorIcon.setBubbleVisible(true); + await mutatorIcon.setBubbleVisible(true); const mutatorWorkspace = mutatorIcon.getWorkspace(); const origFlyoutParamName = mutatorWorkspace .getFlyout() @@ -119,11 +119,11 @@ suite('Procedures', function () { ); }); - test('adding a parameter to the procedure updates procedure defs', function () { + test('adding a parameter to the procedure updates procedure defs', async function () { // Create a stack of container, parameter. const defBlock = createProcDefBlock(this.workspace); const mutatorIcon = defBlock.getIcon(Blockly.icons.MutatorIcon.TYPE); - mutatorIcon.setBubbleVisible(true); + await mutatorIcon.setBubbleVisible(true); const mutatorWorkspace = mutatorIcon.getWorkspace(); const containerBlock = mutatorWorkspace.getTopBlocks()[0]; const paramBlock = mutatorWorkspace.newBlock('procedures_mutatorarg'); @@ -143,12 +143,12 @@ suite('Procedures', function () { ); }); - test('adding a parameter to the procedure updates procedure callers', function () { + test('adding a parameter to the procedure updates procedure callers', async function () { // Create a stack of container, parameter. const defBlock = createProcDefBlock(this.workspace); const callBlock = createProcCallBlock(this.workspace); const mutatorIcon = defBlock.getIcon(Blockly.icons.MutatorIcon.TYPE); - mutatorIcon.setBubbleVisible(true); + await mutatorIcon.setBubbleVisible(true); const mutatorWorkspace = mutatorIcon.getWorkspace(); const containerBlock = mutatorWorkspace.getTopBlocks()[0]; const paramBlock = mutatorWorkspace.newBlock('procedures_mutatorarg'); @@ -169,11 +169,11 @@ suite('Procedures', function () { ); }); - test('undoing adding a procedure parameter removes it', function () { + test('undoing adding a procedure parameter removes it', async function () { // Create a stack of container, parameter. const defBlock = createProcDefBlock(this.workspace); const mutatorIcon = defBlock.getIcon(Blockly.icons.MutatorIcon.TYPE); - mutatorIcon.setBubbleVisible(true); + await mutatorIcon.setBubbleVisible(true); const mutatorWorkspace = mutatorIcon.getWorkspace(); const containerBlock = mutatorWorkspace.getTopBlocks()[0]; const paramBlock = mutatorWorkspace.newBlock('procedures_mutatorarg'); @@ -194,11 +194,11 @@ suite('Procedures', function () { test( 'undoing and redoing adding a procedure parameter maintains ' + 'the same state', - function () { + async function () { // Create a stack of container, parameter. const defBlock = createProcDefBlock(this.workspace); const mutatorIcon = defBlock.getIcon(Blockly.icons.MutatorIcon.TYPE); - mutatorIcon.setBubbleVisible(true); + await mutatorIcon.setBubbleVisible(true); const mutatorWorkspace = mutatorIcon.getWorkspace(); const containerBlock = mutatorWorkspace.getTopBlocks()[0]; const paramBlock = mutatorWorkspace.newBlock('procedures_mutatorarg'); @@ -224,11 +224,11 @@ suite('Procedures', function () { }); suite('deleting procedure parameters', function () { - test('deleting a parameter from the procedure updates procedure defs', function () { + test('deleting a parameter from the procedure updates procedure defs', async function () { // Create a stack of container, parameter. const defBlock = createProcDefBlock(this.workspace); const mutatorIcon = defBlock.getIcon(Blockly.icons.MutatorIcon.TYPE); - mutatorIcon.setBubbleVisible(true); + await mutatorIcon.setBubbleVisible(true); const mutatorWorkspace = mutatorIcon.getWorkspace(); const containerBlock = mutatorWorkspace.getTopBlocks()[0]; const paramBlock = mutatorWorkspace.newBlock('procedures_mutatorarg'); @@ -247,12 +247,12 @@ suite('Procedures', function () { ); }); - test('deleting a parameter from the procedure udpates procedure callers', function () { + test('deleting a parameter from the procedure udpates procedure callers', async function () { // Create a stack of container, parameter. const defBlock = createProcDefBlock(this.workspace); const callBlock = createProcCallBlock(this.workspace); const mutatorIcon = defBlock.getIcon(Blockly.icons.MutatorIcon.TYPE); - mutatorIcon.setBubbleVisible(true); + await mutatorIcon.setBubbleVisible(true); const mutatorWorkspace = mutatorIcon.getWorkspace(); const containerBlock = mutatorWorkspace.getTopBlocks()[0]; const paramBlock = mutatorWorkspace.newBlock('procedures_mutatorarg'); @@ -271,11 +271,11 @@ suite('Procedures', function () { ); }); - test('undoing deleting a procedure parameter adds it', function () { + test('undoing deleting a procedure parameter adds it', async function () { // Create a stack of container, parameter. const defBlock = createProcDefBlock(this.workspace); const mutatorIcon = defBlock.getIcon(Blockly.icons.MutatorIcon.TYPE); - mutatorIcon.setBubbleVisible(true); + await mutatorIcon.setBubbleVisible(true); const mutatorWorkspace = mutatorIcon.getWorkspace(); const containerBlock = mutatorWorkspace.getTopBlocks()[0]; const paramBlock = mutatorWorkspace.newBlock('procedures_mutatorarg'); @@ -298,11 +298,11 @@ suite('Procedures', function () { test( 'undoing and redoing deleting a procedure parameter maintains ' + 'the same state', - function () { + async function () { // Create a stack of container, parameter. const defBlock = createProcDefBlock(this.workspace); const mutatorIcon = defBlock.getIcon(Blockly.icons.MutatorIcon.TYPE); - mutatorIcon.setBubbleVisible(true); + await mutatorIcon.setBubbleVisible(true); const mutatorWorkspace = mutatorIcon.getWorkspace(); const containerBlock = mutatorWorkspace.getTopBlocks()[0]; const paramBlock = mutatorWorkspace.newBlock('procedures_mutatorarg'); @@ -326,11 +326,11 @@ suite('Procedures', function () { }); suite('renaming procedure parameters', function () { - test('defs are updated for parameter renames', function () { + test('defs are updated for parameter renames', async function () { // Create a stack of container, parameter. const defBlock = createProcDefBlock(this.workspace); const mutatorIcon = defBlock.getIcon(Blockly.icons.MutatorIcon.TYPE); - mutatorIcon.setBubbleVisible(true); + await mutatorIcon.setBubbleVisible(true); const mutatorWorkspace = mutatorIcon.getWorkspace(); const containerBlock = mutatorWorkspace.getTopBlocks()[0]; const paramBlock = mutatorWorkspace.newBlock('procedures_mutatorarg'); @@ -353,11 +353,11 @@ suite('Procedures', function () { ); }); - test('defs are updated for parameter renames when two params exist', function () { + test('defs are updated for parameter renames when two params exist', async function () { // Create a stack of container, parameter. const defBlock = createProcDefBlock(this.workspace); const mutatorIcon = defBlock.getIcon(Blockly.icons.MutatorIcon.TYPE); - mutatorIcon.setBubbleVisible(true); + await mutatorIcon.setBubbleVisible(true); const mutatorWorkspace = mutatorIcon.getWorkspace(); const containerBlock = mutatorWorkspace.getTopBlocks()[0]; const paramBlock1 = mutatorWorkspace.newBlock('procedures_mutatorarg'); @@ -383,12 +383,12 @@ suite('Procedures', function () { ); }); - test('callers are updated for parameter renames', function () { + test('callers are updated for parameter renames', async function () { // Create a stack of container, parameter. const defBlock = createProcDefBlock(this.workspace); const callBlock = createProcCallBlock(this.workspace); const mutatorIcon = defBlock.getIcon(Blockly.icons.MutatorIcon.TYPE); - mutatorIcon.setBubbleVisible(true); + await mutatorIcon.setBubbleVisible(true); const mutatorWorkspace = mutatorIcon.getWorkspace(); const containerBlock = mutatorWorkspace.getTopBlocks()[0]; const paramBlock = mutatorWorkspace.newBlock('procedures_mutatorarg'); @@ -412,12 +412,12 @@ suite('Procedures', function () { ); }); - test('variables associated with procedure parameters are not renamed', function () { + test('variables associated with procedure parameters are not renamed', async function () { // Create a stack of container, parameter. const defBlock = createProcDefBlock(this.workspace); const callBlock = createProcCallBlock(this.workspace); const mutatorIcon = defBlock.getIcon(Blockly.icons.MutatorIcon.TYPE); - mutatorIcon.setBubbleVisible(true); + await mutatorIcon.setBubbleVisible(true); const mutatorWorkspace = mutatorIcon.getWorkspace(); const containerBlock = mutatorWorkspace.getTopBlocks()[0]; const paramBlock = mutatorWorkspace.newBlock('procedures_mutatorarg'); @@ -436,11 +436,11 @@ suite('Procedures', function () { ); }); - test('renaming a variable associated with a parameter updates procedure defs', function () { + test('renaming a variable associated with a parameter updates procedure defs', async function () { // Create a stack of container, parameter. const defBlock = createProcDefBlock(this.workspace); const mutatorIcon = defBlock.getIcon(Blockly.icons.MutatorIcon.TYPE); - mutatorIcon.setBubbleVisible(true); + await mutatorIcon.setBubbleVisible(true); const mutatorWorkspace = mutatorIcon.getWorkspace(); const containerBlock = mutatorWorkspace.getTopBlocks()[0]; const paramBlock = mutatorWorkspace.newBlock('procedures_mutatorarg'); @@ -464,11 +464,11 @@ suite('Procedures', function () { ); }); - test('renaming a variable associated with a parameter updates mutator parameters', function () { + test('renaming a variable associated with a parameter updates mutator parameters', async function () { // Create a stack of container, parameter. const defBlock = createProcDefBlock(this.workspace); const mutatorIcon = defBlock.getIcon(Blockly.icons.MutatorIcon.TYPE); - mutatorIcon.setBubbleVisible(true); + await mutatorIcon.setBubbleVisible(true); const mutatorWorkspace = mutatorIcon.getWorkspace(); const containerBlock = mutatorWorkspace.getTopBlocks()[0]; const paramBlock = mutatorWorkspace.newBlock('procedures_mutatorarg'); @@ -488,12 +488,12 @@ suite('Procedures', function () { ); }); - test('renaming a variable associated with a parameter updates procedure callers', function () { + test('renaming a variable associated with a parameter updates procedure callers', async function () { // Create a stack of container, parameter. const defBlock = createProcDefBlock(this.workspace); const callBlock = createProcCallBlock(this.workspace); const mutatorIcon = defBlock.getIcon(Blockly.icons.MutatorIcon.TYPE); - mutatorIcon.setBubbleVisible(true); + await mutatorIcon.setBubbleVisible(true); const mutatorWorkspace = mutatorIcon.getWorkspace(); const containerBlock = mutatorWorkspace.getTopBlocks()[0]; const paramBlock = mutatorWorkspace.newBlock('procedures_mutatorarg'); @@ -518,11 +518,11 @@ suite('Procedures', function () { ); }); - test('coalescing a variable associated with a parameter updates procedure defs', function () { + test('coalescing a variable associated with a parameter updates procedure defs', async function () { // Create a stack of container, parameter. const defBlock = createProcDefBlock(this.workspace); const mutatorIcon = defBlock.getIcon(Blockly.icons.MutatorIcon.TYPE); - mutatorIcon.setBubbleVisible(true); + await mutatorIcon.setBubbleVisible(true); const mutatorWorkspace = mutatorIcon.getWorkspace(); const containerBlock = mutatorWorkspace.getTopBlocks()[0]; const paramBlock = mutatorWorkspace.newBlock('procedures_mutatorarg'); @@ -546,11 +546,11 @@ suite('Procedures', function () { ); }); - test('coalescing a variable associated with a parameter updates mutator parameters', function () { + test('coalescing a variable associated with a parameter updates mutator parameters', async function () { // Create a stack of container, parameter. const defBlock = createProcDefBlock(this.workspace); const mutatorIcon = defBlock.getIcon(Blockly.icons.MutatorIcon.TYPE); - mutatorIcon.setBubbleVisible(true); + await mutatorIcon.setBubbleVisible(true); const mutatorWorkspace = mutatorIcon.getWorkspace(); const containerBlock = mutatorWorkspace.getTopBlocks()[0]; const paramBlock = mutatorWorkspace.newBlock('procedures_mutatorarg'); @@ -570,12 +570,12 @@ suite('Procedures', function () { ); }); - test('coalescing a variable associated with a parameter updates procedure callers', function () { + test('coalescing a variable associated with a parameter updates procedure callers', async function () { // Create a stack of container, parameter. const defBlock = createProcDefBlock(this.workspace); const callBlock = createProcCallBlock(this.workspace); const mutatorIcon = defBlock.getIcon(Blockly.icons.MutatorIcon.TYPE); - mutatorIcon.setBubbleVisible(true); + await mutatorIcon.setBubbleVisible(true); const mutatorWorkspace = mutatorIcon.getWorkspace(); const containerBlock = mutatorWorkspace.getTopBlocks()[0]; const paramBlock = mutatorWorkspace.newBlock('procedures_mutatorarg'); @@ -606,11 +606,11 @@ suite('Procedures', function () { function () {}, ); - test('undoing renaming a procedure parameter reverts the change', function () { + test('undoing renaming a procedure parameter reverts the change', async function () { // Create a stack of container, parameter. const defBlock = createProcDefBlock(this.workspace); const mutatorIcon = defBlock.getIcon(Blockly.icons.MutatorIcon.TYPE); - mutatorIcon.setBubbleVisible(true); + await mutatorIcon.setBubbleVisible(true); const mutatorWorkspace = mutatorIcon.getWorkspace(); const containerBlock = mutatorWorkspace.getTopBlocks()[0]; const paramBlock = mutatorWorkspace.newBlock('procedures_mutatorarg'); @@ -637,11 +637,11 @@ suite('Procedures', function () { ); }); - test('undoing and redoing renaming a procedure maintains the same state', function () { + test('undoing and redoing renaming a procedure maintains the same state', async function () { // Create a stack of container, parameter. const defBlock = createProcDefBlock(this.workspace); const mutatorIcon = defBlock.getIcon(Blockly.icons.MutatorIcon.TYPE); - mutatorIcon.setBubbleVisible(true); + await mutatorIcon.setBubbleVisible(true); const mutatorWorkspace = mutatorIcon.getWorkspace(); const containerBlock = mutatorWorkspace.getTopBlocks()[0]; const paramBlock = mutatorWorkspace.newBlock('procedures_mutatorarg'); @@ -670,11 +670,11 @@ suite('Procedures', function () { }); suite('reordering procedure parameters', function () { - test('reordering procedure parameters updates procedure blocks', function () { + test('reordering procedure parameters updates procedure blocks', async function () { // Create a stack of container, parameter, parameter. const defBlock = createProcDefBlock(this.workspace); const mutatorIcon = defBlock.getIcon(Blockly.icons.MutatorIcon.TYPE); - mutatorIcon.setBubbleVisible(true); + await mutatorIcon.setBubbleVisible(true); const mutatorWorkspace = mutatorIcon.getWorkspace(); const containerBlock = mutatorWorkspace.getTopBlocks()[0]; const paramBlock1 = mutatorWorkspace.newBlock('procedures_mutatorarg'); @@ -706,12 +706,12 @@ suite('Procedures', function () { ); }); - test('reordering procedure parameters updates caller blocks', function () { + test('reordering procedure parameters updates caller blocks', async function () { // Create a stack of container, parameter, parameter. const defBlock = createProcDefBlock(this.workspace); const callBlock = createProcCallBlock(this.workspace); const mutatorIcon = defBlock.getIcon(Blockly.icons.MutatorIcon.TYPE); - mutatorIcon.setBubbleVisible(true); + await mutatorIcon.setBubbleVisible(true); const mutatorWorkspace = mutatorIcon.getWorkspace(); const containerBlock = mutatorWorkspace.getTopBlocks()[0]; const paramBlock1 = mutatorWorkspace.newBlock('procedures_mutatorarg'); @@ -756,12 +756,12 @@ suite('Procedures', function () { test( 'reordering procedure parameters reorders the blocks ' + 'attached to caller inputs', - function () { + async function () { // Create a stack of container, parameter, parameter. const defBlock = createProcDefBlock(this.workspace); const callBlock = createProcCallBlock(this.workspace); const mutatorIcon = defBlock.getIcon(Blockly.icons.MutatorIcon.TYPE); - mutatorIcon.setBubbleVisible(true); + await mutatorIcon.setBubbleVisible(true); const mutatorWorkspace = mutatorIcon.getWorkspace(); const containerBlock = mutatorWorkspace.getTopBlocks()[0]; const paramBlock1 = mutatorWorkspace.newBlock('procedures_mutatorarg'); @@ -1909,11 +1909,11 @@ suite('Procedures', function () { } }); suite('Untyped Arguments', function () { - function createMutator(argArray) { + async function createMutator(argArray) { const mutatorIcon = this.defBlock.getIcon( Blockly.icons.MutatorIcon.TYPE, ); - mutatorIcon.setBubbleVisible(true); + await mutatorIcon.setBubbleVisible(true); this.mutatorWorkspace = mutatorIcon.getWorkspace(); this.containerBlock = this.mutatorWorkspace.getTopBlocks()[0]; this.connection = @@ -1946,58 +1946,58 @@ suite('Procedures', function () { chai.assert.equal(this.callBlock.getVars()[i], argArray[i]); } } - test('Simple Add Arg', function () { + test('Simple Add Arg', async function () { const args = ['arg1']; - createMutator.call(this, args); + await createMutator.call(this, args); assertArgs.call(this, args); }); - test('Multiple Args', function () { + test('Multiple Args', async function () { const args = ['arg1', 'arg2', 'arg3']; - createMutator.call(this, args); + await createMutator.call(this, args); assertArgs.call(this, args); }); - test('Simple Change Arg', function () { - createMutator.call(this, ['arg1']); + test('Simple Change Arg', async function () { + await createMutator.call(this, ['arg1']); this.argBlock.setFieldValue('arg2', 'NAME'); this.defBlock.compose(this.containerBlock); assertArgs.call(this, ['arg2']); }); - test('lower -> CAPS', function () { - createMutator.call(this, ['arg']); + test('lower -> CAPS', async function () { + await createMutator.call(this, ['arg']); this.argBlock.setFieldValue('ARG', 'NAME'); this.defBlock.compose(this.containerBlock); assertArgs.call(this, ['ARG']); }); - test('CAPS -> lower', function () { - createMutator.call(this, ['ARG']); + test('CAPS -> lower', async function () { + await createMutator.call(this, ['ARG']); this.argBlock.setFieldValue('arg', 'NAME'); this.defBlock.compose(this.containerBlock); assertArgs.call(this, ['arg']); }); // Test case for #1958 - test('Set Arg Empty', function () { + test('Set Arg Empty', async function () { const args = ['arg1']; - createMutator.call(this, args); + await createMutator.call(this, args); this.argBlock.setFieldValue('', 'NAME'); this.defBlock.compose(this.containerBlock); assertArgs.call(this, args); }); - test('Whitespace', function () { + test('Whitespace', async function () { const args = ['arg1']; - createMutator.call(this, args); + await createMutator.call(this, args); this.argBlock.setFieldValue(' ', 'NAME'); this.defBlock.compose(this.containerBlock); assertArgs.call(this, args); }); - test('Whitespace and Text', function () { - createMutator.call(this, ['arg1']); + test('Whitespace and Text', async function () { + await createMutator.call(this, ['arg1']); this.argBlock.setFieldValue(' text ', 'NAME'); this.defBlock.compose(this.containerBlock); assertArgs.call(this, ['text']); }); - test('<>', function () { + test('<>', async function () { const args = ['<>']; - createMutator.call(this, args); + await createMutator.call(this, args); assertArgs.call(this, args); }); }); diff --git a/tests/mocha/comment_test.js b/tests/mocha/comment_test.js index 6f19aa7f0..452f07493 100644 --- a/tests/mocha/comment_test.js +++ b/tests/mocha/comment_test.js @@ -47,8 +47,8 @@ suite('Comments', function () { chai.assert.isNotOk(comment.textInputBubble); chai.assert.isOk(comment.textBubble); } - test('Editable', function () { - this.comment.setBubbleVisible(true); + test('Editable', async function () { + await this.comment.setBubbleVisible(true); chai.assert.isTrue(this.comment.bubbleIsVisible()); assertEditable(this.comment); assertEventFired( @@ -59,10 +59,10 @@ suite('Comments', function () { this.block.id, ); }); - test('Not Editable', function () { + test('Not Editable', async function () { sinon.stub(this.block, 'isEditable').returns(false); - this.comment.setBubbleVisible(true); + await this.comment.setBubbleVisible(true); chai.assert.isTrue(this.comment.bubbleIsVisible()); assertNotEditable(this.comment); @@ -74,11 +74,11 @@ suite('Comments', function () { this.block.id, ); }); - test('Editable -> Not Editable', function () { - this.comment.setBubbleVisible(true); + test('Editable -> Not Editable', async function () { + await this.comment.setBubbleVisible(true); sinon.stub(this.block, 'isEditable').returns(false); - this.comment.updateEditable(); + await this.comment.updateEditable(); chai.assert.isTrue(this.comment.bubbleIsVisible()); assertNotEditable(this.comment); @@ -90,14 +90,14 @@ suite('Comments', function () { this.block.id, ); }); - test('Not Editable -> Editable', function () { + test('Not Editable -> Editable', async function () { const editableStub = sinon.stub(this.block, 'isEditable').returns(false); - this.comment.setBubbleVisible(true); + await this.comment.setBubbleVisible(true); editableStub.returns(true); - this.comment.updateEditable(); + await this.comment.updateEditable(); chai.assert.isTrue(this.comment.bubbleIsVisible()); assertEditable(this.comment); assertEventFired( diff --git a/tests/mocha/mutator_test.js b/tests/mocha/mutator_test.js index 609dc03a2..b4c6930fa 100644 --- a/tests/mocha/mutator_test.js +++ b/tests/mocha/mutator_test.js @@ -31,10 +31,10 @@ suite('Mutator', function () { sharedTestTeardown.call(this); }); - test('No change', function () { + test('No change', async function () { const block = createRenderedBlock(this.workspace, 'xml_block'); const icon = block.getIcon(Blockly.icons.MutatorIcon.TYPE); - icon.setBubbleVisible(true); + await icon.setBubbleVisible(true); const mutatorWorkspace = icon.getWorkspace(); // Trigger mutator change listener. createRenderedBlock(mutatorWorkspace, 'checkbox_block'); @@ -43,10 +43,10 @@ suite('Mutator', function () { }); }); - test('XML', function () { + test('XML', async function () { const block = createRenderedBlock(this.workspace, 'xml_block'); const icon = block.getIcon(Blockly.icons.MutatorIcon.TYPE); - icon.setBubbleVisible(true); + await icon.setBubbleVisible(true); const mutatorWorkspace = icon.getWorkspace(); mutatorWorkspace .getBlockById('check_block') @@ -63,10 +63,10 @@ suite('Mutator', function () { ); }); - test('JSO', function () { + test('JSO', async function () { const block = createRenderedBlock(this.workspace, 'jso_block'); const icon = block.getIcon(Blockly.icons.MutatorIcon.TYPE); - icon.setBubbleVisible(true); + await icon.setBubbleVisible(true); const mutatorWorkspace = icon.getWorkspace(); mutatorWorkspace .getBlockById('check_block')