diff --git a/plugins/workspace-search/test/workspace_search_test.mocha.js b/plugins/workspace-search/test/workspace_search_test.mocha.js index 5b8fa85029..94c16fa002 100644 --- a/plugins/workspace-search/test/workspace_search_test.mocha.js +++ b/plugins/workspace-search/test/workspace_search_test.mocha.js @@ -67,6 +67,7 @@ suite('WorkspaceSearch', function () { this.jsdomCleanup = require('jsdom-global')( '
', ); + this.clock = sinon.useFakeTimers(); this.workspace = Blockly.inject('blocklyDiv'); this.workspaceSearch = new WorkspaceSearch(this.workspace); // See https://github.com/RaspberryPiFoundation/blockly-samples/issues/2528 for context. @@ -74,6 +75,10 @@ suite('WorkspaceSearch', function () { }); teardown(function () { + this.workspaceSearch.dispose(); + this.workspace.dispose(); + this.clock.runAll(); + this.clock.restore(); this.jsdomCleanup(); }); @@ -459,7 +464,7 @@ suite('WorkspaceSearch', function () { this.workspaceSearch.init(); // Check starting position this.focusManager = Blockly.FocusManager.getFocusManager(); - this.focusManager.focusTree(this.workspace); + this.focusManager.focusNode(this.alphaBlock); const originalBlock = /** @type {Blockly.BlockSvg} */ ( this.focusManager.getFocusedNode() ); @@ -483,11 +488,11 @@ suite('WorkspaceSearch', function () { assertFocusedNodeType('beta_block'); }); - test('close with no match restores focus', function () { + test('close with no match restores focus to workspace', function () { this.workspaceSearch.searchAndHighlight('nothingMatchesThis', false); this.workspaceSearch.close(); - assertFocusedNodeType('alpha_block'); + assert.equal(Blockly.getFocusManager().getFocusedNode(), this.workspace); }); test('close with match followed by non-match still focuses last found block', function () {