From 440a6bc32a20cce3fd4ec90970fc105147631c90 Mon Sep 17 00:00:00 2001 From: Matt Hillsdon Date: Wed, 2 Jul 2025 17:21:57 +0100 Subject: [PATCH] chore: lint for floating/misused promises Fix missing awaits in the tests. Needed tsconfig information so I've added the project setting - see https://typescript-eslint.io/blog/parser-options-project-true/#introducing-true I've done this just for the tests as otherwise we hit issues with the test app and the webdriver test app not being covered by tsconfig.json files. It could be trivially extended to the src tree. --- eslint.config.js | 13 +++++++++++++ test/webdriverio/test/keyboard_mode_test.ts | 6 +++--- test/webdriverio/test/scroll_test.ts | 2 +- test/webdriverio/test/test_setup.ts | 8 ++++---- test/webdriverio/test/workspace_comment_test.ts | 1 - 5 files changed, 21 insertions(+), 9 deletions(-) diff --git a/eslint.config.js b/eslint.config.js index 60bfe8ab..4a8f0fb3 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -259,4 +259,17 @@ module.exports = [ '@typescript-eslint/no-require-imports': 'error', }, }, + { + files: ['test/webdriverio/test/*.ts'], + languageOptions: { + parserOptions: { + project: true, + tsconfigRootDir: __dirname, + }, + }, + rules: { + '@typescript-eslint/no-floating-promises': 'error', + '@typescript-eslint/no-misused-promises': 'error', + }, + }, ]; diff --git a/test/webdriverio/test/keyboard_mode_test.ts b/test/webdriverio/test/keyboard_mode_test.ts index 692f0d9f..d022c69a 100644 --- a/test/webdriverio/test/keyboard_mode_test.ts +++ b/test/webdriverio/test/keyboard_mode_test.ts @@ -86,7 +86,7 @@ suite( chai.assert.isFalse(await isKeyboardNavigating(this.browser)); - this.browser.execute(() => { + await this.browser.execute(() => { Blockly.keyboardNavigationController.setIsActive(true); }); @@ -106,7 +106,7 @@ suite( chai.assert.isFalse(await isKeyboardNavigating(this.browser)); - this.browser.execute(() => { + await this.browser.execute(() => { Blockly.keyboardNavigationController.setIsActive(true); }); @@ -126,7 +126,7 @@ suite( await this.browser.pause(PAUSE_TIME); // Right click a block - clickBlock(this.browser, 'controls_if_1', {button: 'right'}); + await clickBlock(this.browser, 'controls_if_1', {button: 'right'}); await this.browser.pause(PAUSE_TIME); chai.assert.isFalse(await isKeyboardNavigating(this.browser)); diff --git a/test/webdriverio/test/scroll_test.ts b/test/webdriverio/test/scroll_test.ts index c198ff1a..305ca31c 100644 --- a/test/webdriverio/test/scroll_test.ts +++ b/test/webdriverio/test/scroll_test.ts @@ -24,7 +24,7 @@ suite('Scrolling into view', function () { setup(async function () { this.browser = await testSetup(testFileLocations.BASE); // Predictable small window size for scrolling. - this.browser.setWindowSize(800, 600); + await this.browser.setWindowSize(800, 600); await this.browser.pause(PAUSE_TIME); }); diff --git a/test/webdriverio/test/test_setup.ts b/test/webdriverio/test/test_setup.ts index 497e4796..e5d47aa7 100644 --- a/test/webdriverio/test/test_setup.ts +++ b/test/webdriverio/test/test_setup.ts @@ -441,10 +441,10 @@ export async function tabNavigateToWorkspace( hasFlyout = true, ) { // Navigate past the initial pre-injection focusable div element. - tabNavigateForward(browser); - if (hasToolbox) tabNavigateForward(browser); - if (hasFlyout) tabNavigateForward(browser); - tabNavigateForward(browser); // Tab to the workspace itself. + await tabNavigateForward(browser); + if (hasToolbox) await tabNavigateForward(browser); + if (hasFlyout) await tabNavigateForward(browser); + await tabNavigateForward(browser); // Tab to the workspace itself. } /** diff --git a/test/webdriverio/test/workspace_comment_test.ts b/test/webdriverio/test/workspace_comment_test.ts index 82d6fe12..eb882e27 100644 --- a/test/webdriverio/test/workspace_comment_test.ts +++ b/test/webdriverio/test/workspace_comment_test.ts @@ -7,7 +7,6 @@ import * as chai from 'chai'; import * as Blockly from 'blockly'; import { - contextMenuExists, focusOnBlock, getCurrentFocusNodeId, getFocusedBlockType,