Skip to content

Commit 8f31409

Browse files
committed
test(mover): Improve error handling in getSelectedNeighbourInfo
1 parent 5d20b95 commit 8f31409

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

test/webdriverio/test/move_test.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -190,10 +190,12 @@ suite('Move tests', function () {
190190
*/
191191
function getSelectedNeighbourInfo(browser: WebdriverIO.Browser) {
192192
return browser.execute(() => {
193-
const block = Blockly.getFocusManager().getFocusedNode() as
194-
| Blockly.BlockSvg
195-
| undefined;
196-
if (!block) throw new Error('no selected block');
193+
const focused = Blockly.getFocusManager().getFocusedNode();
194+
if (!focused) throw new Error('nothing focused');
195+
if (!(focused instanceof Blockly.BlockSvg)) {
196+
throw new TypeError('focused node is not a BlockSvg');
197+
}
198+
const block = focused; // Inferred as BlockSvg.
197199
const parent = block?.getParent();
198200
return {
199201
parentId: parent?.id ?? null,

0 commit comments

Comments
 (0)